Skip to content

Commit

Permalink
parse_libvirt_xml: look for manual firmware in "/domain/os/loader/@type"
Browse files Browse the repository at this point in the history
According to [1], there're different ways to specify which firmware is
to be used by a libvirt-driven VM.  Namely, there's an automatic
firmware selection, e.g.:

    ...
    <os firmware='(bios|efi)'>
    ...

and a manual one, e.g.:

    ...
    <os>
        <loader readonly='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.fd</loader>
        ...
    </os>
    ...

with the latter being a way to specify UEFI firmware.  So let's add this
search path as well when parsing source VM's libvirt xml.

[1] https://libvirt.org/formatdomain.html#bios-bootloader

Co-authored-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Andrey Drobyshev <andrey.drobyshev@virtuozzo.com>
Originally-by: Denis Plotnikov <dplotnikov@virtuozzo.com>
Message-Id: <20221220150133.403120-1-andrey.drobyshev@virtuozzo.com>
  • Loading branch information
Andrey Drobyshev and lersek committed Dec 21, 2022
1 parent 1c8ff40 commit 7361431
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions input/parse_libvirt_xml.ml
Original file line number Diff line number Diff line change
Expand Up @@ -446,12 +446,23 @@ let parse_libvirt_xml ?conn xml =
done;
List.rev !nics in

(* Firmware. *)
(* Firmware.
* If "/domain/os" node doesn't contain "firmware" attribute (automatic
* firmware), we look for the presence of "pflash" in
* "/domain/os/loader/@type" attribute (manual firmware), with the latter
* indicating the UEFI firmware.
* See https://libvirt.org/formatdomain.html#bios-bootloader
*)
let firmware =
match xpath_string "/domain/os/@firmware" with
| Some "bios" -> BIOS
| Some "efi" -> UEFI
| None | Some _ -> UnknownFirmware in
| Some _ -> UnknownFirmware
| None -> (
match xpath_string "/domain/os/loader/@type" with
| Some "pflash" -> UEFI
| _ -> UnknownFirmware
) in

(* Check for hostdev devices. (RHBZ#1472719) *)
let () =
Expand Down

0 comments on commit 7361431

Please sign in to comment.