Blame SOURCES/0006-v2v-i-ova-Add-a-test-for-.vmdk.gz-compressed-files-R.patch

0d20ef
From a731003f6a9c28c5ccae79976580571bfff3912f Mon Sep 17 00:00:00 2001
0d20ef
From: "Richard W.M. Jones" <rjones@redhat.com>
0d20ef
Date: Sat, 18 Oct 2014 21:57:10 +0100
0d20ef
Subject: [PATCH] v2v: -i ova: Add a test for *.vmdk.gz compressed files
0d20ef
 (RHBZ#1152998).
0d20ef
0d20ef
(cherry picked from commit 9019c4eb0621397163f0092c5c00ebb969d14152)
0d20ef
---
0d20ef
 v2v/Makefile.am                |   3 +
0d20ef
 v2v/test-v2v-i-ova-gz.expected |  15 +++++
0d20ef
 v2v/test-v2v-i-ova-gz.ovf      | 138 +++++++++++++++++++++++++++++++++++++++++
0d20ef
 v2v/test-v2v-i-ova-gz.sh       |  65 +++++++++++++++++++
0d20ef
 4 files changed, 221 insertions(+)
0d20ef
 create mode 100644 v2v/test-v2v-i-ova-gz.expected
0d20ef
 create mode 100644 v2v/test-v2v-i-ova-gz.ovf
0d20ef
 create mode 100755 v2v/test-v2v-i-ova-gz.sh
0d20ef
0d20ef
diff --git a/v2v/Makefile.am b/v2v/Makefile.am
0d20ef
index e9856fd..c311623 100644
0d20ef
--- a/v2v/Makefile.am
0d20ef
+++ b/v2v/Makefile.am
0d20ef
@@ -23,6 +23,8 @@ EXTRA_DIST = \
0d20ef
 	HACKING README.RHEV-M \
0d20ef
 	test-v2v-i-ova.ovf \
0d20ef
 	test-v2v-i-ova.xml \
0d20ef
+	test-v2v-i-ova-gz.expected \
0d20ef
+	test-v2v-i-ova-gz.ovf \
0d20ef
 	test-v2v-i-ova-two-disks.expected \
0d20ef
 	test-v2v-i-ova-two-disks.ovf \
0d20ef
 	test-v2v-i-ova-zip.expected \
0d20ef
@@ -220,6 +222,7 @@ CLEANFILES += stamp-virt-v2v.pod
0d20ef
 TESTS_ENVIRONMENT = $(top_builddir)/run --test
0d20ef
 
0d20ef
 TESTS = \
0d20ef
+	test-v2v-i-ova-gz.sh \
0d20ef
 	test-v2v-i-ova-two-disks.sh \
0d20ef
 	test-v2v-i-ova-zip.sh
0d20ef
 
0d20ef
diff --git a/v2v/test-v2v-i-ova-gz.expected b/v2v/test-v2v-i-ova-gz.expected
0d20ef
new file mode 100644
0d20ef
index 0000000..7631534
0d20ef
--- /dev/null
0d20ef
+++ b/v2v/test-v2v-i-ova-gz.expected
0d20ef
@@ -0,0 +1,15 @@
0d20ef
+Source guest information (--print-source option):
0d20ef
+
0d20ef
+    source name: 2K8R2EESP1_2_Medium
0d20ef
+hypervisor type: vmware
0d20ef
+         memory: 1073741824 (bytes)
0d20ef
+       nr vCPUs: 1
0d20ef
+   CPU features: 
0d20ef
+        display: 
0d20ef
+disks:
0d20ef
+	.vmdk (vmdk) [hda]
0d20ef
+removable media:
0d20ef
+	CD-ROM [hda]
0d20ef
+NICs:
0d20ef
+	Network "Network adapter 1"
0d20ef
+
0d20ef
diff --git a/v2v/test-v2v-i-ova-gz.ovf b/v2v/test-v2v-i-ova-gz.ovf
0d20ef
new file mode 100644
0d20ef
index 0000000..e10ad2b
0d20ef
--- /dev/null
0d20ef
+++ b/v2v/test-v2v-i-ova-gz.ovf
0d20ef
@@ -0,0 +1,138 @@
0d20ef
+
0d20ef
+<Envelope vmw:buildId="build-1750787" 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_ResourceAllocationSettingData" xmlns:vmw="http://www.vmware.com/schema/ovf" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
0d20ef
+  <References>
0d20ef
+    <File ovf:href="disk1.vmdk.gz" ovf:id="file1" ovf:size="7804077568"/>
0d20ef
+  </References>
0d20ef
+  <DiskSection>
0d20ef
+    <Info>Virtual disk information</Info>
0d20ef
+    <Disk ovf:capacity="50" ovf:capacityAllocationUnits="byte * 2^30" ovf:diskId="vmdisk1" ovf:fileRef="file1" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized" ovf:populatedSize="18975752192"/>
0d20ef
+  </DiskSection>
0d20ef
+  <NetworkSection>
0d20ef
+    <Info>The list of logical networks</Info>
0d20ef
+    <Network ovf:name="PG-VLAN60">
0d20ef
+      <Description>The PG-VLAN60 network</Description>
0d20ef
+    </Network>
0d20ef
+  </NetworkSection>
0d20ef
+  <VirtualSystem ovf:id="2K8R2EESP1_2_Medium">
0d20ef
+    <Info>A virtual machine</Info>
0d20ef
+    <Name>2K8R2EESP1_2_Medium</Name>
0d20ef
+    <OperatingSystemSection ovf:id="103" vmw:osType="windows7Server64Guest">
0d20ef
+      <Info>The kind of installed guest operating system</Info>
0d20ef
+      <Description>Microsoft Windows Server 2008 R2 (64-bit)</Description>
0d20ef
+    </OperatingSystemSection>
0d20ef
+    <VirtualHardwareSection>
0d20ef
+      <Info>Virtual hardware requirements</Info>
0d20ef
+      <System>
0d20ef
+        <vssd:ElementName>Virtual Hardware Family</vssd:ElementName>
0d20ef
+        <vssd:InstanceID>0</vssd:InstanceID>
0d20ef
+        <vssd:VirtualSystemIdentifier>2K8R2EESP1_2_Medium</vssd:VirtualSystemIdentifier>
0d20ef
+        <vssd:VirtualSystemType>vmx-10</vssd:VirtualSystemType>
0d20ef
+      </System>
0d20ef
+      <Item>
0d20ef
+        <rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
0d20ef
+        <rasd:Description>Number of Virtual CPUs</rasd:Description>
0d20ef
+        <rasd:ElementName>1 virtual CPU(s)</rasd:ElementName>
0d20ef
+        <rasd:InstanceID>1</rasd:InstanceID>
0d20ef
+        <rasd:ResourceType>3</rasd:ResourceType>
0d20ef
+        <rasd:VirtualQuantity>1</rasd:VirtualQuantity>
0d20ef
+      </Item>
0d20ef
+      <Item>
0d20ef
+        <rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
0d20ef
+        <rasd:Description>Memory Size</rasd:Description>
0d20ef
+        <rasd:ElementName>1024MB of memory</rasd:ElementName>
0d20ef
+        <rasd:InstanceID>2</rasd:InstanceID>
0d20ef
+        <rasd:ResourceType>4</rasd:ResourceType>
0d20ef
+        <rasd:VirtualQuantity>1024</rasd:VirtualQuantity>
0d20ef
+      </Item>
0d20ef
+      <Item>
0d20ef
+        <rasd:Address>0</rasd:Address>
0d20ef
+        <rasd:Description>SCSI Controller</rasd:Description>
0d20ef
+        <rasd:ElementName>SCSI controller 0</rasd:ElementName>
0d20ef
+        <rasd:InstanceID>3</rasd:InstanceID>
0d20ef
+        <rasd:ResourceSubType>lsilogicsas</rasd:ResourceSubType>
0d20ef
+        <rasd:ResourceType>6</rasd:ResourceType>
0d20ef
+        <vmw:Config ovf:required="false" vmw:key="slotInfo.pciSlotNumber" vmw:value="160"/>
0d20ef
+      </Item>
0d20ef
+      <Item>
0d20ef
+        <rasd:Address>1</rasd:Address>
0d20ef
+        <rasd:Description>IDE Controller</rasd:Description>
0d20ef
+        <rasd:ElementName>IDE 1</rasd:ElementName>
0d20ef
+        <rasd:InstanceID>4</rasd:InstanceID>
0d20ef
+        <rasd:ResourceType>5</rasd:ResourceType>
0d20ef
+      </Item>
0d20ef
+      <Item>
0d20ef
+        <rasd:Address>0</rasd:Address>
0d20ef
+        <rasd:Description>IDE Controller</rasd:Description>
0d20ef
+        <rasd:ElementName>IDE 0</rasd:ElementName>
0d20ef
+        <rasd:InstanceID>5</rasd:InstanceID>
0d20ef
+        <rasd:ResourceType>5</rasd:ResourceType>
0d20ef
+      </Item>
0d20ef
+      <Item ovf:required="false">
0d20ef
+        <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
0d20ef
+        <rasd:ElementName>Video card</rasd:ElementName>
0d20ef
+        <rasd:InstanceID>6</rasd:InstanceID>
0d20ef
+        <rasd:ResourceType>24</rasd:ResourceType>
0d20ef
+        <vmw:Config ovf:required="false" vmw:key="enable3DSupport" vmw:value="false"/>
0d20ef
+        <vmw:Config ovf:required="false" vmw:key="use3dRenderer" vmw:value="automatic"/>
0d20ef
+        <vmw:Config ovf:required="false" vmw:key="useAutoDetect" vmw:value="true"/>
0d20ef
+        <vmw:Config ovf:required="false" vmw:key="videoRamSizeInKB" vmw:value="4096"/>
0d20ef
+      </Item>
0d20ef
+      <Item ovf:required="false">
0d20ef
+        <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
0d20ef
+        <rasd:ElementName>VMCI device</rasd:ElementName>
0d20ef
+        <rasd:InstanceID>7</rasd:InstanceID>
0d20ef
+        <rasd:ResourceSubType>vmware.vmci</rasd:ResourceSubType>
0d20ef
+        <rasd:ResourceType>1</rasd:ResourceType>
0d20ef
+        <vmw:Config ovf:required="false" vmw:key="allowUnrestrictedCommunication" vmw:value="false"/>
0d20ef
+        <vmw:Config ovf:required="false" vmw:key="slotInfo.pciSlotNumber" vmw:value="32"/>
0d20ef
+      </Item>
0d20ef
+      <Item ovf:required="false">
0d20ef
+        <rasd:AddressOnParent>0</rasd:AddressOnParent>
0d20ef
+        <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
0d20ef
+        <rasd:ElementName>CD/DVD drive 1</rasd:ElementName>
0d20ef
+        <rasd:InstanceID>8</rasd:InstanceID>
0d20ef
+        <rasd:Parent>4</rasd:Parent>
0d20ef
+        <rasd:ResourceSubType>vmware.cdrom.atapi</rasd:ResourceSubType>
0d20ef
+        <rasd:ResourceType>15</rasd:ResourceType>
0d20ef
+      </Item>
0d20ef
+      <Item>
0d20ef
+        <rasd:AddressOnParent>0</rasd:AddressOnParent>
0d20ef
+        <rasd:ElementName>Hard disk 1</rasd:ElementName>
0d20ef
+        <rasd:HostResource>ovf:/disk/vmdisk1</rasd:HostResource>
0d20ef
+        <rasd:InstanceID>9</rasd:InstanceID>
0d20ef
+        <rasd:Parent>3</rasd:Parent>
0d20ef
+        <rasd:ResourceType>17</rasd:ResourceType>
0d20ef
+        <vmw:Config ovf:required="false" vmw:key="backing.writeThrough" vmw:value="false"/>
0d20ef
+      </Item>
0d20ef
+      <Item>
0d20ef
+        <rasd:AddressOnParent>7</rasd:AddressOnParent>
0d20ef
+        <rasd:AutomaticAllocation>true</rasd:AutomaticAllocation>
0d20ef
+        <rasd:Connection>PG-VLAN60</rasd:Connection>
0d20ef
+        <rasd:Description>E1000 ethernet adapter on "PG-VLAN60"</rasd:Description>
0d20ef
+        <rasd:ElementName>Network adapter 1</rasd:ElementName>
0d20ef
+        <rasd:InstanceID>11</rasd:InstanceID>
0d20ef
+        <rasd:ResourceSubType>E1000</rasd:ResourceSubType>
0d20ef
+        <rasd:ResourceType>10</rasd:ResourceType>
0d20ef
+        <vmw:Config ovf:required="false" vmw:key="slotInfo.pciSlotNumber" vmw:value="33"/>
0d20ef
+        <vmw:Config ovf:required="false" vmw:key="wakeOnLanEnabled" vmw:value="true"/>
0d20ef
+      </Item>
0d20ef
+      <vmw:Config ovf:required="false" vmw:key="cpuHotAddEnabled" vmw:value="false"/>
0d20ef
+      <vmw:Config ovf:required="false" vmw:key="cpuHotRemoveEnabled" vmw:value="false"/>
0d20ef
+      <vmw:Config ovf:required="false" vmw:key="firmware" vmw:value="bios"/>
0d20ef
+      <vmw:Config ovf:required="false" vmw:key="virtualICH7MPresent" vmw:value="false"/>
0d20ef
+      <vmw:Config ovf:required="false" vmw:key="virtualSMCPresent" vmw:value="false"/>
0d20ef
+      <vmw:Config ovf:required="false" vmw:key="memoryHotAddEnabled" vmw:value="false"/>
0d20ef
+      <vmw:Config ovf:required="false" vmw:key="nestedHVEnabled" vmw:value="false"/>
0d20ef
+      <vmw:Config ovf:required="false" vmw:key="powerOpInfo.powerOffType" vmw:value="soft"/>
0d20ef
+      <vmw:Config ovf:required="false" vmw:key="powerOpInfo.resetType" vmw:value="soft"/>
0d20ef
+      <vmw:Config ovf:required="false" vmw:key="powerOpInfo.standbyAction" vmw:value="checkpoint"/>
0d20ef
+      <vmw:Config ovf:required="false" vmw:key="powerOpInfo.suspendType" vmw:value="hard"/>
0d20ef
+      <vmw:Config ovf:required="false" vmw:key="tools.afterPowerOn" vmw:value="true"/>
0d20ef
+      <vmw:Config ovf:required="false" vmw:key="tools.afterResume" vmw:value="true"/>
0d20ef
+      <vmw:Config ovf:required="false" vmw:key="tools.beforeGuestShutdown" vmw:value="true"/>
0d20ef
+      <vmw:Config ovf:required="false" vmw:key="tools.beforeGuestStandby" vmw:value="true"/>
0d20ef
+      <vmw:Config ovf:required="false" vmw:key="tools.syncTimeWithHost" vmw:value="false"/>
0d20ef
+      <vmw:Config ovf:required="false" vmw:key="tools.toolsUpgradePolicy" vmw:value="upgradeAtPowerCycle"/>
0d20ef
+    </VirtualHardwareSection>
0d20ef
+  </VirtualSystem>
0d20ef
+</Envelope>                                 
0d20ef
diff --git a/v2v/test-v2v-i-ova-gz.sh b/v2v/test-v2v-i-ova-gz.sh
0d20ef
new file mode 100755
0d20ef
index 0000000..6c630fb
0d20ef
--- /dev/null
0d20ef
+++ b/v2v/test-v2v-i-ova-gz.sh
0d20ef
@@ -0,0 +1,65 @@
0d20ef
+#!/bin/bash -
0d20ef
+# libguestfs virt-v2v test script
0d20ef
+# Copyright (C) 2014 Red Hat Inc.
0d20ef
+#
0d20ef
+# This program is free software; you can redistribute it and/or modify
0d20ef
+# it under the terms of the GNU General Public License as published by
0d20ef
+# the Free Software Foundation; either version 2 of the License, or
0d20ef
+# (at your option) any later version.
0d20ef
+#
0d20ef
+# This program is distributed in the hope that it will be useful,
0d20ef
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
0d20ef
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0d20ef
+# GNU General Public License for more details.
0d20ef
+#
0d20ef
+# You should have received a copy of the GNU General Public License
0d20ef
+# along with this program; if not, write to the Free Software
0d20ef
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
0d20ef
+
0d20ef
+# Test -i ova option with gzip-compressed disks.
0d20ef
+
0d20ef
+unset CDPATH
0d20ef
+export LANG=C
0d20ef
+set -e
0d20ef
+
0d20ef
+if [ -n "$SKIP_TEST_V2V_I_OVA_GZ_SH" ]; then
0d20ef
+    echo "$0: test skipped because environment variable is set"
0d20ef
+    exit 77
0d20ef
+fi
0d20ef
+
0d20ef
+if [ "$(guestfish get-backend)" = "uml" ]; then
0d20ef
+    echo "$0: test skipped because UML backend does not support network"
0d20ef
+    exit 77
0d20ef
+fi
0d20ef
+
0d20ef
+virt_tools_data_dir=${VIRT_TOOLS_DATA_DIR:-/usr/share/virt-tools}
0d20ef
+if ! test -r $virt_tools_data_dir/rhsrvany.exe; then
0d20ef
+    echo "$0: test skipped because rhsrvany.exe is not installed"
0d20ef
+    exit 77
0d20ef
+fi
0d20ef
+
0d20ef
+d=test-v2v-i-ova-gz.d
0d20ef
+rm -rf $d
0d20ef
+mkdir $d
0d20ef
+
0d20ef
+pushd $d
0d20ef
+
0d20ef
+truncate -s 10k disk1.vmdk
0d20ef
+gzip disk1.vmdk
0d20ef
+sha=`sha1sum disk1.vmdk | awk '{print $1}'`
0d20ef
+echo -e "SHA1(disk1.vmdk)=$sha\r" > disk1.mf
0d20ef
+
0d20ef
+tar -cf test.ova ../test-v2v-i-ova-gz.ovf disk1.vmdk.gz disk1.mf
0d20ef
+popd
0d20ef
+
0d20ef
+# Run virt-v2v but only as far as the --print-source stage, and
0d20ef
+# normalize the output.
0d20ef
+$VG virt-v2v --debug-gc --quiet \
0d20ef
+    -i ova $d/test.ova \
0d20ef
+    --print-source |
0d20ef
+sed 's,[^ \t]*\(\.vmdk\),\1,' > $d/source
0d20ef
+
0d20ef
+# Check the parsed source is what we expect.
0d20ef
+diff -u test-v2v-i-ova-gz.expected $d/source
0d20ef
+
0d20ef
+rm -rf $d
0d20ef
-- 
0d20ef
1.8.3.1
0d20ef