Add support for VirtualBox VDI images
A message that is not in the archive (sent off-list or not yet received): [email protected]
Thanks Juro,
Quoted 8 lines · Juro Bystricky
Yocto does not support VirtualBox sparse image VDI file format. This could be achieved by the attached patch. The support mimics the VMDK support for VMware. The only subtle difference is that qemu-native has be be built with uuid enabled, as VDI images need a valid UUID in order to be recognized by VirtualBox.
[YOCTO #7374]
This needs to be split up into logical patches. For example one to enable UUID into Qemu, one to add the new image type, another to update the checks.
Ross
OK, no problem.
Saul also suggested merging image-vmdk and image-vdi classes into one class, something like image-vm.bbclass. It is a bit more invasive (will modify the existing vmdk bbclass) , but it should be a cleaner implementation overall.
Juro
From: Burton, Ross [mailto:[email protected]]
Sent: Monday, May 11, 2015 3:55 AM
To: Bystricky, Juro
Cc: OE-core; Saul Wold
Subject: Re: [PATCH] Add support for VirtualBox VDI images
Thanks Juro,
On 8 May 2015 at 23:39, Juro Bystricky <[email protected]<mailto:[email protected]>> wrote:
Yocto does not support VirtualBox sparse image VDI file format.
This could be achieved by the attached patch. The support mimics
the VMDK support for VMware. The only subtle difference is that
qemu-native has be be built with uuid enabled, as VDI images
need a valid UUID in order to be recognized by VirtualBox.
[YOCTO #7374]
This needs to be split up into logical patches. For example one to enable UUID into Qemu, one to add the new image type, another to update the checks.
Ross
Quoted 68 lines · Juro Bystricky
Yocto does not support VirtualBox sparse image VDI file format. This could be achieved by the attached patch. The support mimics the VMDK support for VMware. The only subtle difference is that qemu-native has be be built with uuid enabled, as VDI images need a valid UUID in order to be recognized by VirtualBox.
[YOCTO #7374]
Signed-off-by Juro Bystricky <[email protected]>--- meta/classes/boot-directdisk.bbclass | 3 ++- meta/classes/image-vdi.bbclass | 30 ++++++++++++++++++++++++++++++ meta/classes/image.bbclass | 5 ++++- meta/classes/image_types.bbclass | 5 +++-- meta/classes/sanity.bbclass | 4 ++++ meta/conf/documentation.conf | 1 + meta/lib/oe/image.py | 4 ++-- meta/recipes-devtools/qemu/qemu.inc | 2 +- 8 files changed, 47 insertions(+), 7 deletions(-)create mode 100644 meta/classes/image-vdi.bbclass
meta/classes/boot-directdisk.bbclass +2
-1@@ -64,6 +64,7 @@ SYSLINUX_ROOT ?= "root=/dev/sda2" SYSLINUX_TIMEOUT ?= "10" IS_VMDK = '${@bb.utils.contains("IMAGE_FSTYPES", "vmdk", "true", "false", d)}' +IS_VDI = '${@bb.utils.contains("IMAGE_FSTYPES", "vdi", "true", "false", d)}' boot_direct_populate() { dest=$1@@ -101,7 +102,7 @@ build_boot_dd() { efi_hddimg_populate $HDDDIR fi - if [ "${IS_VMDK}" = "true" ]; then + if [ "${IS_VMDK}" = "true" ] || [ "${IS_VDI}" = "true" ]; then if [ "x${AUTO_SYSLINUXMENU}" = "x1" ] ; then install -m 0644 ${STAGING_DIR}/${MACHINE}/usr/share/syslinux/vesamenu.c32 $HDDDIR/${SYSLINUXDIR}/ if [ "x${SYSLINUX_SPLASH}" != "x" ] ; thenmeta/classes/image-vdi.bbclass new file +20
-0@@ -0,0 +1,30 @@ + +SYSLINUX_ROOT ?= "root=/dev/sda2" +SYSLINUX_PROMPT ?= "0" +SYSLINUX_TIMEOUT ?= "10" +SYSLINUX_LABELS = "boot" +LABELS_append = " ${SYSLINUX_LABELS} " + +# need to define the dependency and the ROOTFS for directdisk +do_bootdirectdisk[depends] += "${PN}:do_rootfs" +ROOTFS ?= "${DEPLOY_DIR_IMAGE}/${IMAGE_BASENAME}-${MACHINE}.ext3" + +# creating VDI relies on having a hddimg so ensure we inherit it here. +inherit boot-directdisk + +IMAGE_TYPEDEP_vdi = "ext3" +IMAGE_TYPES_MASKED += "vdi" + +create_vdi_image () { + qemu-img convert -O vdi ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hdddirect ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.vdi + ln -sf ${IMAGE_NAME}.vdi ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.vdi
meta/classes/image-vdi.bbclass line 30
Quoted 10 lines
meta/classes/image-vdi.bbclass new file +10
-0+} + +python do_vdiimg() { + bb.build.exec_func('create_vdi_image', d) +} + +addtask vdiimg after do_bootdirectdisk before do_build + +do_vdiimg[depends] += "qemu-native:do_populate_sysroot" +
Is there any way that we can create a shared class for vmdk and vdi since the difference between the two classes is vmdk -> vdi? Can this be a variable and/or parameter-ized some how?
I know it's a small class, but the code duplication could cause other problems down the line.
Sau!
Quoted 111 lines
meta/classes/image.bbclass +4
-1@@ -127,11 +127,14 @@ def build_live(d): return "image-live" IMAGE_TYPE_live = "${@build_live(d)}" - inherit ${IMAGE_TYPE_live} + IMAGE_TYPE_vmdk = '${@bb.utils.contains("IMAGE_FSTYPES", "vmdk", "image-vmdk", "", d)}' inherit ${IMAGE_TYPE_vmdk} +IMAGE_TYPE_vdi = '${@bb.utils.contains("IMAGE_FSTYPES", "vdi", "image-vdi", "", d)}' +inherit ${IMAGE_TYPE_vdi} + python () { deps = " " + imagetypes_getdepends(d) d.appendVarFlag('do_rootfs', 'depends', deps)meta/classes/image_types.bbclass +3
-2@@ -13,7 +13,7 @@ def imagetypes_getdepends(d): deps = [] ctypes = d.getVar('COMPRESSIONTYPES', True).split() for type in (d.getVar('IMAGE_FSTYPES', True) or "").split(): - if type in ["vmdk", "live", "iso", "hddimg"]: + if type in ["vmdk", "vdi", "live", "iso", "hddimg"]: type = "ext3" basetype = type for ctype in ctypes:@@ -155,6 +155,7 @@ IMAGE_TYPES = " \ tar tar.gz tar.bz2 tar.xz tar.lz4 \ cpio cpio.gz cpio.xz cpio.lzma cpio.lz4 \ vmdk \ + vdi \ elf \ "@@ -181,5 +182,5 @@ DEPLOYABLE_IMAGE_TYPES ?= "hddimg iso" IMAGE_EXTENSION_live = "hddimg iso" # The IMAGE_TYPES_MASKED variable will be used to mask out from the IMAGE_FSTYPES, -# images that will not be built at do_rootfs time: vmdk, hddimg, iso, etc. +# images that will not be built at do_rootfs time: vmdk, vdi, hddimg, iso, etc. IMAGE_TYPES_MASKED ?= ""meta/classes/sanity.bbclass +4
-0@@ -822,6 +822,10 @@ def check_sanity_everybuild(status, d): # Check vmdk and live can't be built together. if 'vmdk' in d.getVar('IMAGE_FSTYPES', True) and 'live' in d.getVar('IMAGE_FSTYPES', True): status.addresult("Error, IMAGE_FSTYPES vmdk and live can't be built together\n") + + # Check vdi and live can't be built together. + if 'vdi' in d.getVar('IMAGE_FSTYPES', True) and 'live' in d.getVar('IMAGE_FSTYPES', True): + status.addresult("Error, IMAGE_FSTYPES vdi and live can't be built together\n") def check_sanity(sanity_data): import subprocessmeta/conf/documentation.conf +1
-0@@ -58,6 +58,7 @@ do_uboot_mkimage[doc] = "Creates a uImage file from the kernel for the U-Boot bo do_unpack[doc] = "Unpacks the source code into a working directory" do_validate_branches[doc] = "Ensures that the source/meta branches are on the locations specified by their SRCREV values for a linux-yocto style kernel" do_vmdkimg[doc] = "Creates a .vmdk image for use with VMware and compatible virtual machine hosts" +do_vdiimg[doc] = "Creates a .vdi image for use with VirtualBox and compatible virtual machine hosts" # DESCRIPTIONS FOR VARIABLES #meta/lib/oe/image.py +2
-2@@ -66,7 +66,7 @@ class ImageDepGraph(object): return graph def _clean_graph(self): - # Live and VMDK images will be processed via inheriting + # Live and VMDK/VDI images will be processed via inheriting # bbclass and does not get processed here. Remove them from the fstypes # graph. Their dependencies are already added, so no worries here. remove_list = (self.d.getVar('IMAGE_TYPES_MASKED', True) or "").split()@@ -76,7 +76,7 @@ class ImageDepGraph(object): def _image_base_type(self, type): ctypes = self.d.getVar('COMPRESSIONTYPES', True).split() - if type in ["vmdk", "live", "iso", "hddimg"]: + if type in ["vmdk", "vdi", "live", "iso", "hddimg"]: type = "ext3" basetype = type for ctype in ctypes:meta/recipes-devtools/qemu/qemu.inc +1
-1@@ -90,7 +90,7 @@ PACKAGECONFIG ??= " \ fdt sdl alsa \ ${@bb.utils.contains('DISTRO_FEATURES', 'xen', 'xen', '', d)} \ " -PACKAGECONFIG_class-native ??= "fdt alsa" +PACKAGECONFIG_class-native ??= "fdt alsa uuid" PACKAGECONFIG_class-nativesdk ??= "fdt sdl" NATIVEDEPS = "" NATIVEDEPS_class-native = "${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'libxext-native', '',d)}"