On Friday, 8 February 2019 11:44:43 CET Tomáš Golembiovský wrote:
Signed-off-by: Tomáš Golembiovský <tgolembi(a)redhat.com>
---
v2v/Makefile.am | 1 +
v2v/test-v2v-copy-guest-tools.sh | 87 ++++++++++++++++++++++++++++++++
2 files changed, 88 insertions(+)
create mode 100755 v2v/test-v2v-copy-guest-tools.sh
diff --git a/v2v/Makefile.am b/v2v/Makefile.am
index 2312812fb..84667e11d 100644
--- a/v2v/Makefile.am
+++ b/v2v/Makefile.am
@@ -456,6 +456,7 @@ TESTS += \
if HAVE_LIBVIRT
TESTS += \
test-v2v-cdrom.sh \
+ test-v2v-copy-guest-tools.sh \
test-v2v-floppy.sh \
test-v2v-in-place.sh \
test-v2v-mac.sh \
diff --git a/v2v/test-v2v-copy-guest-tools.sh b/v2v/test-v2v-copy-guest-tools.sh
new file mode 100755
index 000000000..e9c1e5b90
--- /dev/null
+++ b/v2v/test-v2v-copy-guest-tools.sh
@@ -0,0 +1,87 @@
+#!/bin/bash -
+# libguestfs virt-v2v test script
+# Copyright (C) 2019 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 copying of guest tools into guest
+
+set -e
+
+$TEST_FUNCTIONS
+slow_test
+skip_if_skipped
+skip_unless_arch x86_64
This arch skip line is not needed, because of...
+guestname="fedora-29"
... this:
skip_unless_virt_builder_guest "$guestname"
+d=test-v2v-copy-guest-tools.d
+disk="$guestname.img"
+xml="$guestname.xml"
+libvirt_uri="test://$abs_builddir/$xml"
+
+rm -f "$disk" "$xml"
+rm -rf $d
+mkdir $d
+
+# Build a guest (using virt-builder).
+virt-builder "$guestname" --quiet -o "$disk" --selinux-relabel
No need for --selinux-relabel, since the guest is not run anyway.
+
+# Create some minimal test metadata.
+cat > "$xml" <<EOF
+<node>
+ <domain type='test'>
+ <name>$guestname</name>
+ <memory>1048576</memory>
+ <os>
+ <type>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <devices>
+ <disk type='file' device='disk'>
+ <driver name='qemu' type='raw'/>
+ <source file='$abs_builddir/$disk'/>
+ <target dev='vda' bus='virtio'/>
+ </disk>
+ </devices>
+ </domain>
+</node>
+EOF
I think using -i disk should be enough, no need to resort to a libvirt
XML.
+
+export VIRTIO_WIN="$d/fake-tools"
+
+rm -rf $d
+mkdir -p $d
+mkdir -p $VIRTIO_WIN/linux/fedora{,27,29}
+# has: fedora, fedora27, fedora29; should use: fedora29
+$VG virt-v2v --debug-gc -v -x \
+ -i libvirt -ic "$libvirt_uri" $guestname \
+ -o local -os $d > $d/log 2>&1
Considering the output is not used, most probably -o null is a better
choice. Adding --no-copy also makes sure to skip that null copying.
+grep '^locating packages in: linux/fedora29, linux/fedora,
linux/fc28$' $d/log
+grep "^cd 'test-v2v-copy-guest-tools.d/fake-tools/linux/fedora29'
&& " $d/log
+
+rm -rf $d
+mkdir -p $d
+mkdir -p $VIRTIO_WIN/linux/fedora{,27}
+# has: fedora, fedora27; should use: fedora
+$VG virt-v2v --debug-gc -v -x \
+ -i libvirt -ic "$libvirt_uri" $guestname \
+ -o local -os $d > $d/log 2>&1
+grep '^locating packages in: linux/fedora29, linux/fedora, linux/fc28$' $d/log
+grep "^cd 'test-v2v-copy-guest-tools.d/fake-tools/linux/fedora' &&
" $d/log
+
+# Finished
+rm -r $d
+rm -f "$disk" "$xml"
--
Pino Toscano