From 99982182b97450b9afb7a65392ac476084a33052 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Thu, 1 Aug 2013 22:18:09 -0400 Subject: [PATCH 1/3] feat(image_to_vm): Switch to qcow2 as default qemu disk format. We only really need raw images for dd'ing to block devices and this format has been requested for some cases so lets just use it! --- build_library/vm_image_util.sh | 6 ++++++ lib/cros_vm_constants.sh | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/build_library/vm_image_util.sh b/build_library/vm_image_util.sh index 305b182a47..bd6093996d 100644 --- a/build_library/vm_image_util.sh +++ b/build_library/vm_image_util.sh @@ -48,6 +48,7 @@ IMG_DEFAULT_CONF_FORMAT= IMG_DEFAULT_MEM=1024 ## qemu +IMG_qemu_DISK_FORMAT=qcow2 IMG_qemu_CONF_FORMAT=qemu ## xen @@ -131,6 +132,7 @@ _disk_ext() { local disk_format=$(_get_vm_opt DISK_FORMAT) case ${disk_format} in raw) echo bin;; + qcow2) echo img;; *) echo "${disk_format}";; esac } @@ -256,6 +258,10 @@ _write_raw_disk() { mv "$1" "$2" } +_write_qcow2_disk() { + qemu-img convert -f raw "$1" -O qcow2 "$2" +} + _write_vmdk_disk() { qemu-img convert -f raw "$1" -O vmdk "$2" } diff --git a/lib/cros_vm_constants.sh b/lib/cros_vm_constants.sh index 7387a91d51..9012135bfc 100644 --- a/lib/cros_vm_constants.sh +++ b/lib/cros_vm_constants.sh @@ -9,7 +9,7 @@ DEFAULT_MEM="1024" DEFAULT_VMDK="ide.vmdk" DEFAULT_VMX="coreos.vmx" DEFAULT_VBOX_DISK="os.vdi" -DEFAULT_QEMU_IMAGE="coreos_developer_qemu_image.bin" +DEFAULT_QEMU_IMAGE="coreos_developer_qemu_image.img" # Minimum sizes for full size vm images -- needed for update. MIN_VDISK_SIZE_FULL=9216 From c7ba8cd4a45d03c4a184bd48bbdca5715ca33b26 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Thu, 1 Aug 2013 23:32:02 -0400 Subject: [PATCH 2/3] fix(image_to_vm): Replace qemu's config file with a script. The recommended command using the config file was triggering a massive memory leak in qemu because it was adding both the default virtual hardware nic as well as the virtio nic. This could be worked around by adding something like -net none or moving all the -net commands from the file to the command line but eh. Clearly qemu config files are used and tested by nobody else so lets just use a trusty script instead. --- build_library/vm_image_util.sh | 50 ++++++++++++---------------------- 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/build_library/vm_image_util.sh b/build_library/vm_image_util.sh index bd6093996d..174b5dd161 100644 --- a/build_library/vm_image_util.sh +++ b/build_library/vm_image_util.sh @@ -280,52 +280,36 @@ _write_qemu_conf() { local src_name=$(basename "$VM_SRC_IMG") local dst_name=$(basename "$VM_DST_IMG") local dst_dir=$(dirname "$VM_DST_IMG") - local conf_path="${dst_dir}/$(_src_to_dst_name "${src_name}" ".conf")" + local script="${dst_dir}/$(_src_to_dst_name "${src_name}" ".sh")" - # FIXME qemu 1.4/5 doesn't support these options in config files - # Seems like submitting a patch to fix that and documenting this - # format would be a worthy projects... - # name=${VM_NAME} - # uuid=${VM_UUID} - # m=${vm_mem} - # cpu=kvm64 - # smp=2 + cat >"${script}" <"${conf_path}" <"${VM_README}" < Date: Fri, 2 Aug 2013 15:07:12 -0400 Subject: [PATCH 3/3] feat(image_to_vm): Add openstack image, uses oem-ami and qcow2 format. --- build_library/vm_image_util.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build_library/vm_image_util.sh b/build_library/vm_image_util.sh index 174b5dd161..d5512d2063 100644 --- a/build_library/vm_image_util.sh +++ b/build_library/vm_image_util.sh @@ -7,6 +7,7 @@ VALID_IMG_TYPES=( ami + openstack qemu rackspace vagrant @@ -38,7 +39,7 @@ IMG_DEFAULT_HYBRID_MBR=0 IMG_DEFAULT_OEM_PACKAGE= # Name of the target image format. -# May be raw or vmdk (vmware, virtualbox) +# May be raw, qcow2 (qemu), or vmdk (vmware, virtualbox) IMG_DEFAULT_DISK_FORMAT=raw # Name of the target config format, default is no config @@ -73,6 +74,10 @@ IMG_vmware_CONF_FORMAT=vmx IMG_ami_HYBRID_MBR=1 IMG_ami_OEM_PACKAGE=oem-ami +## openstack, supports ec2's metadata format so use oem-ami +IMG_openstack_DISK_FORMAT=qcow2 +IMG_openstack_OEM_PACKAGE=oem-ami + ## rackspace # TODO: package doesn't exist yet #IMG_rackspace_OEM_PACKAGE=oem-rackspace