v2v: Don't fail if one of the input disks is blank (RHBZ#1232192).

This also adds a regression test since it is probably easy to break
this in future.

Thanks: Junqin Zhou
This commit is contained in:
Richard W.M. Jones
2015-06-16 12:15:29 +01:00
parent 99dc53bba7
commit 4c73d1d4f1
4 changed files with 91 additions and 1 deletions

View File

@@ -43,6 +43,8 @@ EXTRA_DIST = \
rhbz1054761.sh \
rhbz1091803.sh \
rhbz1175196.sh \
rhbz1232192.sh \
rhbz1232192.xml \
test-noexec-stack.pl
TESTS = \
@@ -68,6 +70,7 @@ TESTS = \
rhbz1055452 \
rhbz1091803.sh \
rhbz1175196.sh \
rhbz1232192.sh \
test-noexec-stack.pl
if HAVE_LIBVIRT

View File

@@ -0,0 +1,56 @@
#!/bin/bash -
# libguestfs
# 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.
# Regression test for virt-v2v handling of blank disks:
# https://bugzilla.redhat.com/show_bug.cgi?id=1232192
set -e
export LANG=C
if [ -n "$SKIP_TEST_RHBZ1232192_SH" ]; then
echo "$0: test skipped because environment variable is set"
exit 77
fi
if ! ../../v2v/virt-v2v --help >/dev/null 2>&1; then
echo "$0: test skipped because virt-v2v was not built"
exit 77
fi
if [ "$(guestfish get-backend)" = "uml" ]; then
echo "$0: test skipped because UML backend does not support network"
exit 77
fi
if [ ! -f ../guests/windows.img ] || [ ! -s ../guests/windows.img ]; then
echo "$0: test skipped because tests/guests/windows.img was not built"
exit 77
fi
if [ ! -f ../guests/blank-disk.img ]; then
echo "$0: test skipped because tests/guests/blank-disk.img was not built"
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
../../v2v/virt-v2v -i libvirtxml rhbz1232192.xml -o null --no-copy

View File

@@ -0,0 +1,26 @@
<domain type='kvm'>
<name>rhbz1232192</name>
<memory>1048576</memory>
<vcpu>2</vcpu>
<os>
<type>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<devices>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='../guests/windows.img'/>
<target dev='hda' bus='ide'/>
</disk>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='../guests/blank-disk.img'/>
<target dev='hdb' bus='ide'/>
</disk>
</devices>
</domain>

View File

@@ -553,8 +553,13 @@ and inspect_source g root_choice =
let rec uefi_ESP_guid = "C12A7328-F81F-11D2-BA4B-00A0C93EC93B"
and is_uefi_ESP dev { G.part_num = partnum } =
g#part_get_gpt_type dev (Int32.to_int partnum) = uefi_ESP_guid
and parttype_is_gpt dev =
try g#part_get_parttype dev = "gpt"
with G.Error msg ->
if verbose () then printf "%s (ignored)\n" msg;
false
and is_uefi_bootable_device dev =
g#part_get_parttype dev = "gpt" && (
parttype_is_gpt dev && (
let partitions = Array.to_list (g#part_list dev) in
List.exists (is_uefi_ESP dev) partitions
)