v2v: efi: Model firmware in source metadata.

Also modify the input_* drivers so they pull out the firmware from the
metadata.  Currently this is only possible for `-i ova', since libvirt
does not expose it (RHBZ#1217444).
This commit is contained in:
Richard W.M. Jones
2015-04-30 13:44:35 +01:00
parent 9a45508f23
commit ef77725081
10 changed files with 41 additions and 1 deletions

View File

@@ -85,6 +85,7 @@ class input_disk verbose input_format disk = object
s_memory = 2048L *^ 1024L *^ 1024L; (* 2048 MB *)
s_vcpu = 1; (* 1 vCPU is a safe default *)
s_features = [ "acpi"; "apic"; "pae" ];
s_firmware = UnknownFirmware; (* causes virt-v2v to autodetect *)
s_display =
Some { s_display_type = Window; s_keymap = None; s_password = None;
s_listen = LNone; s_port = None };

View File

@@ -346,6 +346,7 @@ let parse_libvirt_xml ?conn ~verbose xml =
s_memory = memory;
s_vcpu = vcpu;
s_features = features;
s_firmware = UnknownFirmware; (* XXX until RHBZ#1217444 is fixed *)
s_display = display;
s_sound = sound;
s_disks = [];

View File

@@ -175,6 +175,8 @@ object
"ovf" "http://schemas.dmtf.org/ovf/envelope/1";
Xml.xpath_register_ns xpathctx
"rasd" "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData";
Xml.xpath_register_ns xpathctx
"vmw" "http://www.vmware.com/schema/ovf";
Xml.xpath_register_ns xpathctx
"vssd" "http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData";
@@ -211,6 +213,15 @@ object
(* Search for number of vCPUs. *)
let vcpu = xpath_to_int "/ovf:Envelope/ovf:VirtualSystem/ovf:VirtualHardwareSection/ovf:Item[rasd:ResourceType/text()=3]/rasd:VirtualQuantity/text()" 1 in
(* BIOS or EFI firmware? *)
let firmware = xpath_to_string "/ovf:Envelope/ovf:VirtualSystem/ovf:VirtualHardwareSection/vmw:Config[@vmw:key=\"firmware\"]/@vmw:value" "bios" in
let firmware =
match firmware with
| "bios" -> BIOS
| "efi" -> UEFI
| s ->
error (f_"unknown Config:firmware value %s (expected \"bios\" or \"efi\")") s in
(* Helper function to return the parent controller of a disk. *)
let parent_controller id =
let expr = sprintf "/ovf:Envelope/ovf:VirtualSystem/ovf:VirtualHardwareSection/ovf:Item[rasd:InstanceID/text()=%d]/rasd:ResourceType/text()" id in
@@ -358,6 +369,7 @@ object
s_memory = memory;
s_vcpu = vcpu;
s_features = []; (* XXX *)
s_firmware = firmware;
s_display = None; (* XXX *)
s_sound = None;
s_disks = disks;

View File

@@ -5,6 +5,7 @@ hypervisor type: vmware
memory: 1073741824 (bytes)
nr vCPUs: 1
CPU features:
firmware: uefi
display:
sound:
disks:

View File

@@ -118,7 +118,7 @@
</Item>
<vmw:Config ovf:required="false" vmw:key="cpuHotAddEnabled" vmw:value="false"/>
<vmw:Config ovf:required="false" vmw:key="cpuHotRemoveEnabled" vmw:value="false"/>
<vmw:Config ovf:required="false" vmw:key="firmware" vmw:value="bios"/>
<vmw:Config ovf:required="false" vmw:key="firmware" vmw:value="efi"/>
<vmw:Config ovf:required="false" vmw:key="virtualICH7MPresent" vmw:value="false"/>
<vmw:Config ovf:required="false" vmw:key="virtualSMCPresent" vmw:value="false"/>
<vmw:Config ovf:required="false" vmw:key="memoryHotAddEnabled" vmw:value="false"/>

View File

@@ -5,6 +5,7 @@ hypervisor type: vmware
memory: 1073741824 (bytes)
nr vCPUs: 1
CPU features:
firmware: bios
display:
sound:
disks:

View File

@@ -5,6 +5,7 @@ hypervisor type: vmware
memory: 1073741824 (bytes)
nr vCPUs: 1
CPU features:
firmware: bios
display:
sound:
disks:

View File

@@ -58,6 +58,7 @@ hypervisor type: test
memory: 1073741824 (bytes)
nr vCPUs: 1
CPU features:
firmware: unknown
display:
sound:
disks:

View File

@@ -27,6 +27,7 @@ type source = {
s_memory : int64;
s_vcpu : int;
s_features : string list;
s_firmware : source_firmware;
s_display : source_display option;
s_sound : source_sound option;
s_disks : source_disk list;
@@ -40,6 +41,10 @@ and source_hypervisor =
| Physical (* used by virt-p2v *)
| UnknownHV (* used by -i disk *)
| OtherHV of string
and source_firmware =
| BIOS
| UEFI
| UnknownFirmware
and source_disk = {
s_disk_id : int;
s_qemu_uri : string;
@@ -84,6 +89,7 @@ hypervisor type: %s
memory: %Ld (bytes)
nr vCPUs: %d
CPU features: %s
firmware: %s
display: %s
sound: %s
disks:
@@ -98,6 +104,7 @@ NICs:
s.s_memory
s.s_vcpu
(String.concat "," s.s_features)
(string_of_source_firmware s.s_firmware)
(match s.s_display with
| None -> ""
| Some display -> string_of_source_display display)
@@ -146,6 +153,11 @@ and source_hypervisor_of_string = function
| "unknown" -> OtherHV "unknown" (* because `UnknownHV is for internal use *)
| s -> OtherHV s
and string_of_source_firmware = function
| BIOS -> "bios"
| UEFI -> "uefi"
| UnknownFirmware -> "unknown"
and string_of_source_disk { s_qemu_uri = qemu_uri; s_format = format;
s_controller = controller } =
sprintf "\t%s%s%s"

View File

@@ -27,6 +27,7 @@ type source = {
s_memory : int64; (** Memory size (bytes). *)
s_vcpu : int; (** Number of CPUs. *)
s_features : string list; (** Machine features. *)
s_firmware : source_firmware; (** Firmware (BIOS or EFI). *)
s_display : source_display option; (** Guest display. *)
s_sound : source_sound option; (** Sound card. *)
s_disks : source_disk list; (** Disk images. *)
@@ -46,6 +47,15 @@ and source_hypervisor =
[libvirt.git/docs/schemas/domaincommon.rng] for the list supported
by libvirt. *)
and source_firmware =
| BIOS (** PC BIOS or default firmware *)
| UEFI (** UEFI *)
| UnknownFirmware (** Unknown: try to autodetect. *)
(** The firmware from the source metadata. Note that
[UnknownFirmware] state corresponds to disks (where we have no
metadata) and temporarily also to libvirt because of
RHBZ#1217444. *)
and source_disk = {
s_disk_id : int; (** A unique ID for each source disk. *)
s_qemu_uri : string; (** QEMU URI of source disk. *)