---
v2v/Makefile.am | 11 ++++-
v2v/test-v2v-i-ova-as-root.ovf | 95 ++++++++++++++++++++++++++++++++++++++++++
v2v/test-v2v-i-ova-as-root.sh | 65 +++++++++++++++++++++++++++++
3 files changed, 170 insertions(+), 1 deletion(-)
create mode 100644 v2v/test-v2v-i-ova-as-root.ovf
create mode 100755 v2v/test-v2v-i-ova-as-root.sh
diff --git a/v2v/Makefile.am b/v2v/Makefile.am
index f065654..e8ba2f8 100644
--- a/v2v/Makefile.am
+++ b/v2v/Makefile.am
@@ -305,7 +305,8 @@ TESTS += \
test-v2v-on-option.sh \
test-v2v-print-source.sh \
test-v2v-sound.sh \
- $(SLOW_TESTS)
+ $(SLOW_TESTS) \
+ $(ROOT_TESTS)
endif
endif ENABLE_APPLIANCE
@@ -333,6 +334,12 @@ SLOW_TESTS = \
check-slow:
$(MAKE) check TESTS="$(SLOW_TESTS)" SLOW=1
+ROOT_TESTS = \
+ test-v2v-i-ova-as-root.sh
+
+check-root:
+ $(MAKE) check TESTS="$(ROOT_TESTS)"
+
# A selection of real guests that test-v2v-conversion-of.sh will
# try to convert. This is only used by 'make check-slow'.
@@ -376,6 +383,8 @@ EXTRA_DIST += \
test-v2v-floppy.sh \
test-v2v-floppy.xml \
test-v2v-i-disk.sh \
+ test-v2v-i-ova-as-root.ovf \
+ test-v2v-i-ova-as-root.sh \
test-v2v-i-ova-bad-sha1.sh \
test-v2v-i-ova-bad-sha256.sh \
test-v2v-i-ova-checksums.ovf \
diff --git a/v2v/test-v2v-i-ova-as-root.ovf b/v2v/test-v2v-i-ova-as-root.ovf
new file mode 100644
index 0000000..5bb7f6e
--- /dev/null
+++ b/v2v/test-v2v-i-ova-as-root.ovf
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Envelope
xmlns="http://schemas.dmtf.org/ovf/envelope/1"
xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common"
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"
xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Re...
xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_Vi...
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <References>
+ <File ovf:href="disk.vmdk" ovf:id="file1"
ovf:size="4063232" />
+ </References>
+ <DiskSection>
+ <Info>Virtual disk information</Info>
+ <Disk ovf:capacity="512" ovf:capacityAllocationUnits="byte *
2^20" ovf:diskId="vmdisk1" ovf:fileRef="file1" />
+ </DiskSection>
+ <VirtualSystem ovf:id="ova-test">
+ <Info>A virtual machine</Info>
+ <Name>ova-test</Name>
+ <OperatingSystemSection ovf:id="69">
+ <Info>The kind of installed guest operating system</Info>
+ <Description>Microsoft Windows Server 2003 (32-bit)</Description>
+ </OperatingSystemSection>
+ <VirtualHardwareSection>
+ <Info>Virtual hardware requirements</Info>
+ <System>
+ <vssd:ElementName>Virtual Hardware Family</vssd:ElementName>
+ <vssd:InstanceID>0</vssd:InstanceID>
+
<vssd:VirtualSystemIdentifier>ova-test</vssd:VirtualSystemIdentifier>
+ <vssd:VirtualSystemType>vmx-08</vssd:VirtualSystemType>
+ </System>
+ <Item>
+ <rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
+ <rasd:Description>Number of Virtual CPUs</rasd:Description>
+ <rasd:ElementName>2 virtual CPU(s)</rasd:ElementName>
+ <rasd:InstanceID>1</rasd:InstanceID>
+ <rasd:ResourceType>3</rasd:ResourceType>
+ <rasd:VirtualQuantity>2</rasd:VirtualQuantity>
+ </Item>
+ <Item>
+ <rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
+ <rasd:Description>Memory Size</rasd:Description>
+ <rasd:ElementName>4096MB of memory</rasd:ElementName>
+ <rasd:InstanceID>2</rasd:InstanceID>
+ <rasd:ResourceType>4</rasd:ResourceType>
+ <rasd:VirtualQuantity>4096</rasd:VirtualQuantity>
+ </Item>
+ <Item>
+ <rasd:Address>0</rasd:Address>
+ <rasd:Description>SCSI Controller</rasd:Description>
+ <rasd:ElementName>SCSI controller 0</rasd:ElementName>
+ <rasd:InstanceID>3</rasd:InstanceID>
+ <rasd:ResourceSubType>lsilogic</rasd:ResourceSubType>
+ <rasd:ResourceType>6</rasd:ResourceType>
+ </Item>
+ <Item>
+ <rasd:Address>1</rasd:Address>
+ <rasd:Description>IDE Controller</rasd:Description>
+ <rasd:ElementName>IDE 1</rasd:ElementName>
+ <rasd:InstanceID>4</rasd:InstanceID>
+ <rasd:ResourceType>5</rasd:ResourceType>
+ </Item>
+ <Item>
+ <rasd:Address>0</rasd:Address>
+ <rasd:Description>IDE Controller</rasd:Description>
+ <rasd:ElementName>IDE 0</rasd:ElementName>
+ <rasd:InstanceID>5</rasd:InstanceID>
+ <rasd:ResourceType>5</rasd:ResourceType>
+ </Item>
+ <Item ovf:required="false">
+ <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
+ <rasd:ElementName>Video card</rasd:ElementName>
+ <rasd:InstanceID>6</rasd:InstanceID>
+ <rasd:ResourceType>24</rasd:ResourceType>
+ </Item>
+ <Item ovf:required="false">
+ <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
+ <rasd:ElementName>VMCI device</rasd:ElementName>
+ <rasd:InstanceID>7</rasd:InstanceID>
+ <rasd:ResourceSubType>vmware.vmci</rasd:ResourceSubType>
+ <rasd:ResourceType>1</rasd:ResourceType>
+ </Item>
+ <Item ovf:required="false">
+ <rasd:AddressOnParent>1</rasd:AddressOnParent>
+ <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
+ <rasd:ElementName>CD/DVD drive 1</rasd:ElementName>
+ <rasd:InstanceID>8</rasd:InstanceID>
+ <rasd:Parent>4</rasd:Parent>
+
<rasd:ResourceSubType>vmware.cdrom.remotepassthrough</rasd:ResourceSubType>
+ <rasd:ResourceType>15</rasd:ResourceType>
+ </Item>
+ <Item>
+ <rasd:AddressOnParent>0</rasd:AddressOnParent>
+ <rasd:ElementName>Hard disk 1</rasd:ElementName>
+ <rasd:HostResource>ovf:/disk/vmdisk1</rasd:HostResource>
+ <rasd:InstanceID>9</rasd:InstanceID>
+ <rasd:Parent>3</rasd:Parent>
+ <rasd:ResourceType>17</rasd:ResourceType>
+ </Item>
+ </VirtualHardwareSection>
+ </VirtualSystem>
+</Envelope>
diff --git a/v2v/test-v2v-i-ova-as-root.sh b/v2v/test-v2v-i-ova-as-root.sh
new file mode 100755
index 0000000..04d5d37
--- /dev/null
+++ b/v2v/test-v2v-i-ova-as-root.sh
@@ -0,0 +1,65 @@
+#!/bin/bash -
+# libguestfs virt-v2v test script
+# Copyright (C) 2017 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 the case where a OVA file is only readable as
+# root. Because libvirt runs qemu as qemu.qemu in this case, qemu
+# cannot open the OVA file. See:
+#
https://bugzilla.redhat.com/show_bug.cgi?id=1375157#c6
+#
https://bugzilla.redhat.com/show_bug.cgi?id=1430680
+
+set -e
+
+$TEST_FUNCTIONS
+root_test
+skip_if_skipped
+skip_unless_backend libvirt
+skip_unless_phony_guest windows.img
+
+if [ ! -f windows.vmdk -o ! -s windows.vmdk ]; then
+ echo "$0: test skipped because windows.vmdk was not created"
+ exit 77
+fi
+
+export VIRT_TOOLS_DATA_DIR="$top_srcdir/test-data/fake-virt-tools"
+
+d=test-v2v-i-ova-as-root.d
+rm -rf $d
+mkdir $d
+
+pushd $d
+
+# Create the test OVA.
+cp ../test-v2v-i-ova-as-root.ovf test.ovf
+cp ../windows.vmdk disk.vmdk
+
+echo "SHA1(test.ovf)=" `do_sha1 test.ovf` > test.mf
+echo "SHA1(disk.vmdk)=" `do_sha1 disk.vmdk` >> test.mf
+
+tar cf test.ova test.ovf disk.vmdk test.mf
+
+# So it's unreadable by non-root.
+chown root.root test.ova
+chmod 0600 test.ova
+
+# Run virt-v2v.
+$VG virt-v2v --debug-gc --quiet \
+ -i ova test.ova \
+ -o null
+
+popd
+rm -rf $d
--
2.9.3