output_rhv: restrict block status collection to the old RHV output

resolves: rhbz#2034240
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
Laszlo Ersek 2021-12-23 15:29:18 +01:00
parent 8c9ce53762
commit 7ea0c8cf97
15 changed files with 208 additions and 36 deletions

View File

@ -68,5 +68,5 @@ index 7cedfff9..91e7be45 100644
Nbdkit.add_arg cmd "insecure" "true";
if is_ovirt_host then
--
2.31.1
2.19.1.3.g30247aa5d201

View File

@ -22,5 +22,5 @@ index 081c598e..aacedb78 100644
(* Retry filter (if it exists) can be used to get around brief
* interruptions in service. It must be closest to the plugin.
--
2.31.1
2.19.1.3.g30247aa5d201

View File

@ -0,0 +1,166 @@
From 07b12fe99fb9cf0b75fe45d3eaa07b4bbc1bbe89 Mon Sep 17 00:00:00 2001
From: Laszlo Ersek <lersek@redhat.com>
Date: Mon, 20 Dec 2021 14:56:40 +0100
Subject: [PATCH] output_rhv: restrict block status collection to the old RHV
output
Nir reports that, despite the comment we removed in commit a2a4f7a09996,
we generally cannot access the output NBD servers in the finalization
stage. In particular, in the "rhv_upload_finalize" function
[output/output_rhv_upload.ml], the output disks are disconnected before
"create_ovf" is called.
Consequently, the "get_disk_allocated" call in the "create_ovf" ->
"add_disks" -> "get_disk_allocated" chain fails.
Rich suggests that we explicitly restrict the "get_disk_allocated" call
with a new optional boolean parameter to the one output plugin that really
needs it, namely the old RHV one.
Accordingly, revert the VDSM test case to its state at (a2a4f7a09996^).
Cc: Nir Soffer <nsoffer@redhat.com>
Fixes: a2a4f7a09996a5e66d027d0d9692e083eb0a8128
Reported-by: Nir Soffer <nsoffer@redhat.com>
Suggested-by: Richard W.M. Jones <rjones@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2034240
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20211220135640.12436-1-lersek@redhat.com>
Tested-by: Nir Soffer <nsoffer@redhat.com>
[lersek@redhat.com: drop parens around condition in "if"; thanks: Rich]
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
---
lib/create_ovf.ml | 35 +++++++++++++---------
lib/create_ovf.mli | 3 +-
output/output_rhv.ml | 4 +--
tests/test-v2v-o-vdsm-options.ovf.expected | 4 +--
4 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/lib/create_ovf.ml b/lib/create_ovf.ml
index dbac3405..9d06bd23 100644
--- a/lib/create_ovf.ml
+++ b/lib/create_ovf.ml
@@ -531,7 +531,8 @@ let rec create_ovf source inspect
{ output_name; guestcaps; target_firmware; target_nics }
sizes
output_alloc output_format
- sd_uuid image_uuids vol_uuids dir vm_uuid ovf_flavour =
+ sd_uuid image_uuids vol_uuids ?(need_actual_sizes = false) dir
+ vm_uuid ovf_flavour =
assert (List.length sizes = List.length vol_uuids);
let memsize_mb = source.s_memory /^ 1024L /^ 1024L in
@@ -745,7 +746,7 @@ let rec create_ovf source inspect
(* Add disks to the OVF XML. *)
add_disks sizes guestcaps output_alloc output_format
- sd_uuid image_uuids vol_uuids dir ovf_flavour ovf;
+ sd_uuid image_uuids vol_uuids need_actual_sizes dir ovf_flavour ovf;
(* Old virt-v2v ignored removable media. XXX *)
@@ -791,7 +792,7 @@ and get_flavoured_section ovf ovirt_path rhv_path rhv_path_attr = function
(* This modifies the OVF DOM, adding a section for each disk. *)
and add_disks sizes guestcaps output_alloc output_format
- sd_uuid image_uuids vol_uuids dir ovf_flavour ovf =
+ sd_uuid image_uuids vol_uuids need_actual_sizes dir ovf_flavour ovf =
let references =
let nodes = path_to_nodes ovf ["ovf:Envelope"; "References"] in
match nodes with
@@ -839,7 +840,12 @@ and add_disks sizes guestcaps output_alloc output_format
b /^ 1073741824L
in
let size_gb = bytes_to_gb size in
- let actual_size = get_disk_allocated ~dir ~disknr:i in
+ let actual_size =
+ if need_actual_sizes then
+ get_disk_allocated ~dir ~disknr:i
+ else
+ None
+ in
let format_for_rhv =
match output_format with
@@ -891,16 +897,17 @@ and add_disks sizes guestcaps output_alloc output_format
"ovf:disk-type", "System"; (* RHBZ#744538 *)
"ovf:boot", if is_bootable_drive then "True" else "False";
] in
- (* Ovirt-engine considers the "ovf:actual_size" attribute mandatory. If
- * we don't know the actual size, we must create the attribute with
- * empty contents.
- *)
- List.push_back attrs
- ("ovf:actual_size",
- match actual_size with
- | None -> ""
- | Some actual_size -> Int64.to_string (bytes_to_gb actual_size)
- );
+ if need_actual_sizes then
+ (* Ovirt-engine considers the "ovf:actual_size" attribute mandatory.
+ * If we don't know the actual size, we must create the attribute
+ * with empty contents.
+ *)
+ List.push_back attrs
+ ("ovf:actual_size",
+ match actual_size with
+ | None -> ""
+ | Some actual_size -> Int64.to_string (bytes_to_gb actual_size)
+ );
e "Disk" !attrs [] in
append_child disk disk_section;
diff --git a/lib/create_ovf.mli b/lib/create_ovf.mli
index 0d1cc5a9..d6d4e62e 100644
--- a/lib/create_ovf.mli
+++ b/lib/create_ovf.mli
@@ -46,7 +46,8 @@ val ovf_flavour_to_string : ovf_flavour -> string
val create_ovf : Types.source -> Types.inspect ->
Types.target_meta -> int64 list ->
Types.output_allocation -> string -> string -> string list ->
- string list -> string -> string -> ovf_flavour -> DOM.doc
+ string list -> ?need_actual_sizes:bool -> string -> string ->
+ ovf_flavour -> DOM.doc
(** Create the OVF file.
Actually a {!DOM} document is created, not a file. It can be written
diff --git a/output/output_rhv.ml b/output/output_rhv.ml
index b902a7ee..6a67b7aa 100644
--- a/output/output_rhv.ml
+++ b/output/output_rhv.ml
@@ -183,8 +183,8 @@ and rhv_finalize dir source inspect target_meta
(* Create the metadata. *)
let ovf =
Create_ovf.create_ovf source inspect target_meta sizes
- output_alloc output_format esd_uuid image_uuids vol_uuids dir vm_uuid
- Create_ovf.RHVExportStorageDomain in
+ output_alloc output_format esd_uuid image_uuids vol_uuids
+ ~need_actual_sizes:true dir vm_uuid Create_ovf.RHVExportStorageDomain in
(* Write it to the metadata file. *)
let dir = esd_mp // esd_uuid // "master" // "vms" // vm_uuid in
diff --git a/tests/test-v2v-o-vdsm-options.ovf.expected b/tests/test-v2v-o-vdsm-options.ovf.expected
index bd5b5e7d..23ca180f 100644
--- a/tests/test-v2v-o-vdsm-options.ovf.expected
+++ b/tests/test-v2v-o-vdsm-options.ovf.expected
@@ -2,7 +2,7 @@
<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/' xmlns:ovirt='http://www.ovirt.org/ovf' ovf:version='0.9'>
<!-- generated by virt-v2v -->
<References>
- <File ovf:href='VOL' ovf:id='VOL' ovf:description='generated by virt-v2v' ovf:size='#SIZE#'/>
+ <File ovf:href='VOL' ovf:id='VOL' ovf:description='generated by virt-v2v'/>
</References>
<NetworkSection>
<Info>List of networks</Info>
@@ -10,7 +10,7 @@
</NetworkSection>
<DiskSection>
<Info>List of Virtual Disks</Info>
- <Disk ovf:diskId='IMAGE' ovf:size='1' ovf:capacity='536870912' 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='VirtIO' ovf:disk-type='System' ovf:boot='True' ovf:actual_size='1'/>
+ <Disk ovf:diskId='IMAGE' ovf:size='1' ovf:capacity='536870912' 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='VirtIO' ovf:disk-type='System' ovf:boot='True'/>
</DiskSection>
<VirtualSystem ovf:id='VM'>
<Name>windows</Name>
--
2.19.1.3.g30247aa5d201

View File

@ -1,4 +1,4 @@
From 235e3ea926bc1138b481f9200b1880f368cf0f27 Mon Sep 17 00:00:00 2001
From 9b77e7e51f462cbac978adfcdbed18df112438c8 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sat, 18 Dec 2021 13:42:56 +0000
Subject: [PATCH] v2v: Swap over the output and conversion stages
@ -62,5 +62,5 @@ index a2414598..1db0c233 100644
with_open_out (tmpdir // "copy") (fun _ -> ());
--
2.31.1
2.19.1.3.g30247aa5d201

View File

@ -1,4 +1,4 @@
From b57ce6a2cd0dd4941b6d0bc88428487103688ec5 Mon Sep 17 00:00:00 2001
From a96669133e5aa5eb1269cf284f8bd7530a4e836a Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sat, 18 Dec 2021 13:40:08 +0000
Subject: [PATCH] XXX v2v: Remove nbdcopy --request-size=4M flag
@ -57,5 +57,5 @@ index 1db0c233..47e6e937 100644
if not (quiet ()) then List.push_back cmd "--progress";
if output_alloc = Types.Preallocated then List.push_back cmd "--allocated";
--
2.31.1
2.19.1.3.g30247aa5d201

View File

@ -1,4 +1,4 @@
From 1945253e1e51a48585c5d595795caba54751b250 Mon Sep 17 00:00:00 2001
From 5c115d2e7214f1b8bc0c0f19f099bb6e381c6265 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sun, 28 Sep 2014 19:14:43 +0100
Subject: [PATCH] RHEL: v2v: Select correct qemu binary for -o qemu mode
@ -29,5 +29,5 @@ index 0aac1eba..c4265703 100644
let flag = Qemuopts.flag cmd
and arg = Qemuopts.arg cmd
--
2.31.1
2.19.1.3.g30247aa5d201

View File

@ -1,4 +1,4 @@
From 0888b1586f975aa7e1eb3c99f44b2016a4fb01f0 Mon Sep 17 00:00:00 2001
From 79d50860b2b16c8668c7bbd3a26972841ec0517d Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 30 Sep 2014 10:50:27 +0100
Subject: [PATCH] RHEL: v2v: Disable the --qemu-boot / -oo qemu-boot option
@ -108,5 +108,5 @@ index 47e6e937..503dfb55 100644
s_"How to choose root filesystem";
[ L"vddk-config" ], Getopt.String ("filename", set_input_option_compat "vddk-config"),
--
2.31.1
2.19.1.3.g30247aa5d201

View File

@ -1,4 +1,4 @@
From fb4b10147dad17d7d530741884b01841f7e8c47d Mon Sep 17 00:00:00 2001
From 3d3810f4e8fbde3fa21728c718a0d0ec14efe275 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 24 Apr 2015 09:45:41 -0400
Subject: [PATCH] RHEL: Fix list of supported sound cards to match RHEL qemu
@ -30,5 +30,5 @@ index d6861d08..a2fccf29 100644
(* Find the UEFI firmware. *)
let find_uefi_firmware guest_arch =
--
2.31.1
2.19.1.3.g30247aa5d201

View File

@ -1,4 +1,4 @@
From f48329ef521f909ba8f480cd04c03b3b69acbd97 Mon Sep 17 00:00:00 2001
From 68d728c2642f15005811d2878f76f4c31266ff7a Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sun, 30 Aug 2015 03:21:57 -0400
Subject: [PATCH] RHEL: Fixes for libguestfs-winsupport.
@ -100,5 +100,5 @@ index a4cf191d..1ff41f6a 100755
# We also update the Registry several times, for firstboot, and (ONLY
--
2.31.1
2.19.1.3.g30247aa5d201

View File

@ -1,4 +1,4 @@
From 86e3b39167e3dc050c36d4bcc39fc748041f9d2c Mon Sep 17 00:00:00 2001
From 9439bad9c940556c33a241c59e38ff35f0ac0284 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 2 Mar 2017 14:21:37 +0100
Subject: [PATCH] RHEL: v2v: -i disk: force VNC as display (RHBZ#1372671)
@ -22,5 +22,5 @@ index 0d92f256..753938f6 100644
s_sound = None;
s_disks = s_disks;
--
2.31.1
2.19.1.3.g30247aa5d201

View File

@ -1,4 +1,4 @@
From 9377a144e20aba2b8b31d5d0cb169299d50678b2 Mon Sep 17 00:00:00 2001
From 151c1c3c78020c73156d7be66886ca4c92b295ff Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Wed, 8 Mar 2017 11:03:40 +0100
Subject: [PATCH] RHEL: v2v: do not mention SUSE Xen hosts (RHBZ#1430203)
@ -22,5 +22,5 @@ index cd3210bf..e9f336a9 100644
=head1 INPUT FROM XEN
--
2.31.1
2.19.1.3.g30247aa5d201

View File

@ -1,4 +1,4 @@
From 078a21ee965b6b8f092161ab11bf09ecf5ab2788 Mon Sep 17 00:00:00 2001
From 77696ce54071f741a44061a7112fb724e3ab25f4 Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Tue, 26 Mar 2019 09:42:25 +0100
Subject: [PATCH] RHEL: point to KB for supported v2v hypervisors/guests
@ -123,5 +123,5 @@ index 9815f51f..1ffc0f9d 100644
=head2 Guest firmware
--
2.31.1
2.19.1.3.g30247aa5d201

View File

@ -1,4 +1,4 @@
From 6819cc91b463ac9e480b90ce4cd0f5c20e261b1c Mon Sep 17 00:00:00 2001
From 6b1c1c4a3001a5c8a1adaa020968a390dd593c95 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Wed, 30 Jun 2021 11:15:52 +0100
Subject: [PATCH] RHEL: Disable -o glance
@ -215,5 +215,5 @@ index 503dfb55..39fef0fa 100644
| `RHV_Upload -> (module Output_rhv_upload.RHVUpload)
| `RHV -> (module Output_rhv.RHV)
--
2.31.1
2.19.1.3.g30247aa5d201

View File

@ -1,4 +1,4 @@
From c9e36c617bd4e035b261e09637e40b77f3ff4d46 Mon Sep 17 00:00:00 2001
From 31a6a8283c5d7ccfe96f67fabb81a21a02631e93 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Thu, 2 Dec 2021 11:56:05 +0000
Subject: [PATCH] RHEL: Remove the --in-place option
@ -148,5 +148,5 @@ index 39fef0fa..a1143b68 100644
pr "mac-option\n";
pr "bandwidth-option\n";
--
2.31.1
2.19.1.3.g30247aa5d201

View File

@ -15,7 +15,7 @@
Name: virt-v2v
Epoch: 1
Version: 1.45.95
Release: 2%{?dist}
Release: 3%{?dist}
Summary: Convert a virtual machine to run on KVM
License: GPLv2+
@ -53,17 +53,18 @@ ExclusiveArch: x86_64
# Patches.
Patch0001: 0001-input-output-Use-Option.may-for-some-Nbdkit-calls.patch
Patch0002: 0002-input-nbdkit_curl.ml-Fix-typo-in-commented-code.patch
Patch0003: 0003-v2v-Swap-over-the-output-and-conversion-stages.patch
Patch0004: 0004-XXX-v2v-Remove-nbdcopy-request-size-4M-flag.patch
Patch0005: 0005-RHEL-v2v-Select-correct-qemu-binary-for-o-qemu-mode-.patch
Patch0006: 0006-RHEL-v2v-Disable-the-qemu-boot-oo-qemu-boot-option-R.patch
Patch0007: 0007-RHEL-Fix-list-of-supported-sound-cards-to-match-RHEL.patch
Patch0008: 0008-RHEL-Fixes-for-libguestfs-winsupport.patch
Patch0009: 0009-RHEL-v2v-i-disk-force-VNC-as-display-RHBZ-1372671.patch
Patch0010: 0010-RHEL-v2v-do-not-mention-SUSE-Xen-hosts-RHBZ-1430203.patch
Patch0011: 0011-RHEL-point-to-KB-for-supported-v2v-hypervisors-guest.patch
Patch0012: 0012-RHEL-Disable-o-glance.patch
Patch0013: 0013-RHEL-Remove-the-in-place-option.patch
Patch0003: 0003-output_rhv-restrict-block-status-collection-to-the-old-RHV-output.patch
Patch0004: 0004-v2v-Swap-over-the-output-and-conversion-stages.patch
Patch0005: 0005-XXX-v2v-Remove-nbdcopy-request-size-4M-flag.patch
Patch0006: 0006-RHEL-v2v-Select-correct-qemu-binary-for-o-qemu-mode-RHBZ-1147313.patch
Patch0007: 0007-RHEL-v2v-Disable-the-qemu-boot-oo-qemu-boot-option-RHBZ-1147313.patch
Patch0008: 0008-RHEL-Fix-list-of-supported-sound-cards-to-match-RHEL-qemu-RHBZ-1176493.patch
Patch0009: 0009-RHEL-Fixes-for-libguestfs-winsupport.patch
Patch0010: 0010-RHEL-v2v-i-disk-force-VNC-as-display-RHBZ-1372671.patch
Patch0011: 0011-RHEL-v2v-do-not-mention-SUSE-Xen-hosts-RHBZ-1430203.patch
Patch0012: 0012-RHEL-point-to-KB-for-supported-v2v-hypervisors-guests.patch
Patch0013: 0013-RHEL-Disable-o-glance.patch
Patch0014: 0014-RHEL-Remove-the-in-place-option.patch
%endif
%if 0%{patches_touch_autotools}
@ -304,6 +305,11 @@ popd
%changelog
* Thu Dec 23 2021 Laszlo Ersek <lersek@redhat.com> - 1:1.45.95-3
- output_rhv: restrict block status collection to the old RHV output
- Rebase from upstream commit 702a511b7f33 to direct child commit 07b12fe99fb9
resolves: rhbz#2034240
* Sat Dec 18 2021 Richard W.M. Jones <rjones@redhat.com> - 1:1.45.95-2
- Rebase to upstream 1.45.95.
- Change video type to VGA (instead of QXL).