Skip to content

Commit 673700a

Browse files
committed
CLOUDSTACK-1340: Fix raw disk export using vbox internalcommand
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
1 parent 1d31c3e commit 673700a

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

‎tools/appliance/build.sh‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ done
4141
# Get appliance uuids
4242
machine_uuid=`vboxmanage showvminfo $appliance | grep UUID | head -1 | awk '{print $2}'`
4343
hdd_uuid=`vboxmanage showvminfo $appliance | grep vdi | head -1 | awk '{print $8}' | cut -d ')' -f 1`
44+
hdd_path=`vboxmanage list hdds | grep $appliance | grep vdi | cut -c 14-`
4445

4546
# Compact the virtual hdd
4647
vboxmanage modifyhd $hdd_uuid --compact
@@ -49,6 +50,19 @@ vboxmanage modifyhd $hdd_uuid --compact
4950
rm -fr dist
5051
mkdir dist
5152

53+
# Export for Xen
54+
vboxmange internalcommands converttoraw $hdd_path dist/raw.img
55+
vhd-util convert -s 0 -t 1 -i dist/raw.img -o dist/$appliance-$build_date-$branch-xen.vhd
56+
bzip2 dist/$appliance-$build_date-$branch-xen.vhd
57+
echo "$appliance exported for Xen: dist/$appliance-$build_date-$branch-xen.vhd.bz2"
58+
59+
# Export for KVM
60+
vboxmange internalcommands converttoraw $hdd_path dist/raw.img
61+
qemu-img convert -f raw -O qcow2 dist/raw.img dist/$appliance-$build_date-$branch-kvm.qcow2
62+
rm dist/raw.img
63+
bzip2 dist/$appliance-$build_date-$branch-kvm.qcow2
64+
echo "$appliance exported for KVM: dist/$appliance-$build_date-$branch-kvm.qcow2.bz2"
65+
5266
# Export for VMWare vSphere
5367
vboxmanage export $machine_uuid --output dist/$appliance-$build_date-$branch-vmware.ova
5468
echo "$appliance exported for VMWare: dist/$appliance-$build_date-$branch-vmware.ova"
@@ -58,15 +72,3 @@ vboxmanage clonehd $hdd_uuid dist/$appliance-$build_date-$branch-hyperv.vhd --fo
5872
bzip2 dist/$appliance-$build_date-$branch-hyperv.vhd
5973
echo "$appliance exported for HyperV: dist/$appliance-$build_date-$branch-hyperv.vhd.bz2"
6074

61-
# Export for KVM
62-
vboxmanage clonehd $hdd_uuid dist/raw.img --format RAW
63-
qemu-img convert -f raw -O qcow2 dist/raw.img dist/$appliance-$build_date-$branch-kvm.qcow2
64-
bzip2 dist/$appliance-$build_date-$branch-kvm.qcow2
65-
echo "$appliance exported for KVM: dist/$appliance-$build_date-$branch-kvm.qcow2.bz2"
66-
67-
# Export for Xen
68-
# This will be an overwrite convert so, do it at the end
69-
vhd-util convert -s 0 -t 1 -i dist/raw.img -o dist/$appliance-$build_date-$branch-xen.vhd
70-
bzip2 dist/$appliance-$build_date-$branch-xen.vhd
71-
echo "$appliance exported for Xen: dist/$appliance-$build_date-$branch-xen.vhd.bz2"
72-

0 commit comments

Comments
 (0)