From d4d06cfe57603043ff5ea60f9d7572b9c59363c5 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Sun, 23 Mar 2014 16:31:09 -0700 Subject: [PATCH 1/3] feat(vm_image_util): Add new Rackspace target with VHD disk images. --- build_library/vm_image_util.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/build_library/vm_image_util.sh b/build_library/vm_image_util.sh index 2b41b36262..acefb6a76f 100644 --- a/build_library/vm_image_util.sh +++ b/build_library/vm_image_util.sh @@ -11,6 +11,7 @@ VALID_IMG_TYPES=( openstack qemu rackspace + rackspace_vhd vagrant vagrant_vmware_fusion virtualbox @@ -118,6 +119,9 @@ IMG_gce_OEM_PACKAGE=oem-gce ## rackspace IMG_rackspace_BOOT_KERNEL=0 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 +260,10 @@ _write_qcow2_disk() { 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() { qemu-img convert -f raw "$1" -O vmdk -o adapter_type=ide "$2" } From 0a8f1780026d06ed6ccb591a660d4deba3415e97 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Sun, 23 Mar 2014 17:15:36 -0700 Subject: [PATCH 2/3] feat(vm_image_util): Support other disk formats with Xen, such as vhd. --- build_library/vm_image_util.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build_library/vm_image_util.sh b/build_library/vm_image_util.sh index acefb6a76f..163fa424b9 100644 --- a/build_library/vm_image_util.sh +++ b/build_library/vm_image_util.sh @@ -67,6 +67,7 @@ IMG_qemu_CONF_FORMAT=qemu ## xen IMG_xen_BOOT_KERNEL=0 +IMG_xen_DISK_FORMAT=vhd IMG_xen_CONF_FORMAT=xl ## virtualbox @@ -457,6 +458,7 @@ _write_xl_conf() { local dst_dir=$(dirname "$VM_DST_IMG") 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 disk_format=$(_get_vm_opt DISK_FORMAT) # Set up the few differences between pygrub and pvgrub echo '# Xen PV config using pygrub' > "${pygrub}" @@ -477,7 +479,7 @@ memory = "${vm_mem}" vcpus = 2 # TODO(marineam): networking... vif = [ ] -disk = [ '${dst_name},raw,xvda' ] +disk = [ '${dst_name},${disk_format},xvda' ] EOF cat > "${VM_README}" < Date: Sun, 23 Mar 2014 20:17:05 -0400 Subject: [PATCH 3/3] fix(build_image): Add auto-enter-chroot call This makes build_image and image_to_vm behave like build_packages, where if you call the script outside of the SDK's chroot it will automatically reexecute itself inside of the chroot. --- build_image | 5 +++++ image_to_vm.sh | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/build_image b/build_image index a9f54ecf99..5ea08da4b2 100755 --- a/build_image +++ b/build_image @@ -12,6 +12,11 @@ SCRIPT_ROOT=$(dirname $(readlink -f "$0")) . "${SCRIPT_ROOT}/common.sh" || exit 1 +# Script must run inside the chroot +restart_in_chroot_if_needed "$@" + +assert_not_root_user + # Developer-visible flags. DEFINE_string board "${DEFAULT_BOARD}" \ "The board to build an image for." diff --git a/image_to_vm.sh b/image_to_vm.sh index 37d25de020..585f02abe4 100755 --- a/image_to_vm.sh +++ b/image_to_vm.sh @@ -8,10 +8,15 @@ # disk image, supporting a variety of different targets. - # Helper scripts should be run from the same location as this script. SCRIPT_ROOT=$(dirname "$(readlink -f "$0")") . "${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}/build_image_util.sh" || exit 1 . "${BUILD_LIBRARY_DIR}/vm_image_util.sh" || exit 1