Print blkhash of converted image in virt-v2v debugging output

resolves: RHEL-85512
This commit is contained in:
Richard W.M. Jones 2025-03-31 13:42:50 +01:00
parent 809d9b96ac
commit 00e965efce
4 changed files with 299 additions and 2 deletions

View File

@ -0,0 +1,128 @@
From d42726148753250e741b030a1aff09310fb9938a Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 2 Dec 2024 13:25:49 +0000
Subject: [PATCH] build: Remove --with-virt-v2v-nbdkit-python-plugin=...
In theory, ./configure --with-virt-v2v-nbdkit-python-plugin=<name>
allowed you to override the default nbdkit-python-plugin name (usually
"python"). However:
(a) nbdkit no longer provides a Python version 2 plugin and hasn't
since nbdkit 1.16 (2019),
(b) we no longer support older RHEL where there were parallel Python
2 & 3 plugins and this was an issue, and
(c) the result wasn't actually used in the code (it used to be, but I
think I replaced it with "python" and forgot about this ./configure
parameter).
(cherry picked from commit 9e25b211a48804b27228e17d8e123b5f1d44df8b)
---
config.sh.in | 1 -
configure.ac | 4 ----
lib/config.ml.in | 1 -
lib/config.mli | 9 ---------
m4/guestfs-v2v.m4 | 28 ----------------------------
tests/test-o-rhv-upload.sh | 2 +-
6 files changed, 1 insertion(+), 44 deletions(-)
delete mode 100644 m4/guestfs-v2v.m4
diff --git a/config.sh.in b/config.sh.in
index be304b39..8f590853 100644
--- a/config.sh.in
+++ b/config.sh.in
@@ -19,5 +19,4 @@
# This shell script contains the results of some configure checks,
# mostly used in other shell scripts.
-export VIRT_V2V_NBDKIT_PYTHON_PLUGIN="@VIRT_V2V_NBDKIT_PYTHON_PLUGIN@"
export PYCODESTYLE="@PYCODESTYLE@"
diff --git a/configure.ac b/configure.ac
index 623c634d..a99bcb75 100644
--- a/configure.ac
+++ b/configure.ac
@@ -97,10 +97,6 @@ dnl Perl, used for running mllibvirt generator, and man pages.
HEADING([Checking for Perl])
m4_include([m4/guestfs-perl.m4])
-dnl virt-v2v.
-HEADING([Checking the virt-v2v dependencies])
-m4_include([m4/guestfs-v2v.m4])
-
dnl Bash completion.
HEADING([Checking for bash completion])
m4_include([m4/guestfs-bash-completion.m4])
diff --git a/lib/config.ml.in b/lib/config.ml.in
index 74606d1b..be3bdfa2 100644
--- a/lib/config.ml.in
+++ b/lib/config.ml.in
@@ -23,4 +23,3 @@ let package_version_full = "@PACKAGE_VERSION_FULL@"
let prefix = "@prefix@"
let datadir = prefix ^ "/share"
let host_cpu = "@host_cpu@"
-let nbdkit_python_plugin = "@VIRT_V2V_NBDKIT_PYTHON_PLUGIN@"
diff --git a/lib/config.mli b/lib/config.mli
index fe71e57c..a02864fa 100644
--- a/lib/config.mli
+++ b/lib/config.mli
@@ -33,12 +33,3 @@ val datadir : string
val host_cpu : string
(** The configure value [@host_cpu@] *)
-
-val nbdkit_python_plugin : string
-(** Return the name of the nbdkit python plugin used by
- [virt-v2v -o rhv-upload].
-
- As above this must also be the Python 3 version of the plugin,
- unless you change it. The configure command to change this is:
-
- [./configure --with-virt-v2v-nbdkit-python-plugin=...] *)
diff --git a/m4/guestfs-v2v.m4 b/m4/guestfs-v2v.m4
deleted file mode 100644
index 787864d3..00000000
--- a/m4/guestfs-v2v.m4
+++ /dev/null
@@ -1,28 +0,0 @@
-# virt-v2v
-# Copyright (C) 2009-2020 Red Hat Inc.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-dnl Virt-v2v.
-
-dnl nbdkit python plugin.
-AC_MSG_CHECKING([for the nbdkit python plugin name])
-AC_ARG_WITH([virt-v2v-nbdkit-python-plugin],
- [AS_HELP_STRING([--with-virt-v2v-nbdkit-python-plugin="python|..."],
- [set nbdkit python plugin name used by virt-v2v @<:@default=python@:>@])],
- [VIRT_V2V_NBDKIT_PYTHON_PLUGIN="$withval"],
- [VIRT_V2V_NBDKIT_PYTHON_PLUGIN=python])
-AC_MSG_RESULT([$VIRT_V2V_NBDKIT_PYTHON_PLUGIN])
-AC_SUBST([VIRT_V2V_NBDKIT_PYTHON_PLUGIN])
diff --git a/tests/test-o-rhv-upload.sh b/tests/test-o-rhv-upload.sh
index 51307f80..c65fff67 100755
--- a/tests/test-o-rhv-upload.sh
+++ b/tests/test-o-rhv-upload.sh
@@ -31,7 +31,7 @@ set -x
skip_if_skipped
requires python3 --version
-requires nbdkit $VIRT_V2V_NBDKIT_PYTHON_PLUGIN --version
+requires nbdkit python --version
requires test -f ../test-data/phony-guests/windows.img
libvirt_uri="test://$abs_top_builddir/test-data/phony-guests/guests.xml"

View File

@ -0,0 +1,86 @@
From 52bbbfed912b723f5a4618571fbab57cd9d459b7 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 2 Dec 2024 13:43:39 +0000
Subject: [PATCH] build: Use nbdcopy and nbdinfo from ./configure
Use the configured binaries, so that (eg) ./configure NBDCOPY=...
will do the right thing.
(cherry picked from commit 5c866e7bb2c7a08a37bb71dea094141802e849e7)
---
input/ssh.ml | 4 ++--
lib/config.ml.in | 2 ++
lib/config.mli | 6 ++++++
v2v/v2v.ml | 8 +++++---
4 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/input/ssh.ml b/input/ssh.ml
index e35a2b5a..3b17cb38 100644
--- a/input/ssh.ml
+++ b/input/ssh.ml
@@ -47,7 +47,7 @@ let start_nbdkit ~server ?port ?user ?password path =
let download_file ~server ?port ?user ?password path output =
let uri = start_nbdkit ~server ?port ?user ?password path in
- let cmd = [ "nbdcopy"; uri; output ] in
+ let cmd = [ Config.nbdcopy; uri; output ] in
if run_command cmd <> 0 then
error (f_"could not copy the VMX file from the remote server, \
see earlier error messages")
@@ -59,5 +59,5 @@ let remote_file_exists ~server ?port ?user ?password path =
(* Testing that we can connect to the nbdkit server is enough to
* prove the remote file exists.
*)
- let cmd = [ "nbdinfo"; "--can"; "connect"; uri ] in
+ let cmd = [ Config.nbdinfo; "--can"; "connect"; uri ] in
run_command cmd = 0
diff --git a/lib/config.ml.in b/lib/config.ml.in
index be3bdfa2..4f1d1e08 100644
--- a/lib/config.ml.in
+++ b/lib/config.ml.in
@@ -23,3 +23,5 @@ let package_version_full = "@PACKAGE_VERSION_FULL@"
let prefix = "@prefix@"
let datadir = prefix ^ "/share"
let host_cpu = "@host_cpu@"
+let nbdcopy = "@NBDCOPY@"
+let nbdinfo = "@NBDINFO@"
diff --git a/lib/config.mli b/lib/config.mli
index a02864fa..9cd249f1 100644
--- a/lib/config.mli
+++ b/lib/config.mli
@@ -33,3 +33,9 @@ val datadir : string
val host_cpu : string
(** The configure value [@host_cpu@] *)
+
+val nbdcopy : string
+(** The location of the nbdcopy program, from configure value [@NBDCOPY@] *)
+
+val nbdinfo : string
+(** The location of the nbdinfo program, from configure value [@NBDINFO@] *)
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index e56462a5..60425768 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -688,7 +688,7 @@ and nbdcopy ?request_size output_alloc input_uri output_uri =
* --target-is-zero which would be a useful optimization.
*)
let cmd = ref [] in
- List.push_back_list cmd [ "nbdcopy"; input_uri; output_uri ];
+ List.push_back_list cmd [ Config.nbdcopy; input_uri; output_uri ];
(match request_size with
| None -> ()
@@ -722,8 +722,10 @@ and nbdcopy ?request_size output_alloc input_uri output_uri =
*)
and nbdinfo ?(content = false) uri =
let cmd =
- sprintf "nbdinfo%s %s ||:"
- (if content then " --content" else " --no-content") (quote uri) in
+ sprintf "%s%s %s ||:"
+ (quote Config.nbdinfo)
+ (if content then " --content" else " --no-content")
+ (quote uri) in
external_command cmd
(* Convert a Unix domain socket path to an NBD URI. *)

View File

@ -0,0 +1,78 @@
From 7d36586c5a299ecf17ef241063988bc1b9ace2bb Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 31 Mar 2025 11:06:09 +0100
Subject: [PATCH] v2v: Use nbdcopy --blkhash in verbose mode
In verbose mode, and if nbdcopy supports it, add the nbdcopy --blkhash
option. This will compute and print a hash of the disk as we are
copying it (more precisely, a hash of the source disk after conversion
changes have been made). This will allow users to detect any
corruption during or after writing the output.
This feature requires nbdcopy >= 1.23.1
It adds some overhead to the copy, but (a) we're almost always copying
over the network which is slow anyway and (b) this is only done in
verbose mode where there's a lot of overhead from the output anyway.
However keep an eye on this overhead.
Note what is printed is a blkhash, not a regular checksum. See:
https://gitlab.com/nirs/blkhash/
Fixes: https://issues.redhat.com/browse/RHEL-85508
Fixes: https://issues.redhat.com/browse/RHEL-85512
Fixes: https://issues.redhat.com/browse/RHEL-85514
(cherry picked from commit cffd129d8fd47554255d52ad611d58a30b6b9951)
---
lib/utils.ml | 8 ++++++++
lib/utils.mli | 3 +++
v2v/v2v.ml | 3 +++
3 files changed, 14 insertions(+)
diff --git a/lib/utils.ml b/lib/utils.ml
index f2da9e80..ecdaeb80 100644
--- a/lib/utils.ml
+++ b/lib/utils.ml
@@ -181,6 +181,14 @@ let error_if_no_ssh_agent () =
is not set). This is required by qemu to do passwordless \
ssh access. See the virt-v2v(1) man page for more information.")
+let nbdcopy_supports_blkhash =
+ let check =
+ lazy (
+ let cmd = sprintf "%s --help | grep -sq -- --blkhash" Config.nbdcopy in
+ 0 = Sys.command cmd
+ ) in
+ fun () -> Lazy.force check
+
(* Create the directory containing inX and outX sockets. *)
let create_v2v_directory () =
let d = Mkdtemp.temp_dir "v2v." in
diff --git a/lib/utils.mli b/lib/utils.mli
index e7ee13d1..6b405353 100644
--- a/lib/utils.mli
+++ b/lib/utils.mli
@@ -68,6 +68,9 @@ val chown_for_libvirt_rhbz_1045069 : string -> unit
val error_if_no_ssh_agent : unit -> unit
+val nbdcopy_supports_blkhash : unit -> bool
+(** Return true if [nbdcopy] supports the [--blkhash] flag. *)
+
val create_v2v_directory : unit -> string
(** Create the directory containing inX and outX sockets. *)
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index 60425768..3436ce14 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -704,6 +704,9 @@ and nbdcopy ?request_size output_alloc input_uri output_uri =
min 64 (target_buffer_size / request_size) in
List.push_back cmd (sprintf "--requests=%d" requests);
+ if verbose () && nbdcopy_supports_blkhash () then
+ List.push_back cmd "--blkhash";
+
List.push_back cmd "--flush";
(*List.push_back cmd "--verbose";*)

View File

@ -8,7 +8,7 @@
Name: virt-v2v
Epoch: 1
Version: 2.7.1
Release: 6%{?dist}
Release: 7%{?dist}
Summary: Convert a virtual machine to run on KVM
License: GPL-2.0-or-later AND LGPL-2.0-or-later
@ -62,6 +62,9 @@ Patch0031: 0031-convert-Use-yum-apt-.-for-package-removals-not-rpm-d.patch
Patch0032: 0032-test-data-phony-fedora-Add-simple-static-bin-sh.patch
Patch0033: 0033-convert-Handle-large-output-from-rpm-ql-command.patch
Patch0034: 0034-Update-common-submodule.patch
Patch0035: 0035-build-Remove-with-virt-v2v-nbdkit-python-plugin.patch
Patch0036: 0036-build-Use-nbdcopy-and-nbdinfo-from-.-configure.patch
Patch0037: 0037-v2v-Use-nbdcopy-blkhash-in-verbose-mode.patch
%if !0%{?rhel}
# libguestfs hasn't been built on i686 for a while since there is no
@ -363,9 +366,11 @@ make -C tests TESTS=test-fedora-luks-on-lvm-conversion.sh check
%changelog
* Thu Mar 13 2025 Richard W.M. Jones <rjones@redhat.com> - 1:2.7.1-6
* Mon Mar 31 2025 Richard W.M. Jones <rjones@redhat.com> - 1:2.7.1-7
- mlcustomize: Remove dnf --verbose option
resolves: RHEL-83289
- Print blkhash of converted image in virt-v2v debugging output
resolves: RHEL-85512
* Tue Feb 25 2025 Richard W.M. Jones <rjones@redhat.com> - 1:2.7.1-5
- Rebase to upstream development version 2.7.1