---
v2v/Makefile.am | 3 ++
v2v/test-v2v-cdrom.expected | 8 +++++
v2v/test-v2v-cdrom.sh | 80 +++++++++++++++++++++++++++++++++++++++++++++
v2v/test-v2v-cdrom.xml | 43 ++++++++++++++++++++++++
4 files changed, 134 insertions(+)
create mode 100644 v2v/test-v2v-cdrom.expected
create mode 100755 v2v/test-v2v-cdrom.sh
create mode 100644 v2v/test-v2v-cdrom.xml
diff --git a/v2v/Makefile.am b/v2v/Makefile.am
index 0dd9d9b..8932057 100644
--- a/v2v/Makefile.am
+++ b/v2v/Makefile.am
@@ -24,6 +24,8 @@ EXTRA_DIST = \
HACKING \
rhel-7-virt-v2v-conversion-server.config \
rhel-7-virt-v2v-conversion-server.ks \
+ test-v2v-cdrom.expected \
+ test-v2v-cdrom.xml \
test-v2v-i-ova.ovf \
test-v2v-i-ova.xml \
test-v2v-i-ova-formats.expected \
@@ -229,6 +231,7 @@ endif
if ENABLE_APPLIANCE
TESTS += \
+ test-v2v-cdrom.sh \
test-v2v-i-ova.sh \
test-v2v-i-disk.sh \
test-v2v-machine-readable.sh \
diff --git a/v2v/test-v2v-cdrom.expected b/v2v/test-v2v-cdrom.expected
new file mode 100644
index 0000000..e18ea6f
--- /dev/null
+++ b/v2v/test-v2v-cdrom.expected
@@ -0,0 +1,8 @@
+ <disk type='file' device='disk'>
+ <driver name='qemu' type='raw' cache='none'/>
+ <target dev='vda' bus='virtio'/>
+ </disk>
+ <disk device='cdrom' type='file'>
+ <driver name='qemu' type='raw'/>
+ <target dev='hdc' bus='ide'/>
+ </disk>
diff --git a/v2v/test-v2v-cdrom.sh b/v2v/test-v2v-cdrom.sh
new file mode 100755
index 0000000..93975c2
--- /dev/null
+++ b/v2v/test-v2v-cdrom.sh
@@ -0,0 +1,80 @@
+#!/bin/bash -
+# libguestfs virt-v2v test script
+# Copyright (C) 2015 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 cdrom dev assignment.
+#
https://bugzilla.redhat.com/show_bug.cgi?id=1238053
+
+unset CDPATH
+export LANG=C
+set -e
+
+if [ -n "$SKIP_TEST_V2V_CDROM_SH" ]; then
+ echo "$0: test skipped because environment variable is set"
+ exit 77
+fi
+
+if [ "$(guestfish get-backend)" = "uml" ]; then
+ echo "$0: test skipped because UML backend does not support network"
+ exit 77
+fi
+
+abs_builddir="$(pwd)"
+libvirt_uri="test://$abs_builddir/test-v2v-cdrom.xml"
+
+f=../tests/guests/windows.img
+if ! test -f $f || ! test -s $f; then
+ echo "$0: test skipped because phony Windows image was not created"
+ exit 77
+fi
+
+f=../tests/guests/blank-disk.img
+if ! test -f $f || ! test -s $f; then
+ echo "$0: test skipped because blank-disk.img was not created"
+ exit 77
+fi
+
+virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools}
+if ! test -r $virt_tools_data_dir/rhsrvany.exe; then
+ echo "$0: test skipped because rhsrvany.exe is not installed"
+ exit 77
+fi
+
+d=test-v2v-cdrom.d
+rm -rf $d
+mkdir $d
+
+$VG virt-v2v --debug-gc \
+ -i libvirt -ic "$libvirt_uri" windows \
+ -o local -os $d --no-copy
+
+# Test the libvirt XML metadata was created.
+test -f $d/windows.xml
+
+# Grab just the <disk>..</disk> output and compare it to what we
+# expect.
https://stackoverflow.com/questions/16587218
+awk '/<disk /{p=1;print;next} p&&/<\/disk>/{p=0;print;next} ;p'
\
+ $d/windows.xml |
+ grep -v '<source file' > $d/disks
+
+if ! diff -u test-v2v-cdrom.expected $d/disks; then
+ echo "$0: unexpected disk assignments"
+ cat $d/disks
+ exit 1
+fi
+
+rm -r $d
diff --git a/v2v/test-v2v-cdrom.xml b/v2v/test-v2v-cdrom.xml
new file mode 100644
index 0000000..b48d88f
--- /dev/null
+++ b/v2v/test-v2v-cdrom.xml
@@ -0,0 +1,43 @@
+<!--
+libguestfs virt-v2v tool
+Copyright (C) 2009-2015 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.
+-->
+<node>
+ <domain type='test'>
+ <name>windows</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='../tests/guests/windows.img'/>
+ <!-- virt-v2v should install virtio drivers and turn this
+ into dev='vda' bus='virtio' -->
+ <target dev='hda' bus='ide'/>
+ </disk>
+ <disk type='file' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source file='../tests/guests/blank-disk.img'/>
+ <!-- virt-v2v should preserve the device name and bus -->
+ <target dev='hdc' bus='ide'/>
+ </disk>
+ </devices>
+ </domain>
+</node>
--
2.3.1