[Libguestfs] [PATCH 3/3] v2v: vdsm: add --vdsm-fixed-ovf option

Tomáš Golembiovský tgolembi at redhat.com
Sun Feb 18 14:26:10 UTC 2018


Add option for -o vdsm that enables output of the modified OVF. oVirt
engine should already be able to consume the OVF, but let's not take any
chances and enable it only by command line argument. It can be made
default later when it receives proper testing.

Signed-off-by: Tomáš Golembiovský <tgolembi at redhat.com>
---
 v2v/cmdline.ml                           |  5 +++++
 v2v/output_vdsm.ml                       |  8 ++++++--
 v2v/output_vdsm.mli                      |  1 +
 v2v/test-v2v-o-vdsm-options.ovf.expected | 26 +++++++++++++-------------
 v2v/test-v2v-o-vdsm-options.sh           |  3 ++-
 v2v/virt-v2v.pod                         |  7 +++++++
 6 files changed, 34 insertions(+), 16 deletions(-)

diff --git a/v2v/cmdline.ml b/v2v/cmdline.ml
index efad080cc..409d5dfab 100644
--- a/v2v/cmdline.ml
+++ b/v2v/cmdline.ml
@@ -75,6 +75,7 @@ let parse_cmdline () =
   let vddk_vimapiver = ref None in
   let vdsm_vm_uuid = ref None in
   let vdsm_ovf_output = ref None in (* default "." *)
+  let vdsm_fixed_ovf = ref false in
 
   let vdsm_compat = ref "0.10" in
   let set_vdsm_compat s = vdsm_compat := s in
@@ -251,6 +252,8 @@ let parse_cmdline () =
                                     s_"Output VM UUID";
     [ L"vdsm-ovf-output" ], Getopt.String ("-", set_string_option_once "--vdsm-ovf-output" vdsm_ovf_output),
                                     s_"Output OVF file";
+    [ L"vdsm-fixed-ovf" ], Getopt.Set vdsm_fixed_ovf,
+                                    s_"Produce OVF that is more conforming to the standard";
     [ L"vmtype" ],   Getopt.String ("-", vmtype_warning),
                                     s_"Ignored for backwards compatibility";
   ] in
@@ -327,6 +330,7 @@ read the man page virt-v2v(1).
   let vdsm_vol_uuids = List.rev !vdsm_vol_uuids in
   let vdsm_vm_uuid = !vdsm_vm_uuid in
   let vdsm_ovf_output = Option.default "." !vdsm_ovf_output in
+  let vdsm_fixed_ovf = !vdsm_fixed_ovf in
 
   (* No arguments and machine-readable mode?  Print out some facts
    * about what this binary supports.
@@ -542,6 +546,7 @@ read the man page virt-v2v(1).
         vm_uuid = vdsm_vm_uuid;
         ovf_output = vdsm_ovf_output;
         compat = vdsm_compat;
+        legacy_ovf = not vdsm_fixed_ovf;
       } in
       Output_vdsm.output_vdsm os vdsm_params output_alloc,
       output_format, output_alloc in
diff --git a/v2v/output_vdsm.ml b/v2v/output_vdsm.ml
index b2188dd8b..9d0568f3e 100644
--- a/v2v/output_vdsm.ml
+++ b/v2v/output_vdsm.ml
@@ -32,6 +32,7 @@ type vdsm_params = {
   vm_uuid : string;
   ovf_output : string;
   compat : string;
+  legacy_ovf : bool;
 }
 
 class output_vdsm os vdsm_params output_alloc =
@@ -39,7 +40,7 @@ object
   inherit output
 
   method as_options =
-    sprintf "-o vdsm -os %s%s%s --vdsm-vm-uuid %s --vdsm-ovf-output %s%s" os
+    sprintf "-o vdsm -os %s%s%s --vdsm-vm-uuid %s --vdsm-ovf-output %s%s%s" os
       (String.concat ""
          (List.map (sprintf " --vdsm-image-uuid %s") vdsm_params.image_uuids))
       (String.concat ""
@@ -49,6 +50,9 @@ object
       (match vdsm_params.compat with
        | "0.10" -> "" (* currently this is the default, so don't print it *)
        | s -> sprintf " --vdsm-compat=%s" s)
+      (match vdsm_params.legacy_ovf with
+       | true -> "" (* currently this is the default, so don't print it *)
+       | false -> "--vdsm-fixed-ovf")
 
   method supported_firmware = [ TargetBIOS ]
 
@@ -176,7 +180,7 @@ object
       vdsm_params.image_uuids
       vdsm_params.vol_uuids
       vdsm_params.vm_uuid
-      true in
+      vdsm_params.legacy_ovf in
 
     (* Write it to the metadata file. *)
     let file = vdsm_params.ovf_output // vdsm_params.vm_uuid ^ ".ovf" in
diff --git a/v2v/output_vdsm.mli b/v2v/output_vdsm.mli
index 95a84ee46..24793596d 100644
--- a/v2v/output_vdsm.mli
+++ b/v2v/output_vdsm.mli
@@ -24,6 +24,7 @@ type vdsm_params = {
   vm_uuid : string;                   (* --vdsm-vm-uuid *)
   ovf_output : string;                (* --vdsm-ovf-output *)
   compat : string;                    (* --vdsm-compat=0.10|1.1 *)
+  legacy_ovf : bool;                  (* --vdsm-fixed-ovf *)
 }
 (** Miscellaneous extra command line parameters used by VDSM. *)
 
diff --git a/v2v/test-v2v-o-vdsm-options.ovf.expected b/v2v/test-v2v-o-vdsm-options.ovf.expected
index fafd0dd53..2934a6dd3 100644
--- a/v2v/test-v2v-o-vdsm-options.ovf.expected
+++ b/v2v/test-v2v-o-vdsm-options.ovf.expected
@@ -2,17 +2,17 @@
 <ovf:Envelope xmlns:rasd='http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData' xmlns:vssd='http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ovf='http://schemas.dmtf.org/ovf/envelope/1/' ovf:version='0.9'>
   <!-- generated by virt-v2v 1.38.0 -->
   <References>
-    <File ovf:href='IMAGE/VOL' ovf:id='VOL' ovf:size='536870912' ovf:description='generated by virt-v2v 1.38.0'/>
+    <File ovf:href='VOL' ovf:id='VOL' ovf:size='536870912' ovf:description='generated by virt-v2v 1.38.0'/>
   </References>
-  <Section xsi:type='ovf:NetworkSection_Type'>
+  <NetworkSection>
     <Info>List of networks</Info>
     <Network ovf:name='default'/>
-  </Section>
-  <Section xsi:type='ovf:DiskSection_Type'>
+  </NetworkSection>
+  <DiskSection>
     <Info>List of Virtual Disks</Info>
-    <Disk ovf:diskId='VOL' ovf:size='1' ovf:fileRef='IMAGE/VOL' ovf:parentRef='' ovf:vm_snapshot_id='#UUID#' ovf:volume-format='COW' ovf:volume-type='Sparse' ovf:format='http://en.wikipedia.org/wiki/Byte' ovf:disk-interface='IDE' ovf:disk-type='System' ovf:boot='True' ovf:actual_size='1'/>
-  </Section>
-  <Content ovf:id='out' xsi:type='ovf:VirtualSystem_Type'>
+    <Disk ovf:diskId='IMAGE' ovf:size='1' ovf:fileRef='VOL' ovf:parentRef='' ovf:vm_snapshot_id='#UUID#' ovf:volume-format='COW' ovf:volume-type='Sparse' ovf:format='http://en.wikipedia.org/wiki/Byte' ovf:disk-interface='IDE' ovf:disk-type='System' ovf:boot='True' ovf:actual_size='1'/>
+  </DiskSection>
+  <VirtualSystem ovf:id='out'>
     <Name>windows</Name>
     <TemplateId>00000000-0000-0000-0000-000000000000</TemplateId>
     <TemplateName>Blank</TemplateName>
@@ -25,11 +25,11 @@
     <IsStateless>False</IsStateless>
     <VmType>0</VmType>
     <DefaultDisplayType>1</DefaultDisplayType>
-    <Section ovf:id='VM' ovf:required='false' xsi:type='ovf:OperatingSystemSection_Type'>
+    <OperatingSystemSection ovf:id='VM' ovf:required='false'>
       <Info>Microsoft Windows 7 Phony Edition</Info>
       <Description>Windows7</Description>
-    </Section>
-    <Section xsi:type='ovf:VirtualHardwareSection_Type'>
+    </OperatingSystemSection>
+    <VirtualHardwareSection>
       <Info>1 CPU, 1024 Memory</Info>
       <Item>
         <rasd:Caption>1 virtual cpu</rasd:Caption>
@@ -66,7 +66,7 @@
         <rasd:InstanceId>VOL</rasd:InstanceId>
         <rasd:ResourceType>17</rasd:ResourceType>
         <Type>disk</Type>
-        <rasd:HostResource>IMAGE/VOL</rasd:HostResource>
+        <rasd:HostResource>VOL</rasd:HostResource>
         <rasd:Parent>00000000-0000-0000-0000-000000000000</rasd:Parent>
         <rasd:Template>00000000-0000-0000-0000-000000000000</rasd:Template>
         <rasd:ApplicationList/>
@@ -87,6 +87,6 @@
         <rasd:Name>eth0</rasd:Name>
         <rasd:MACAddress>00:11:22:33:44:55</rasd:MACAddress>
       </Item>
-    </Section>
-  </Content>
+    </VirtualHardwareSection>
+  </VirtualSystem>
 </ovf:Envelope>
diff --git a/v2v/test-v2v-o-vdsm-options.sh b/v2v/test-v2v-o-vdsm-options.sh
index 509a12499..03a30de46 100755
--- a/v2v/test-v2v-o-vdsm-options.sh
+++ b/v2v/test-v2v-o-vdsm-options.sh
@@ -54,7 +54,8 @@ $VG virt-v2v --debug-gc \
     --vdsm-vol-uuid VOL \
     --vdsm-vm-uuid VM \
     --vdsm-ovf-output $d/12345678-1234-1234-1234-123456789abc/master/vms/VM \
-    --vdsm-compat=1.1
+    --vdsm-compat=1.1 \
+    --vdsm-fixed-ovf
 
 # Test the OVF metadata was created.
 test -f $d/12345678-1234-1234-1234-123456789abc/master/vms/VM/VM.ovf
diff --git a/v2v/virt-v2v.pod b/v2v/virt-v2v.pod
index b2face339..9a047d390 100644
--- a/v2v/virt-v2v.pod
+++ b/v2v/virt-v2v.pod
@@ -759,6 +759,13 @@ hex digit can be C<0-9> or C<a-f>), conforming to S<OSF DCE 1.1>.
 
 These options can only be used with I<-o vdsm>.
 
+=item B<--vdsm-fixed-ovf>
+
+OVF generated for RHV contains some deviations from the standard (notably some
+sections are introduced by different elements). This option instruct virt-v2v
+to create more conforming version of the OVF. This may later become the
+default.
+
 =item B<-v>
 
 =item B<--verbose>
-- 
2.16.1




More information about the Libguestfs mailing list