diff --git a/tests/regressions/Makefile.am b/tests/regressions/Makefile.am index d5d63bb50..74f23dd42 100644 --- a/tests/regressions/Makefile.am +++ b/tests/regressions/Makefile.am @@ -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 diff --git a/tests/regressions/rhbz1232192.sh b/tests/regressions/rhbz1232192.sh new file mode 100755 index 000000000..5b4b31ed8 --- /dev/null +++ b/tests/regressions/rhbz1232192.sh @@ -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 diff --git a/tests/regressions/rhbz1232192.xml b/tests/regressions/rhbz1232192.xml new file mode 100644 index 000000000..c31ea2460 --- /dev/null +++ b/tests/regressions/rhbz1232192.xml @@ -0,0 +1,26 @@ + + rhbz1232192 + 1048576 + 2 + + hvm + + + + + + + + + + + + + + + + + + + + diff --git a/v2v/v2v.ml b/v2v/v2v.ml index 14dc69a99..3f49f6839 100644 --- a/v2v/v2v.ml +++ b/v2v/v2v.ml @@ -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 )