Previously we mapped TargetBIOS to 0 and TargetUEFI to 2, but I
believe that both of these are wrong, and they certainly don't match
the oVirt source code.
This changes the BiosType calculation to use all necessary inputs
(architecture, I440FX|Q35, and TargetBIOS|TargetUEFI) and try to map
these as closely as possible to the BiosType as described in the oVirt
sources.
An exact mapping is not possible, so in cases where we can't find one
we punt on this by returning 0 (use cluster default).
---
tests/test-v2v-o-rhv.ovf.expected | 2 +-
tests/test-v2v-o-vdsm-options.ovf.expected | 2 +-
v2v/create_ovf.ml | 23 +++++++++++++---------
3 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/tests/test-v2v-o-rhv.ovf.expected b/tests/test-v2v-o-rhv.ovf.expected
index c6bd05c562..d7c1a0619f 100644
--- a/tests/test-v2v-o-rhv.ovf.expected
+++ b/tests/test-v2v-o-rhv.ovf.expected
@@ -25,7 +25,7 @@
<IsStateless>False</IsStateless>
<VmType>0</VmType>
<DefaultDisplayType>1</DefaultDisplayType>
- <BiosType>0</BiosType>
+ <BiosType>2</BiosType>
<Section ovf:id='#VM_ID#' ovf:required='false'
xsi:type='ovf:OperatingSystemSection_Type'>
<Info>Microsoft Windows 7 Phony Edition</Info>
<Description>Windows7</Description>
diff --git a/tests/test-v2v-o-vdsm-options.ovf.expected
b/tests/test-v2v-o-vdsm-options.ovf.expected
index f0d418b46b..6a2029afc3 100644
--- a/tests/test-v2v-o-vdsm-options.ovf.expected
+++ b/tests/test-v2v-o-vdsm-options.ovf.expected
@@ -25,7 +25,7 @@
<IsStateless>False</IsStateless>
<VmType>0</VmType>
<DefaultDisplayType>1</DefaultDisplayType>
- <BiosType>0</BiosType>
+ <BiosType>2</BiosType>
<OperatingSystemSection ovf:id='VM' ovf:required='false'
ovirt:id='11'>
<Info>Microsoft Windows 7 Phony Edition</Info>
<Description>Windows7</Description>
diff --git a/v2v/create_ovf.ml b/v2v/create_ovf.ml
index de938f6fc4..481867b43c 100644
--- a/v2v/create_ovf.ml
+++ b/v2v/create_ovf.ml
@@ -462,13 +462,18 @@ let origin_of_source_hypervisor = function
*)
| _ -> None
-(* Set the <BiosType> element. Other possible values:
- * 1 q35 + SeaBIOS
- * 3 q35 + UEFI + Secure Boot
+(* Set the <BiosType> element.
+ *
https://github.com/oVirt/ovirt-engine/blob/master/backend/manager/modules...
*)
-let get_ovirt_biostype = function
- | TargetBIOS -> 0 (* i440fx + SeaBIOS *)
- | TargetUEFI -> 2 (* q35 + UEFI *)
+let get_ovirt_biostype arch machine firmware =
+ if arch <> "x86_64" then
+ 1
+ else
+ match machine, firmware with
+ | I440FX, TargetBIOS -> 1 (* i440fx + SeaBIOS *)
+ | Q35, TargetBIOS -> 2 (* q35 + SeaBIOS *)
+ | Q35, TargetUEFI -> 3 (* q35 + UEFI *)
+ | _ -> 0 (* who knows! try cluster default *)
(* Generate the .meta file associated with each volume. *)
let create_meta_files output_alloc sd_uuid image_uuids overlays =
@@ -523,7 +528,9 @@ let rec create_ovf source targets guestcaps inspect target_firmware
let vmtype = get_vmtype inspect in
let vmtype = match vmtype with `Desktop -> "0" | `Server ->
"1" in
let ostype = get_ostype inspect in
- let biostype = get_ovirt_biostype target_firmware in
+ let biostype =
+ get_ovirt_biostype guestcaps.gcaps_arch guestcaps.gcaps_machine
+ target_firmware in
let ovf : doc =
doc "ovf:Envelope" [
@@ -612,8 +619,6 @@ let rec create_ovf source targets guestcaps inspect target_firmware
source.s_vcpu memsize_mb)]
] in
- (* XXX How to set machine type for Q35? *)
-
List.push_back virtual_hardware_section_items (
e "Item" [] ([
e "rasd:Caption" [] [PCData (sprintf "%d virtual cpu"
source.s_vcpu)];
--
2.28.0.rc2