Merge pull request #203 from marineam/vhd

VHD disk images
This commit is contained in:
Michael Marineau 2014-03-23 18:29:50 -07:00
commit 5357390bb6
3 changed files with 22 additions and 2 deletions

View File

@ -12,6 +12,11 @@
SCRIPT_ROOT=$(dirname $(readlink -f "$0")) SCRIPT_ROOT=$(dirname $(readlink -f "$0"))
. "${SCRIPT_ROOT}/common.sh" || exit 1 . "${SCRIPT_ROOT}/common.sh" || exit 1
# Script must run inside the chroot
restart_in_chroot_if_needed "$@"
assert_not_root_user
# Developer-visible flags. # Developer-visible flags.
DEFINE_string board "${DEFAULT_BOARD}" \ DEFINE_string board "${DEFAULT_BOARD}" \
"The board to build an image for." "The board to build an image for."

View File

@ -11,6 +11,7 @@ VALID_IMG_TYPES=(
openstack openstack
qemu qemu
rackspace rackspace
rackspace_vhd
vagrant vagrant
vagrant_vmware_fusion vagrant_vmware_fusion
virtualbox virtualbox
@ -66,6 +67,7 @@ IMG_qemu_CONF_FORMAT=qemu
## xen ## xen
IMG_xen_BOOT_KERNEL=0 IMG_xen_BOOT_KERNEL=0
IMG_xen_DISK_FORMAT=vhd
IMG_xen_CONF_FORMAT=xl IMG_xen_CONF_FORMAT=xl
## virtualbox ## virtualbox
@ -118,6 +120,9 @@ IMG_gce_OEM_PACKAGE=oem-gce
## rackspace ## rackspace
IMG_rackspace_BOOT_KERNEL=0 IMG_rackspace_BOOT_KERNEL=0
IMG_rackspace_OEM_PACKAGE=oem-rackspace IMG_rackspace_OEM_PACKAGE=oem-rackspace
IMG_rackspace_vhd_BOOT_KERNEL=0
IMG_rackspace_vhd_DISK_FORMAT=vhd
IMG_rackspace_vhd_OEM_PACKAGE=oem-rackspace
########################################################### ###########################################################
@ -256,6 +261,10 @@ _write_qcow2_disk() {
qemu-img convert -f raw "$1" -O qcow2 "$2" qemu-img convert -f raw "$1" -O qcow2 "$2"
} }
_write_vhd_disk() {
qemu-img convert -f raw "$1" -O vpc "$2"
}
_write_vmdk_ide_disk() { _write_vmdk_ide_disk() {
qemu-img convert -f raw "$1" -O vmdk -o adapter_type=ide "$2" qemu-img convert -f raw "$1" -O vmdk -o adapter_type=ide "$2"
} }
@ -449,6 +458,7 @@ _write_xl_conf() {
local dst_dir=$(dirname "$VM_DST_IMG") local dst_dir=$(dirname "$VM_DST_IMG")
local pygrub="${dst_dir}/$(_src_to_dst_name "${src_name}" "_pygrub.cfg")" local pygrub="${dst_dir}/$(_src_to_dst_name "${src_name}" "_pygrub.cfg")"
local pvgrub="${dst_dir}/$(_src_to_dst_name "${src_name}" "_pvgrub.cfg")" local pvgrub="${dst_dir}/$(_src_to_dst_name "${src_name}" "_pvgrub.cfg")"
local disk_format=$(_get_vm_opt DISK_FORMAT)
# Set up the few differences between pygrub and pvgrub # Set up the few differences between pygrub and pvgrub
echo '# Xen PV config using pygrub' > "${pygrub}" echo '# Xen PV config using pygrub' > "${pygrub}"
@ -469,7 +479,7 @@ memory = "${vm_mem}"
vcpus = 2 vcpus = 2
# TODO(marineam): networking... # TODO(marineam): networking...
vif = [ ] vif = [ ]
disk = [ '${dst_name},raw,xvda' ] disk = [ '${dst_name},${disk_format},xvda' ]
EOF EOF
cat > "${VM_README}" <<EOF cat > "${VM_README}" <<EOF

View File

@ -8,10 +8,15 @@
# disk image, supporting a variety of different targets. # disk image, supporting a variety of different targets.
# Helper scripts should be run from the same location as this script. # Helper scripts should be run from the same location as this script.
SCRIPT_ROOT=$(dirname "$(readlink -f "$0")") SCRIPT_ROOT=$(dirname "$(readlink -f "$0")")
. "${SCRIPT_ROOT}/common.sh" || exit 1 . "${SCRIPT_ROOT}/common.sh" || exit 1
# Script must run inside the chroot
restart_in_chroot_if_needed "$@"
assert_not_root_user
. "${BUILD_LIBRARY_DIR}/toolchain_util.sh" || exit 1 . "${BUILD_LIBRARY_DIR}/toolchain_util.sh" || exit 1
. "${BUILD_LIBRARY_DIR}/build_image_util.sh" || exit 1 . "${BUILD_LIBRARY_DIR}/build_image_util.sh" || exit 1
. "${BUILD_LIBRARY_DIR}/vm_image_util.sh" || exit 1 . "${BUILD_LIBRARY_DIR}/vm_image_util.sh" || exit 1