Skip to contentSkip to conversation

make vm + live images can build together

PATCH In review Robert Yang 2 participants 9 messages Feb 24, 2016 – Mar 2, 2016

lore
Share & tools
lore
#0 lore raw

cover make vm + live images can build together

Hello,

These patches can make vm and live images build together, and also make the images easier to use.

I'd like to combine the following classes if you are fine with it:
* boot-directdisk.bbclass and image-vm.bbclass into image-vm.bbclass. They are used for making vm images.
* bootimg.bbclass and image-live.bbclass into image-live.bbclass. They are used for making live images.
Combine them can make them easier to understand and also make the structure clearer.

// Robert

The following changes since commit 205b446f3fc4a9885179a66a8dab9d81bcc63dca:

uclibc: Do not use immediate expansion operator (2016-02-22 20:42:34 +0000)

are available in the git repository at:

git://git.openembedded.org/openembedded-core-contrib rbt/syslinux
http://cgit.openembedded.org/cgit.cgi/openembedded-core-contrib/log/?h=rbt/syslinux

Robert Yang (4):
image-live/boot-directdisk.bbclass: remove AUTO_SYSLINUXCFG boot-directdisk.bbclass: drop IS_VM chechking syslinux.bbclass: make vm and live can be built together sanity.bbclass: remove conflict checking for image vm and live

 meta/classes/boot-directdisk.bbclass |   21 ++++++++-------------
 meta/classes/bootimg.bbclass         |    1 +
 meta/classes/image-live.bbclass      |   17 ++++++++---------
 meta/classes/image-vm.bbclass        |   15 +++++++--------
 meta/classes/sanity.bbclass          |   12 ------------
 meta/classes/syslinux.bbclass        |   23 ++++++++++++++++++-----
 6 files changed, 42 insertions(+), 47 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/4 image-live/boot-directdisk.bbclass: remove AUTO_SYSLINUXCFG

No one uses it.

---
 meta/classes/boot-directdisk.bbclass |    1 -
 meta/classes/image-live.bbclass      |    1 -
 2 files changed, 2 deletions(-)
meta/classes/boot-directdisk.bbclass +0 -1
index ee8c744..ce637b8 100644
@@ -58,7 +58,6 @@ inherit ${EFI_CLASS}
 
 # Get the build_syslinux_cfg() function from the syslinux class
 
-AUTO_SYSLINUXCFG = "1"
 DISK_SIGNATURE ?= "${DISK_SIGNATURE_GENERATED}"
 SYSLINUX_ROOT ?= "root=/dev/sda2"
 SYSLINUX_TIMEOUT ?= "10"
meta/classes/image-live.bbclass +0 -1
index d2314aa..badf40d 100644
@@ -1,5 +1,4 @@
 
-AUTO_SYSLINUXCFG = "1"
 INITRD_IMAGE ?= "core-image-minimal-initramfs"
 INITRD ?= "${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE}-${MACHINE}.cpio.gz"
 SYSLINUX_ROOT ?= "root=/dev/ram0"
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/4 boot-directdisk.bbclass: drop IS_VM chechking

In reply to Robert Yang

The IS_VM was used for making menus for vmdk, vdi and qcow2, except hddimg, there is no reason to not make menus for hddimg, so drop it.

---
 meta/classes/boot-directdisk.bbclass |   12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
meta/classes/boot-directdisk.bbclass +4 -8
index ce637b8..89007e3 100644
@@ -62,8 +62,6 @@ DISK_SIGNATURE ?= "${DISK_SIGNATURE_GENERATED}"
 SYSLINUX_ROOT ?= "root=/dev/sda2"
 SYSLINUX_TIMEOUT ?= "10"
 
-IS_VM = '${@bb.utils.contains_any("IMAGE_FSTYPES", ["vmdk", "vdi", "qcow2"], "true", "false", d)}'
-
 boot_direct_populate() {
 	dest=$1
 	install -d $dest
@@ -102,12 +100,10 @@ build_boot_dd() {
 		efi_hddimg_populate $HDDDIR
 	fi
 
-	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
-				install -m 0644 ${SYSLINUX_SPLASH} $HDDDIR/${SYSLINUXDIR}/splash.lss
-			fi
+	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
+			install -m 0644 ${SYSLINUX_SPLASH} $HDDDIR/${SYSLINUXDIR}/splash.lss
 		fi
 	fi
 
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 3/4 syslinux.bbclass: make vm and live can be built together

In reply to Robert Yang

* The vm image(hdddirect, vmdk, qcow2, vdi) and live image (hddimg, iso) couldn't be built together because the following vars settings are conflicted:
- SYSLINUX_ROOT (/dev/sda2 vs /dev/ram0)
- LABELS (boot vs boot install)
- INITRD (None vs live install)
- SYSLINUX_CFG (see above)
Introduce new vars (SYSLINUX_ROOT_VM/_LIVE, the samilar to others) to make them can work together, now we can build all of them together:

IMAGE_FSTYPES += "live iso hddimg hdddirect vmdk qcow2 vdi"

* Use SYSLINUX_CFG rather than SYSLINUXCFG to keep align with others SYSLINUX vars.

* The SYSLINUX_TIMEOUT had been set, but it didn't work since AUTO_SYSLINUXMENU wasn't set, this would cause confusions, so also set AUTO_SYSLINUXMENU.

* Move SYSLINUX_PROMPT and SYSLINUX_TIMEOUT to syslinux.bbclass rather than in separate classes since they are the same.

* Set SYSLINUX_TIMEOUT to 50 to have a unique timeout for syslinux.

[YOCTO #9161]

---
 meta/classes/boot-directdisk.bbclass |    8 ++++----
 meta/classes/bootimg.bbclass         |    1 +
 meta/classes/image-live.bbclass      |   16 ++++++++--------
 meta/classes/image-vm.bbclass        |   15 +++++++--------
 meta/classes/syslinux.bbclass        |   23 ++++++++++++++++++-----
 5 files changed, 38 insertions(+), 25 deletions(-)
meta/classes/boot-directdisk.bbclass +4 -4
index 89007e3..fcdef26 100644
@@ -53,14 +53,13 @@ def pcbios_class(d):
 PCBIOS = "${@pcbios(d)}"
 PCBIOS_CLASS = "${@pcbios_class(d)}"
 
+# Get the build_syslinux_cfg() function from the syslinux class
 inherit ${PCBIOS_CLASS}
 inherit ${EFI_CLASS}
 
-# Get the build_syslinux_cfg() function from the syslinux class
-
 DISK_SIGNATURE ?= "${DISK_SIGNATURE_GENERATED}"
-SYSLINUX_ROOT ?= "root=/dev/sda2"
-SYSLINUX_TIMEOUT ?= "10"
+SYSLINUX_ROOT_VM ?= "root=/dev/sda2"
+SYSLINUX_CFG_VM  ?= "${S}/syslinux_hdd.cfg"
 
 boot_direct_populate() {
 	dest=$1
@@ -162,6 +161,7 @@ build_boot_dd() {
 python do_bootdirectdisk() {
     validate_disk_signature(d)
     if d.getVar("PCBIOS", True) == "1":
+        syslinux_set_vars(d, 'VM')
         bb.build.exec_func('build_syslinux_cfg', d)
     if d.getVar("EFI", True) == "1":
         bb.build.exec_func('build_efi_cfg', d)
meta/classes/bootimg.bbclass +1 -0
index b174266..7946839 100644
@@ -281,6 +281,7 @@ build_hddimg() {
 
 python do_bootimg() {
     if d.getVar("PCBIOS", True) == "1":
+        syslinux_set_vars(d, 'LIVE')
         bb.build.exec_func('build_syslinux_cfg', d)
     if d.getVar("EFI", True) == "1":
         bb.build.exec_func('build_efi_cfg', d)
meta/classes/image-live.bbclass +8 -8
index badf40d..b8f21cb 100644
@@ -1,10 +1,10 @@
 
-INITRD_IMAGE ?= "core-image-minimal-initramfs"
-INITRD ?= "${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE}-${MACHINE}.cpio.gz"
-SYSLINUX_ROOT ?= "root=/dev/ram0"
-SYSLINUX_TIMEOUT ?= "50"
-SYSLINUX_LABELS ?= "boot install"
-LABELS_append = " ${SYSLINUX_LABELS} "
+INITRD_IMAGE_LIVE ?= "core-image-minimal-initramfs"
+INITRD_LIVE ?= "${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE_LIVE}-${MACHINE}.cpio.gz"
+SYSLINUX_ROOT_LIVE ?= "root=/dev/ram0"
+SYSLINUX_LABELS_LIVE ?= "boot install"
+LABELS_LIVE ?= "${SYSLINUX_LABELS_LIVE}"
+SYSLINUX_CFG_LIVE ?= "${S}/syslinux_live.cfg"
 
 ROOTFS ?= "${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.ext4"
 
@@ -19,9 +19,9 @@ IMAGE_TYPES_MASKED += "live hddimg iso"
 
 python() {
     image_b = d.getVar('IMAGE_BASENAME', True)
-    initrd_i = d.getVar('INITRD_IMAGE', True)
+    initrd_i = d.getVar('INITRD_IMAGE_LIVE', True)
     if image_b == initrd_i:
-        bb.error('INITRD_IMAGE %s cannot use image live, hddimg or iso.' % initrd_i)
+        bb.error('INITRD_IMAGE_LIVE %s cannot use image live, hddimg or iso.' % initrd_i)
         bb.fatal('Check IMAGE_FSTYPES and INITRAMFS_FSTYPES settings.')
     else:
         d.appendVarFlag('do_bootimg', 'depends', ' %s:do_image_complete' % initrd_i)
meta/classes/image-vm.bbclass +7 -8
index 6f3a55b..17e87a5 100644
@@ -1,18 +1,17 @@
 
-SYSLINUX_PROMPT ?= "0"
-SYSLINUX_LABELS = "boot"
-LABELS_append = " ${SYSLINUX_LABELS} "
+SYSLINUX_LABELS_VM ?= "boot"
+LABELS_VM ?= "${SYSLINUX_LABELS_VM}"
 
-# Using an initramfs is optional. Enable it by setting INITRD_IMAGE.
-INITRD_IMAGE ?= ""
-INITRD ?= "${@'${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE}-${MACHINE}.cpio.gz' if '${INITRD_IMAGE}' else ''}"
-do_bootdirectdisk[depends] += "${@'${INITRD_IMAGE}:do_image_complete' if '${INITRD_IMAGE}' else ''}"
+# Using an initramfs is optional. Enable it by setting INITRD_IMAGE_VM.
+INITRD_IMAGE_VM ?= ""
+INITRD_VM ?= "${@'${DEPLOY_DIR_IMAGE}/${INITRD_IMAGE_VM}-${MACHINE}.cpio.gz' if '${INITRD_IMAGE_VM}' else ''}"
+do_bootdirectdisk[depends] += "${@'${INITRD_IMAGE_VM}:do_image_complete' if '${INITRD_IMAGE_VM}' else ''}"
 
 # need to define the dependency and the ROOTFS for directdisk
 do_bootdirectdisk[depends] += "${PN}:do_image_ext4"
 ROOTFS ?= "${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.ext4"
 
-# creating VM images relies on having a hddimg so ensure we inherit it here.
+# creating VM images relies on having a hdddirect so ensure we inherit it here.
 inherit boot-directdisk
 
 IMAGE_TYPEDEP_vmdk = "ext4"
meta/classes/syslinux.bbclass +18 -5
index 44ef9a9..1b644b2 100644
@@ -20,8 +20,6 @@
 do_bootimg[depends] += "${MLPREFIX}syslinux:do_populate_sysroot \
                         syslinux-native:do_populate_sysroot"
 
-SYSLINUXCFG  = "${S}/syslinux.cfg"
-
 ISOLINUXDIR = "/isolinux"
 SYSLINUXDIR = "/"
 # The kernel has an internal default console, which you can override with
@@ -29,6 +27,9 @@ SYSLINUXDIR = "/"
 SYSLINUX_DEFAULT_CONSOLE ?= ""
 SYSLINUX_SERIAL ?= "0 115200"
 SYSLINUX_SERIAL_TTY ?= "console=ttyS0,115200"
+SYSLINUX_PROMPT ?= "0"
+SYSLINUX_TIMEOUT ?= "50"
+AUTO_SYSLINUXMENU ?= "1"
 ISO_BOOTIMG = "isolinux/isolinux.bin"
 ISO_BOOTCAT = "isolinux/boot.cat"
 MKISOFS_OPTIONS = "-no-emul-boot -boot-load-size 4 -boot-info-table"
@@ -37,6 +38,18 @@ APPEND_prepend = " ${SYSLINUX_ROOT} "
 # Need UUID utility code.
 inherit fs-uuid
 
+# Some of the vars for vm and live image are conflicted, this function
+# is used for fixing the problem.
+def syslinux_set_vars(d, suffix):
+    vars = ['SYSLINUX_ROOT', 'SYSLINUX_CFG', 'LABELS', 'INITRD']
+    for var in vars:
+        var_with_suffix = var + '_' + suffix
+        if d.getVar(var, True):
+            bb.warn('Found potential conflicted var %s, please use %s rather than %s' % \
+                (var, var_with_suffix, var))
+        elif d.getVar(var_with_suffix, True):
+            d.setVar(var, d.getVar(var_with_suffix, True))
+
 syslinux_populate() {
 	DEST=$1
 	BOOTDIR=$2
@@ -45,7 +58,7 @@ syslinux_populate() {
 	install -d ${DEST}${BOOTDIR}
 
 	# Install the config files
-	install -m 0644 ${SYSLINUXCFG} ${DEST}${BOOTDIR}/${CFGNAME}
+	install -m 0644 ${SYSLINUX_CFG} ${DEST}${BOOTDIR}/${CFGNAME}
 	if [ "${AUTO_SYSLINUXMENU}" = 1 ] ; then
 		install -m 0644 ${STAGING_DATADIR}/syslinux/vesamenu.c32 ${DEST}${BOOTDIR}/vesamenu.c32
 		install -m 0444 ${STAGING_DATADIR}/syslinux/libcom32.c32 ${DEST}${BOOTDIR}/libcom32.c32
@@ -96,9 +109,9 @@ python build_syslinux_cfg () {
         bb.debug(1, "No labels, nothing to do")
         return
 
-    cfile = d.getVar('SYSLINUXCFG', True)
+    cfile = d.getVar('SYSLINUX_CFG', True)
     if not cfile:
-        raise bb.build.FuncFailed('Unable to read SYSLINUXCFG')
+        raise bb.build.FuncFailed('Unable to read SYSLINUX_CFG')
 
     try:
         cfgfile = file(cfile, 'w')
Signature · 1 line
1.7.9.5
#4 lore raw

PATCH 4/4 sanity.bbclass: remove conflict checking for image vm and live

In reply to Robert Yang

[YOCTO #9161]

---
 meta/classes/sanity.bbclass |   12 ------------
 1 file changed, 12 deletions(-)
meta/classes/sanity.bbclass +0 -12
index 466eb49..edf49da 100644
@@ -843,18 +843,6 @@ def check_sanity_everybuild(status, d):
         with open(checkfile, "w") as f:
             f.write(tmpdir)
 
-    # 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")
-
-    # Check qcow2 and live can't be built together.
-    if 'qcow2' in d.getVar('IMAGE_FSTYPES', True) and 'live' in d.getVar('IMAGE_FSTYPES', True):
-        status.addresult("Error, IMAGE_FSTYPES qcow2 and live can't be built together\n")
-
     # Check /bin/sh links to dash or bash
     real_sh = os.path.realpath('/bin/sh')
     if not real_sh.endswith('/dash') and not real_sh.endswith('/bash'):
Signature · 1 line
1.7.9.5
#5 lore raw
In reply to Robert Yang

Hi Ross,

Quoted 19 lines · Robert Yang

Hello,

These patches can make vm and live images build together, and also make the images easier to use.

I'd like to combine the following classes if you are fine with it:
* boot-directdisk.bbclass and image-vm.bbclass into image-vm.bbclass. They are used for making vm images.
* bootimg.bbclass and image-live.bbclass into image-live.bbclass. They are used for making live images.
Combine them can make them easier to understand and also make the structure clearer.

// Robert

The following changes since commit 205b446f3fc4a9885179a66a8dab9d81bcc63dca:

uclibc: Do not use immediate expansion operator (2016-02-22 20:42:34 +0000)

Quoted 8 lines

are available in the git repository at:

git://git.openembedded.org/openembedded-core-contrib rbt/syslinux
http://cgit.openembedded.org/cgit.cgi/openembedded-core-contrib/log/?h=rbt/syslinux

Robert Yang (4):
image-live/boot-directdisk.bbclass: remove AUTO_SYSLINUXCFG boot-directdisk.bbclass: drop IS_VM chechking

The two are merged.

Quoted 2 lines

syslinux.bbclass: make vm and live can be built together sanity.bbclass: remove conflict checking for image vm and live

How about these 2 please ? These are convenient for testing images, otherwise we have to build two times to get virtual machine and live images.

// Robert

Quoted 9 lines
  meta/classes/boot-directdisk.bbclass |   21 ++++++++-------------
  meta/classes/bootimg.bbclass         |    1 +
  meta/classes/image-live.bbclass      |   17 ++++++++---------
  meta/classes/image-vm.bbclass        |   15 +++++++--------
  meta/classes/sanity.bbclass          |   12 ------------
  meta/classes/syslinux.bbclass        |   23 ++++++++++++++++++-----
  6 files changed, 42 insertions(+), 47 deletions(-)
#6 lore raw
Quoted 7 lines · Robert Yang

Robert Yang (4):

Quoted 3 lines

image-live/boot-directdisk.bbclass: remove AUTO_SYSLINUXCFG boot-directdisk.bbclass: drop IS_VM chechking

The two are merged.

Quoted 7 lines

syslinux.bbclass: make vm and live can be built together

Quoted 2 lines

sanity.bbclass: remove conflict checking for image vm and live

How about these 2 please ? These are convenient for testing images, otherwise we have to build two times to get virtual machine and live images.

Two were easy, two were more complex. They're in mut now.

Ross

#7 lore raw
In reply to Robert Yang
Quoted 4 lines · Robert Yang

syslinux.bbclass: make vm and live can be built together

Quoted 1 line

sanity.bbclass: remove conflict checking for image vm and live

If I build a core-image-sato for intel-corei7-32 I get this warning:

WARNING: core-image-sato-base-1.0-r0 do_bootimg: Found potential conflicted var INITRD, please use INITRD_LIVE rather than INITRD

Ross

#8 lore raw
Quoted 4 lines · Ross

On 29 February 2016 at 05:54, Robert Yang <[email protected] <mailto:[email protected]>> wrote:

Quoted 8 lines

syslinux.bbclass: make vm and live can be built together sanity.bbclass: remove conflict checking for image vm and live

If I build a core-image-sato for intel-corei7-32 I get this warning:

WARNING: core-image-sato-base-1.0-r0 do_bootimg: Found potential conflicted var INITRD, please use INITRD_LIVE rather than INITRD

I added this checking, we need fix from from meta-intel, I will send a patch to meta-yocto [email protected] to fix it.

// Robert

Quoted 2 lines

Ross