Skip to contentSkip to conversation

Support for VirtualBox VDI image format.

PATCH In review Juro Bystricky 3 participants 11 messages Jun 3, 2015 – Jun 8, 2015

lore
Share & tools
lore
#0 lore raw

cover Support for VirtualBox VDI image format.

This series of patches implements support for VirtualBox VDI images. Instead of a new VDI only class a new class image-vm.bbclass was created. This class replaces the previously existing image-vmdk class and now supports both VM image formats: VMDK and VDI.

Generally, VMDK and VDI treatment is mostly identical. Both images are created by qemu from hdddirect image. However, VDI images need UUID to boot, so qemu has to be built with UUID support.

Both VDI and VMDK images can be built simultaneously, as demonstrated by the recipe core-image-minimal-vms.bb

[YOCTO #7374]

Juro Bystricky (7):
image: Support for VDI
qemu: Add support for UUID
documentation.conf: Document do_vmimg sanity.bbclass: Prevent 'vdi' and 'live' to be built together boot-direct.bbclass: Add support for VDI images
build-appliance-image: do_vmdkimg replaced by do_vmimg
core-image-minimal-vms: new recipe to build images for VM

 meta/classes/boot-directdisk.bbclass               |  4 +--
 meta/classes/image-vm.bbclass                      | 38 ++++++++++++++++++++++
 meta/classes/image-vmdk.bbclass                    | 35 --------------------
 meta/classes/image.bbclass                         |  6 ++--
 meta/classes/image_types.bbclass                   |  5 +--
 meta/classes/sanity.bbclass                        |  5 +++
 meta/conf/documentation.conf                       |  2 +-
 meta/lib/oe/image.py                               |  4 +--
 .../images/build-appliance-image_12.0.1.bb         |  2 +-
 meta/recipes-core/images/core-image-minimal-vms.bb | 12 +++++++
 meta/recipes-devtools/qemu/qemu.inc                |  2 +-
 11 files changed, 68 insertions(+), 47 deletions(-)
 create mode 100644 meta/classes/image-vm.bbclass
 delete mode 100644 meta/classes/image-vmdk.bbclass
 create mode 100644 meta/recipes-core/images/core-image-minimal-vms.bb
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/7 image: Support for VDI

Added support for VirtualBox VDI format. The support was implemented by merging with the already existing VMDK support for VM player by creating a new class image-vm.bbclass. This class replaces the previous VMDK only image-vmdk.class.

---
 meta/classes/image-vm.bbclass    | 38 ++++++++++++++++++++++++++++++++++++++
 meta/classes/image-vmdk.bbclass  | 35 -----------------------------------
 meta/classes/image.bbclass       |  6 +++---
 meta/classes/image_types.bbclass |  5 +++--
 meta/lib/oe/image.py             |  4 ++--
 5 files changed, 46 insertions(+), 42 deletions(-)
 create mode 100644 meta/classes/image-vm.bbclass
 delete mode 100644 meta/classes/image-vmdk.bbclass
meta/classes/image-vm.bbclass new file +38 -0
new file mode 100644
index 0000000..fdfd14f
@@ -0,0 +1,38 @@
+
+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 VM images relies on having a hddimg so ensure we inherit it here.
+inherit boot-directdisk
+
+IMAGE_TYPEDEP_vmdk = "ext3"
+IMAGE_TYPEDEP_vdi = "ext3"
+IMAGE_TYPES_MASKED += "vmdk vdi"
+
+create_vmdk_image () {
+    qemu-img convert -O vmdk ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hdddirect ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.vmdk
+    ln -sf ${IMAGE_NAME}.vmdk ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.vmdk
+}
+
+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
+}
+
+python do_vmimg() {
+    if 'vmdk' in d.getVar('IMAGE_FSTYPES', True):
+        bb.build.exec_func('create_vmdk_image', d)
+    if 'vdi' in d.getVar('IMAGE_FSTYPES', True):
+        bb.build.exec_func('create_vdi_image', d)        
+}
+
+addtask vmimg after do_bootdirectdisk before do_build
+do_vmimg[depends] += "qemu-native:do_populate_sysroot"
+
meta/classes/image-vmdk.bbclass deleted +0 -35
deleted file mode 100644
index 77b7fac..0000000
@@ -1,35 +0,0 @@
-
-#NOISO = "1"
-
-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 VMDK relies on having a live hddimg so ensure we
-# inherit it here.
-#inherit image-live
-inherit boot-directdisk
-
-IMAGE_TYPEDEP_vmdk = "ext3"
-IMAGE_TYPES_MASKED += "vmdk"
-
-create_vmdk_image () {
-	qemu-img convert -O vmdk ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hdddirect ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.vmdk
-	ln -sf ${IMAGE_NAME}.vmdk ${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.vmdk
-}
-
-python do_vmdkimg() {
-        bb.build.exec_func('create_vmdk_image', d)
-}
-
-#addtask vmdkimg after do_bootimg before do_build
-addtask vmdkimg after do_bootdirectdisk before do_build
-
-do_vmdkimg[depends] += "qemu-native:do_populate_sysroot" 
-
meta/classes/image.bbclass +3 -3
index 58b4add..64ae2cb 100644
@@ -130,10 +130,10 @@ 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_vm = '${@bb.utils.contains_any("IMAGE_FSTYPES", ["vmdk", "vdi"], "image-vm", "", d)}'
+inherit ${IMAGE_TYPE_vm}
 
 python () {
     deps = " " + imagetypes_getdepends(d)
meta/classes/image_types.bbclass +3 -2
index 72c7337..d86d108 100644
@@ -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/lib/oe/image.py +2 -2
index 0ce303d..40f6151 100644
@@ -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:
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/7 qemu: Add support for UUID

In reply to Juro Bystricky

Native qemu is used to to create VMDK and VDI images. VDI images need support for UUID, otherwise the resulting image will not boot.

---
 meta/recipes-devtools/qemu/qemu.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/qemu/qemu.inc +1 -1
index 4274b25..ca94fb2 100644
@@ -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)}"
Signature · 1 line
1.9.1
#3 lore raw

PATCH 3/7 documentation.conf: Document do_vmimg

In reply to Juro Bystricky

Changes due to new combined support for both vmdk and vdi files.

---
 meta/conf/documentation.conf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/conf/documentation.conf +1 -1
index 3a918e8..bd34c99 100644
@@ -57,7 +57,7 @@ do_testsdk[doc] = "Installs an SDK and performs runtime tests on the tools insta
 do_uboot_mkimage[doc] = "Creates a uImage file from the kernel for the U-Boot bootloader"
 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_vmimg[doc] = "Creates an image for use with VMware or VirtualBox compatible virtual machine hosts (based on IMAGE_FSTYPES either .vmdk or .vdi)"
 
 # DESCRIPTIONS FOR VARIABLES #
 
Signature · 1 line
1.9.1
#4 lore raw

PATCH 4/7 sanity.bbclass: Prevent 'vdi' and 'live' to be built together

In reply to Juro Bystricky

Same reason and check as for vmdk.

---
 meta/classes/sanity.bbclass | 5 +++++
 1 file changed, 5 insertions(+)
meta/classes/sanity.bbclass +5 -0
index 32e9b82..c0c06e7 100644
@@ -825,6 +825,11 @@ def check_sanity_everybuild(status, d):
     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):
     class SanityStatus(object):
         def __init__(self):
Signature · 1 line
1.9.1
#5 lore raw

PATCH 5/7 boot-direct.bbclass: Add support for VDI images

In reply to Juro Bystricky

Same treatment for both VMDK and VDI images.

---
 meta/classes/boot-directdisk.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/classes/boot-directdisk.bbclass +2 -2
index 44f738b..c576523 100644
@@ -63,7 +63,7 @@ DISK_SIGNATURE ?= "${DISK_SIGNATURE_GENERATED}"
 SYSLINUX_ROOT ?= "root=/dev/sda2"
 SYSLINUX_TIMEOUT ?= "10"
 
-IS_VMDK = '${@bb.utils.contains("IMAGE_FSTYPES", "vmdk", "true", "false", d)}'
+IS_VM = '${@bb.utils.contains_any("IMAGE_FSTYPES", ["vmdk" ,"vdi"], "true", "false", d)}'
 
 boot_direct_populate() {
 	dest=$1
@@ -101,7 +101,7 @@ build_boot_dd() {
 		efi_hddimg_populate $HDDDIR
 	fi
 
-	if [ "${IS_VMDK}" = "true" ]; then
+	if [ "${IS_VM}" = "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" ] ; then
Signature · 1 line
1.9.1
#6 lore raw

PATCH 6/7 build-appliance-image: do_vmdkimg replaced by do_vmimg

In reply to Juro Bystricky

As a consequence of adding VDI image support, do_vmdkimg routine has been replaced by a generic do_vmimg routine.

This also allows to build the build-appliance for VirtualBox, providing IMAGE_FSTYPES is set to "vdi"

---
 meta/recipes-core/images/build-appliance-image_12.0.1.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-core/images/build-appliance-image_12.0.1.bb +1 -1
index 6d48a65..8e71b36 100644
@@ -89,5 +89,5 @@ python do_bundle_files() {
     bb.build.exec_func('create_bundle_files', d)
 }
 
-addtask bundle_files after do_vmdkimg before do_build
+addtask bundle_files after do_vmimg before do_build
 do_bundle_files[nostamp] = "1"
Signature · 1 line
1.9.1
#7 lore raw

PATCH 7/7 core-image-minimal-vms: new recipe to build images for VM

In reply to Juro Bystricky

Simple recipe that builds core-image-minimal in both supported VM formats:
VDI (VirtualBox) and VMDK (VM player)

---
 meta/recipes-core/images/core-image-minimal-vms.bb | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 meta/recipes-core/images/core-image-minimal-vms.bb
meta/recipes-core/images/core-image-minimal-vms.bb new file +12 -0
new file mode 100644
index 0000000..dd2fc0e
@@ -0,0 +1,12 @@
+SUMMARY = "Small VM images just capable of allowing a device to boot."
+
+IMAGE_INSTALL = "packagegroup-core-boot ${ROOTFS_PKGMANAGE_BOOTSTRAP} ${CORE_IMAGE_EXTRA_INSTALL}"
+
+IMAGE_LINGUAS = " "
+
+LICENSE = "MIT"
+
+IMAGE_FSTYPES = "vdi vmdk"
+require core-image-minimal.bb
+
+
Signature · 1 line
1.9.1
#8 lore raw

Re: [PATCH 7/7] core-image-minimal-vms: new recipe to build images for VM

Quoted 3 lines · Juro Bystricky

Simple recipe that builds core-image-minimal in both supported VM formats:
VDI (VirtualBox) and VMDK (VM player)

I'm not convinced we need this in oe-core as it's just a IMAGE_FSTYPES assignment in local.conf for the end user.

Ross

#9 lore raw

Re: [PATCH 7/7] core-image-minimal-vms: new recipe to build images for VM

Quoted 9 lines · Ross
Quoted 3 lines · Juro Bystricky

Simple recipe that builds core-image-minimal in both supported VM formats:
VDI (VirtualBox) and VMDK (VM player)

I'm not convinced we need this in oe-core as it's just a IMAGE_FSTYPES assignment in local.conf for the end user.

FWIW: I was thinking the same thing.

Bruce

Quoted 9 lines

Ross

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Signature · 2 lines
"Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end"
#10 lore raw

Re: [PATCH 7/7] core-image-minimal-vms: new recipe to build images for VM

In reply to Burton, Ross

Agreed. Not needed per se, just an example recipe. I used it for testing of the new bbclass.

From: Burton, Ross [mailto:[email protected]]
Sent: Monday, June 8, 2015 8:15 AM
To: Bystricky, Juro
Cc: OE-core; Juro Bystricky; Saul Wold
Subject: Re: [PATCH 7/7] core-image-minimal-vms: new recipe to build images for VM

On 3 June 2015 at 19:07, Juro Bystricky <[email protected]<mailto:[email protected]>> wrote:
Simple recipe that builds core-image-minimal in both supported VM formats:
VDI (VirtualBox) and VMDK (VM player)

I'm not convinced we need this in oe-core as it's just a IMAGE_FSTYPES assignment in local.conf for the end user.

Ross