virt-v2v/0029-tests-Add-test-for-i-disk-nbd-URI.patch
Andrew Lukoshko d443c55aac Update to virt-v2v-2.10.0-17
Patch series regenerated from public sources:
- https://github.com/libguestfs/virt-v2v (branch rhel-10.2)
- https://github.com/libguestfs/libguestfs-common (branch rhel-10.2-virt-v2v)
2026-06-08 13:02:55 +00:00

124 lines
3.5 KiB
Diff

From a4a65048989da029da637a1f6554c391ffe52fcf Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sat, 18 Apr 2026 22:30:27 +0100
Subject: [PATCH] tests: Add test for -i disk nbd:// URI
Updates: commit a153d3e66eb3ce2f08c949f6dde483991aa4bd28
(cherry picked from commit 79d39ec12acfd5c90a2326ef417b948a2154adf4)
---
tests/Makefile.am | 6 ++--
tests/test-i-disk-nbd.sh | 78 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 82 insertions(+), 2 deletions(-)
create mode 100755 tests/test-i-disk-nbd.sh
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 036cd3bb..19a60f73 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -70,8 +70,9 @@ TESTS = \
test-fedora-lvm-on-luks-conversion.sh \
test-fedora-md-conversion.sh \
test-floppy.sh \
- test-i-disk-parallel.sh \
test-i-disk.sh \
+ test-i-disk-nbd.sh \
+ test-i-disk-parallel.sh \
test-i-ova-bad-sha1.sh \
test-i-ova-bad-sha256.sh \
test-i-ova-directory.sh \
@@ -233,8 +234,9 @@ EXTRA_DIST += \
test-fedora-md-conversion.sh \
test-floppy.expected \
test-floppy.sh \
- test-i-disk-parallel.sh \
test-i-disk.sh \
+ test-i-disk-nbd.sh \
+ test-i-disk-parallel.sh \
test-i-ova-as-root.ovf \
test-i-ova-as-root.sh \
test-i-ova-bad-sha1.sh \
diff --git a/tests/test-i-disk-nbd.sh b/tests/test-i-disk-nbd.sh
new file mode 100755
index 00000000..12a23d7f
--- /dev/null
+++ b/tests/test-i-disk-nbd.sh
@@ -0,0 +1,78 @@
+#!/bin/bash -
+# libguestfs virt-v2v test script
+# Copyright (C) 2014 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.
+
+# Test -i disk with nbd URIs.
+
+source ./functions.sh
+set -e
+set -x
+
+skip_if_skipped
+
+b=fedora.img
+f=../test-data/phony-guests/$b
+requires test -f $f
+
+requires xz --version
+
+# Check we have nbdkit and the plugins and filters required.
+requires nbdkit --version
+requires nbdkit file --version
+requires nbdkit nbd --version
+requires nbdkit null --version
+requires nbdkit null --filter=cow --version
+requires nbdkit null --filter=xz --version
+
+# Check --exit-with-parent option will work.
+requires nbdkit --exit-with-parent --version
+
+d=test-i-disk-nbd.d
+rm -rf $d
+cleanup_fn rm -rf $d
+mkdir $d
+
+cp $f $d/$b
+xz $d/$b
+
+# Start nbdkit connected to the compressed file.
+nbdkit -r -f --exit-with-parent \
+ -U $d/sock -P $d/pid \
+ --filter=xz file $d/$b.xz &
+
+# Wait for the pidfile to appear.
+for i in {1..60}; do
+ if test -s "$d/pid"; then
+ break
+ fi
+ sleep 1
+done
+if ! test -s "$d/pid"; then
+ echo "$0: nbdkit: PID file $d/pid was not created"
+ exit 1
+fi
+cleanup_fn kill "$(cat $d/pid)"
+
+$VG virt-v2v --debug-gc \
+ -i disk nbd+unix:///?socket=$d/sock \
+ -o local -os $d
+
+# Test the libvirt XML metadata and a disk was created.
+test -f $d/unknown.xml
+test -f $d/unknown-sda
+
+cat $d/unknown.xml