Fix hang when converting with virt-p2v

resolves: rhbz#2044911
Send nbdinfo debugging information to stderr
resolves: rhbz#2044922
Explicitly require platform-python
resolves: rhbz#2046178
This commit is contained in:
Richard W.M. Jones 2022-01-26 13:08:07 +00:00
parent 211690d47b
commit 04a560e699
3 changed files with 108 additions and 2 deletions

View File

@ -0,0 +1,45 @@
From 2a3b0da09e3a89eb9a6c84fd6015367ba3022e24 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 25 Jan 2022 10:06:37 +0000
Subject: [PATCH] input: libvirt: Share a single connection to the source NBD
server
When using virt-p2v from RHEL 7, it starts a very old qemu-nbd server
(probably 1.5.3) which required the --shared parameter to enable
sharing even in read-only mode. Since it doesn't pass this parameter
only a single connection at a time is allowed, and further connections
will deadlock. Note that later versions of qemu-nbd changed this so
that read-only connections permit sharing automatically.
In modular virt-v2v we now use nbdkit-nbd-plugin to proxy the
connection to virt-p2v / qemu-nbd. When you connect to this multiple
times, as virt-v2v does, it will make multiple connections to the
backend qemu-nbd. This will cause a deadlock.
We can use the nbdkit-nbd-plugin shared=true flag to enable the plugin
to share a single connection to the backend between multiple nbdkit
clients.
Reported-by: Tingting Zheng
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2044911
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 20019b5cadc1434ac09842e2045a7d5635561835)
---
input/input_libvirt.ml | 1 +
1 file changed, 1 insertion(+)
diff --git a/input/input_libvirt.ml b/input/input_libvirt.ml
index 33f61086..42050c15 100644
--- a/input/input_libvirt.ml
+++ b/input/input_libvirt.ml
@@ -76,6 +76,7 @@ and libvirt_servers dir disks =
Nbdkit.add_filter cmd "cow";
Nbdkit.add_arg cmd "hostname" hostname;
Nbdkit.add_arg cmd "port" (string_of_int port);
+ Nbdkit.add_arg cmd "shared" "true";
let _, pid = Nbdkit.run_unix ~socket cmd in
(* --exit-with-parent should ensure nbdkit is cleaned
--
2.31.1

View File

@ -0,0 +1,52 @@
From aef0dcabe2257c234e1acb745f016b61824af014 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 25 Jan 2022 10:39:49 +0000
Subject: [PATCH] v2v: Send nbdinfo debug information to stderr not stdout
When running in verbose mode (virt-v2v -vx) debug messages are
supposed to only be written to stderr. This allows virt-p2v and other
wrappers to separate ordinary progress messages and warnings, from
debugging information.
However when we added nbdinfo output (only printed in verbose mode),
the output was wrongly sent to stdout instead of stderr. You can show
this as follows:
$ virt-v2v -vx -i disk /var/tmp/fedora-35.qcow2 -o null 2>/dev/null
[ 0.0] Setting up the source: -i disk /var/tmp/fedora-35.qcow2
[ 1.0] Opening the source
... some messages elided ...
protocol: newstyle-fixed without TLS <-- debug output to stdout
export="":
export-size: 6442450944 (6G)
content: DOS/MBR boot sector
uri: nbd+unix:///?socket=/tmp/v2v.Xqvaml/in0
... etc ...
This patch sends the nbdinfo debugging output to stderr instead.
Reported-by: Tingting Zheng
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2044922
Fixes: commit 255722cbf39afc0b012e2ac00d16fa6ba2f8c21f
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 68af35d48ca845133ede948d36ee351d171e3de8)
---
v2v/v2v.ml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index 1c74f01f..92546940 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -616,7 +616,7 @@ and nbdcopy output_alloc input_uri output_uri =
*)
and nbdinfo ?(content = false) uri =
let cmd =
- sprintf "nbdinfo%s %s"
+ sprintf "nbdinfo%s %s >&2"
(if content then " --content" else " --no-content") (quote uri) in
ignore (Sys.command cmd)
--
2.31.1

View File

@ -15,7 +15,7 @@
Name: virt-v2v
Epoch: 1
Version: 1.45.97
Release: 2%{?dist}
Release: 3%{?dist}
Summary: Convert a virtual machine to run on KVM
License: GPLv2+
@ -73,6 +73,8 @@ Patch0019: 0019-RHEL-v2v-do-not-mention-SUSE-Xen-hosts-RHBZ-1430203.patch
Patch0020: 0020-RHEL-point-to-KB-for-supported-v2v-hypervisors-guest.patch
Patch0021: 0021-RHEL-Disable-o-glance.patch
Patch0022: 0022-RHEL-Remove-the-in-place-option.patch
Patch0023: 0023-input-libvirt-Share-a-single-connection-to-the-sourc.patch
Patch0024: 0024-v2v-Send-nbdinfo-debug-information-to-stderr-not-std.patch
%endif
%if 0%{patches_touch_autotools}
@ -143,6 +145,7 @@ Requires: edk2-ovmf
Requires: edk2-aarch64
%endif
Requires: platform-python
Requires: libnbd >= 1.8.2-2.el9
Requires: %{_bindir}/qemu-nbd
Requires: %{_bindir}/nbdcopy
@ -313,7 +316,7 @@ popd
%changelog
* Mon Jan 17 2022 Richard W.M. Jones <rjones@redhat.com> - 1:1.45.97-2
* Wed Jan 26 2022 Richard W.M. Jones <rjones@redhat.com> - 1:1.45.97-3
- Rebase to upstream 1.45.97.
resolves: rhbz#2011713
- Add virtio-transitional for older guests when converting to q35
@ -326,6 +329,12 @@ popd
resolves: rhbz#2041850
- Fix virt-v2v hang when given incorrect vpx:// URL
resolves: rhbz#2041886
- Fix hang when converting with virt-p2v
resolves: rhbz#2044911
- Send nbdinfo debugging information to stderr
resolves: rhbz#2044922
- Explicitly require platform-python
resolves: rhbz#2046178
* 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