|
|
e76f14 |
From f5ce839611e01ae4aed4125d24690644bb609ef8 Mon Sep 17 00:00:00 2001
|
|
|
e76f14 |
From: "Richard W.M. Jones" <rjones@redhat.com>
|
|
|
e76f14 |
Date: Wed, 22 Jun 2016 14:48:22 +0100
|
|
|
e76f14 |
Subject: [PATCH] v2v: Add a regression test for floppy assignment
|
|
|
e76f14 |
(RHBZ#1309706).
|
|
|
e76f14 |
|
|
|
e76f14 |
(cherry picked from commit 0421c5afa330b80c17d8dce88abed2cb53f4f5cc)
|
|
|
e76f14 |
---
|
|
|
e76f14 |
v2v/Makefile.am | 3 ++
|
|
|
e76f14 |
v2v/test-v2v-floppy.expected | 8 +++++
|
|
|
e76f14 |
v2v/test-v2v-floppy.sh | 77 ++++++++++++++++++++++++++++++++++++++++++++
|
|
|
e76f14 |
v2v/test-v2v-floppy.xml | 42 ++++++++++++++++++++++++
|
|
|
e76f14 |
4 files changed, 130 insertions(+)
|
|
|
e76f14 |
create mode 100644 v2v/test-v2v-floppy.expected
|
|
|
e76f14 |
create mode 100755 v2v/test-v2v-floppy.sh
|
|
|
e76f14 |
create mode 100644 v2v/test-v2v-floppy.xml
|
|
|
e76f14 |
|
|
|
e76f14 |
diff --git a/v2v/Makefile.am b/v2v/Makefile.am
|
|
|
e76f14 |
index 5bffbfe..a996e5d 100644
|
|
|
e76f14 |
--- a/v2v/Makefile.am
|
|
|
e76f14 |
+++ b/v2v/Makefile.am
|
|
|
e76f14 |
@@ -25,6 +25,8 @@ EXTRA_DIST = \
|
|
|
e76f14 |
HACKING \
|
|
|
e76f14 |
test-v2v-cdrom.expected \
|
|
|
e76f14 |
test-v2v-cdrom.xml \
|
|
|
e76f14 |
+ test-v2v-floppy.expected \
|
|
|
e76f14 |
+ test-v2v-floppy.xml \
|
|
|
e76f14 |
test-v2v-i-ova.ovf \
|
|
|
e76f14 |
test-v2v-i-ova.xml \
|
|
|
e76f14 |
test-v2v-i-ova-formats.expected \
|
|
|
e76f14 |
@@ -303,6 +305,7 @@ endif
|
|
|
e76f14 |
if ENABLE_APPLIANCE
|
|
|
e76f14 |
TESTS += \
|
|
|
e76f14 |
test-v2v-cdrom.sh \
|
|
|
e76f14 |
+ test-v2v-floppy.sh \
|
|
|
e76f14 |
test-v2v-i-ova.sh \
|
|
|
e76f14 |
test-v2v-i-disk.sh \
|
|
|
e76f14 |
test-v2v-machine-readable.sh \
|
|
|
e76f14 |
diff --git a/v2v/test-v2v-floppy.expected b/v2v/test-v2v-floppy.expected
|
|
|
e76f14 |
new file mode 100644
|
|
|
e76f14 |
index 0000000..dd74ed9
|
|
|
e76f14 |
--- /dev/null
|
|
|
e76f14 |
+++ b/v2v/test-v2v-floppy.expected
|
|
|
e76f14 |
@@ -0,0 +1,8 @@
|
|
|
e76f14 |
+ <disk type='file' device='disk'>
|
|
|
e76f14 |
+ <driver name='qemu' type='raw' cache='none'/>
|
|
|
e76f14 |
+ <target dev='vda' bus='virtio'/>
|
|
|
e76f14 |
+ </disk>
|
|
|
e76f14 |
+ <disk device='floppy' type='file'>
|
|
|
e76f14 |
+ <driver name='qemu' type='raw'/>
|
|
|
e76f14 |
+ <target dev='fda'/>
|
|
|
e76f14 |
+ </disk>
|
|
|
e76f14 |
diff --git a/v2v/test-v2v-floppy.sh b/v2v/test-v2v-floppy.sh
|
|
|
e76f14 |
new file mode 100755
|
|
|
e76f14 |
index 0000000..d4ecfba
|
|
|
e76f14 |
--- /dev/null
|
|
|
e76f14 |
+++ b/v2v/test-v2v-floppy.sh
|
|
|
e76f14 |
@@ -0,0 +1,77 @@
|
|
|
e76f14 |
+#!/bin/bash -
|
|
|
e76f14 |
+# libguestfs virt-v2v test script
|
|
|
e76f14 |
+# Copyright (C) 2015-2016 Red Hat Inc.
|
|
|
e76f14 |
+#
|
|
|
e76f14 |
+# This program is free software; you can redistribute it and/or modify
|
|
|
e76f14 |
+# it under the terms of the GNU General Public License as published by
|
|
|
e76f14 |
+# the Free Software Foundation; either version 2 of the License, or
|
|
|
e76f14 |
+# (at your option) any later version.
|
|
|
e76f14 |
+#
|
|
|
e76f14 |
+# This program is distributed in the hope that it will be useful,
|
|
|
e76f14 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
e76f14 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
e76f14 |
+# GNU General Public License for more details.
|
|
|
e76f14 |
+#
|
|
|
e76f14 |
+# You should have received a copy of the GNU General Public License
|
|
|
e76f14 |
+# along with this program; if not, write to the Free Software
|
|
|
e76f14 |
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
e76f14 |
+
|
|
|
e76f14 |
+# Test converting a guest with a floppy disk.
|
|
|
e76f14 |
+# https://bugzilla.redhat.com/show_bug.cgi?id=1309706
|
|
|
e76f14 |
+
|
|
|
e76f14 |
+unset CDPATH
|
|
|
e76f14 |
+export LANG=C
|
|
|
e76f14 |
+set -e
|
|
|
e76f14 |
+
|
|
|
e76f14 |
+if [ -n "$SKIP_TEST_V2V_FLOPPY_SH" ]; then
|
|
|
e76f14 |
+ echo "$0: test skipped because environment variable is set"
|
|
|
e76f14 |
+ exit 77
|
|
|
e76f14 |
+fi
|
|
|
e76f14 |
+
|
|
|
e76f14 |
+if [ "$(guestfish get-backend)" = "uml" ]; then
|
|
|
e76f14 |
+ echo "$0: test skipped because UML backend does not support network"
|
|
|
e76f14 |
+ exit 77
|
|
|
e76f14 |
+fi
|
|
|
e76f14 |
+
|
|
|
e76f14 |
+abs_builddir="$(pwd)"
|
|
|
e76f14 |
+libvirt_uri="test://$abs_builddir/test-v2v-floppy.xml"
|
|
|
e76f14 |
+
|
|
|
e76f14 |
+f=../test-data/phony-guests/windows.img
|
|
|
e76f14 |
+if ! test -f $f || ! test -s $f; then
|
|
|
e76f14 |
+ echo "$0: test skipped because phony Windows image was not created"
|
|
|
e76f14 |
+ exit 77
|
|
|
e76f14 |
+fi
|
|
|
e76f14 |
+
|
|
|
e76f14 |
+f=../test-data/phony-guests/blank-disk.img
|
|
|
e76f14 |
+if ! test -f $f || ! test -s $f; then
|
|
|
e76f14 |
+ echo "$0: test skipped because blank-disk.img was not created"
|
|
|
e76f14 |
+ exit 77
|
|
|
e76f14 |
+fi
|
|
|
e76f14 |
+
|
|
|
e76f14 |
+export VIRT_TOOLS_DATA_DIR="$srcdir/../test-data/fake-virt-tools"
|
|
|
e76f14 |
+export VIRTIO_WIN="$srcdir/../test-data/fake-virtio-win"
|
|
|
e76f14 |
+
|
|
|
e76f14 |
+d=test-v2v-floppy.d
|
|
|
e76f14 |
+rm -rf $d
|
|
|
e76f14 |
+mkdir $d
|
|
|
e76f14 |
+
|
|
|
e76f14 |
+$VG virt-v2v --debug-gc \
|
|
|
e76f14 |
+ -i libvirt -ic "$libvirt_uri" windows \
|
|
|
e76f14 |
+ -o local -os $d --no-copy
|
|
|
e76f14 |
+
|
|
|
e76f14 |
+# Test the libvirt XML metadata was created.
|
|
|
e76f14 |
+test -f $d/windows.xml
|
|
|
e76f14 |
+
|
|
|
e76f14 |
+# Grab just the <disk>..</disk> output and compare it to what we
|
|
|
e76f14 |
+# expect. https://stackoverflow.com/questions/16587218
|
|
|
e76f14 |
+awk '/<disk /{p=1;print;next} p&&/<\/disk>/{p=0;print;next} ;p' \
|
|
|
e76f14 |
+ $d/windows.xml |
|
|
|
e76f14 |
+ grep -v '<source file' > $d/disks
|
|
|
e76f14 |
+
|
|
|
e76f14 |
+if ! diff -u test-v2v-floppy.expected $d/disks; then
|
|
|
e76f14 |
+ echo "$0: unexpected disk assignments"
|
|
|
e76f14 |
+ cat $d/disks
|
|
|
e76f14 |
+ exit 1
|
|
|
e76f14 |
+fi
|
|
|
e76f14 |
+
|
|
|
e76f14 |
+rm -r $d
|
|
|
e76f14 |
diff --git a/v2v/test-v2v-floppy.xml b/v2v/test-v2v-floppy.xml
|
|
|
e76f14 |
new file mode 100644
|
|
|
e76f14 |
index 0000000..41e1bef
|
|
|
e76f14 |
--- /dev/null
|
|
|
e76f14 |
+++ b/v2v/test-v2v-floppy.xml
|
|
|
e76f14 |
@@ -0,0 +1,42 @@
|
|
|
e76f14 |
+
|
|
|
e76f14 |
+libguestfs virt-v2v tool
|
|
|
e76f14 |
+Copyright (C) 2009-2016 Red Hat Inc.
|
|
|
e76f14 |
+
|
|
|
e76f14 |
+This program is free software; you can redistribute it and/or modify
|
|
|
e76f14 |
+it under the terms of the GNU General Public License as published by
|
|
|
e76f14 |
+the Free Software Foundation; either version 2 of the License, or
|
|
|
e76f14 |
+(at your option) any later version.
|
|
|
e76f14 |
+
|
|
|
e76f14 |
+This program is distributed in the hope that it will be useful,
|
|
|
e76f14 |
+but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
e76f14 |
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
e76f14 |
+GNU General Public License for more details.
|
|
|
e76f14 |
+
|
|
|
e76f14 |
+You should have received a copy of the GNU General Public License
|
|
|
e76f14 |
+along with this program; if not, write to the Free Software
|
|
|
e76f14 |
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
e76f14 |
+-->
|
|
|
e76f14 |
+<node>
|
|
|
e76f14 |
+ <domain type='test'>
|
|
|
e76f14 |
+ <name>windows</name>
|
|
|
e76f14 |
+ <memory>1048576</memory>
|
|
|
e76f14 |
+ <os>
|
|
|
e76f14 |
+ <type>hvm</type>
|
|
|
e76f14 |
+ <boot dev='hd'/>
|
|
|
e76f14 |
+ </os>
|
|
|
e76f14 |
+ <devices>
|
|
|
e76f14 |
+ <disk type='file' device='disk'>
|
|
|
e76f14 |
+ <driver name='qemu' type='raw'/>
|
|
|
e76f14 |
+ <source file='../test-data/phony-guests/windows.img'/>
|
|
|
e76f14 |
+
|
|
|
e76f14 |
+ into dev='vda' bus='virtio' -->
|
|
|
e76f14 |
+ <target dev='hda' bus='ide'/>
|
|
|
e76f14 |
+ </disk>
|
|
|
e76f14 |
+ <disk type='file' device='floppy'>
|
|
|
e76f14 |
+ <driver name='qemu' type='raw'/>
|
|
|
e76f14 |
+ <source file='../test-data/phony-guests/blank-disk.img'/>
|
|
|
e76f14 |
+ <target dev='fda' />
|
|
|
e76f14 |
+ </disk>
|
|
|
e76f14 |
+ </devices>
|
|
|
e76f14 |
+ </domain>
|
|
|
e76f14 |
+</node>
|
|
|
e76f14 |
--
|
|
|
aa0300 |
2.7.4
|
|
|
e76f14 |
|