arm-autonomy/xenguest: Add guestcount support
PATCH 1/3 arm-autonomy/xenguest: Add guestcount support
From: Nathan Dunne <[email protected]>
Add guestcount parameter to ARM_AUTONOMY_HOST_IMAGE_EXTERN_GUESTS, to create multiple guests with the same config. Symlinks are created in the host rootfs pointing to the original xenguest file
Parameters for ARM_AUTONOMY_HOST_IMAGE_EXTERN_GUESTS are now retrieved using python regex rather than split, so that they can appear in any order
Issue-Id: SCM-1863
--- .../images/arm-autonomy-host-image-minimal.bb | 54 +++++++++++++------ .../xenguest/files/xenguest-manager | 22 ++++++-- 2 files changed, 58 insertions(+), 18 deletions(-)
meta-arm-autonomy/recipes-core/images/arm-autonomy-host-image-minimal.bb +39 -15
@@ -14,12 +14,21 @@ LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda # The ARM_AUTONOMY_HOST_IMAGE_EXTERN_GUESTS variable can be used to include in the # image one or several xenguest images. # The list must be space separated and each entry must have the following -# format: URL[;guestname=NAME] +# format: URL[;params] # - URL can be the full path to a file or a Yocto compatible SRC_URI url -# - guestname=NAME can be used to specify the name of the guest. If not -# specified the basename of the file (without .xenguest extension) is used. +# - params encompasses two values that can be optionally set: +# - guestname=NAME can be used to specify the name of the guest. If not +# specified the default value is the basename of the file +# (without .xenguest extension). +# - guestcount=NUM can be used to created NUM guests with the same config. +# All guests after the first will have numbers appended to the guestname, +# starting from 2. In the rootfs additional xenguest files will be +# symlinks to the original. +# params should be semicolon seperated, without a space, and can appear in +# any order. +# # Here are examples of values: -# /home/mydir/myguest.xenguest;guestname=guest1 +# /home/mydir/myguest.xenguest;guestname=guest1;guestcount=3 # http://www.url.com/testguest.xenguest # # If you are using the output of an other Yocto project, you should use the
@@ -73,6 +82,11 @@ do_image[mcdepends] += "${DO_IMAGE_MCDEPENDS}" python __anonymous() { + import re + guestfile_pattern = re.compile(r"^([^;]+);") + guestname_pattern = re.compile(r";guestname=([^;]+);?") + guestcount_pattern = re.compile(r";guestcount=(\d+);?") + if bb.utils.contains('DISTRO_FEATURES', 'arm-autonomy-host', False, True, d): raise bb.parse.SkipRecipe("DISTRO_FEATURES does not contain 'arm-autonomy-host'")
@@ -87,16 +101,19 @@ python __anonymous() { # If the user just specified a file instead of file://FILE, add # the file:// prefix if guest.startswith('/'): - guestfile = '' - guestname = '' - if ';guestname=' in guest: - # user specified a guestname - guestname = guest.split(';guestname=')[1] - guestfile = guest.split(';guestname=')[0] - else: - # no guestname so use the basename - guestname = os.path.basename(guest) - guestfile = guest + guestname = os.path.basename(guest) + guestfile = guest + guestcount = "1" + f = guestfile_pattern.search(guest) + n = guestname_pattern.search(guest) + c = guestcount_pattern.search(guest) + + if f is not None: + guestfile = f.group(1) + if n is not None: + guestname = n.group(1) + if c is not None: + guestcount = c.group(1) # in case we have a link we need the destination guestfile = os.path.realpath(guestfile)
@@ -105,7 +122,7 @@ python __anonymous() { raise bb.parse.SkipRecipe("ARM_AUTONOMY_HOST_IMAGE_EXTERN_GUESTS entry does not exist: " + guest) # In case the file is a symlink make sure we use the destination - d.appendVar('SRC_URI', ' file://' + guestfile + ';guestname=' + guestname) + d.appendVar('SRC_URI', ' file://' + guestfile + ';guestname=' + guestname + ';guestcount=' + guestcount) else: # we have a Yocto URL try:
@@ -141,8 +158,15 @@ python add_extern_guests () { # Add file extension if not there if not dstname.endswith('.xenguest'): dstname += '.xenguest' + if not bb.utils.copyfile(path, guestdir + '/' + dstname): bb.fatal("Fail to copy Guest file " + path) + + if 'guestcount' in parm: + guestcount = int(parm['guestcount']) + 1 + + for i in range(2, guestcount): + os.symlink('./' + dstname, guestdir + '/' + dstname.replace('.xenguest', str(i) + '.xenguest')) } IMAGE_PREPROCESS_COMMAND += "add_extern_guests; "
meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-manager +19 -3
@@ -1017,15 +1017,31 @@ case ${cmd} in create) guestfile="${arg1}" guestname="${arg2}" - if [ -z "${guestfile}" -o ! -f "${guestfile}" ]; then + # guestfile invalid if empty + if [ -z "${guestfile}" ]; then log fatal "Usage ${this} create XENGUEST_FILE [NAME]" fi + # Set Guest name before resolving any symlinks if [ -z "${guestname}" ]; then guestname=$(basename ${guestfile} .xenguest) + log info "guestname argument not provided, using '${guestname}'" fi - + # Check for and resolve symlink + if [ -L "${guestfile}" ]; then + errmsg="'${guestfile}' is a broken symlink" + guestfile=$(readlink -e "${guestfile}") + if [ -z "${guestfile}" ]; then + log fatal "${errmsg}" + else + log info "Guestfile symlink resolved to path '${guestfile}'" + fi + fi + # Check that guestfile is a valid file + if [ ! -f "${guestfile}" ]; then + log fatal "File '${guestfile}' not found" + fi + # Check if guest already exists if [ -f ${XENGUEST_CONF_BASE}/guests/${guestname}/guest.cfg ]; then - # Guest already exist log fatal "Guest '${guestname}' already exists" fi
Signature · 1 line
2.17.1
PATCH 2/3 arm-autonomy/documentation: Remove references to meta-kernel
From: Nathan Dunne <[email protected]>
Since meta-arm-bsp doesn't depend on meta-kernel anymore it has been removed from the appropriate documentation.
Issue-Id: SCM-2005
--- meta-arm-autonomy/documentation/arm-autonomy-quickstart.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
meta-arm-autonomy/documentation/arm-autonomy-quickstart.md +1 -4
@@ -26,7 +26,6 @@ First you must download the Yocto layers needed: - [poky](https://git.yoctoproject.org/poky) - [meta-virtualization](https://git.yoctoproject.org/meta-virtualization) - [meta-arm](https://git.yoctoproject.org/meta-arm) - - [meta-kernel](https://gitlab.com/openembedded/community/meta-kernel.git) - all other layers you might want to use For each of the downloaded layer make sure you checkout the release of Yocto
@@ -57,7 +56,6 @@ Here are the main steps to create an arm-autonomy project: bitbake-layers add-layer $LAYERDIR_BASE/meta-poky $LAYERDIR_BASE/meta-yocto-bsp \ $LAYERDIR_BASE/meta-openembedded/meta-oe $LAYERDIR_BASE/meta-openembedded/meta-python \ $LAYERDIR_BASE/meta-openembedded/meta-filesystems $LAYERDIR_BASE/meta-openembedded/meta-networking \ - $LAYERDIR_BASE/meta-virtualization $LAYERDIR_BASE/meta-kernel \ $LAYERDIR_BASE/meta-arm/meta-arm $LAYERDIR_BASE/meta-arm/meta-arm-toolchain \ $LAYERDIR_BASE/meta-arm/meta-arm-bsp $LAYERDIR_BASE/meta-arm/meta-arm-autonomy \ ```
@@ -73,7 +71,6 @@ Here are the main steps to create an arm-autonomy project: /home/user/arm-autonomy/meta-openembedded/meta-filesystems \ /home/user/arm-autonomy/meta-openembedded/meta-networking \ /home/user/arm-autonomy/meta-virtualization \ - /home/user/arm-autonomy/meta-kernel \ /home/user/arm-autonomy/meta-arm/meta-arm \ /home/user/arm-autonomy/meta-arm/meta-arm-toolchain \ /home/user/arm-autonomy/meta-arm/meta-arm-bsp \
@@ -212,7 +209,7 @@ and is configuring it by default to use dhcp. If you need a different type of configuration you can set XENGUEST_NETWORK_BRIDGE_CONFIG in a xenguest-network-bridge.bbappend to use a different file. -The recipe will look for the file in ${WORKDIR} so you will need to add it to +The recipe will look for the file in ${WORKDIR} so you will need to add it to SRC_URI in your bbappend. The recipe will also substitute `###BRIDGE_NAME###` with the bridge name configured in ${XENGUEST_NETWORK_BRIDGE_NAME}.
Signature · 1 line
2.17.1
PATCH 3/3 arm-autonomy/arm-autonomy-host-image-minimal: Use REQUIRED_DISTRO_FEATURES
In reply to Nathan DunneFrom: Nathan Dunne <[email protected]>
Make use of REQUIRED_DISTRO_FEATURES rather than anonymous python for determining that both arm-autonomy-host and xen are present in DISTRO_FEATURES
Issue-Id: SCM-1862
--- .../images/arm-autonomy-host-image-minimal.bb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
meta-arm-autonomy/recipes-core/images/arm-autonomy-host-image-minimal.bb +3 -7
@@ -6,7 +6,7 @@ DESCRIPTION = "Arm Autonomy stack host minimal image" # and install the alternate kernel inherit ${@bb.utils.filter('DISTRO_FEATURES', 'alternate-kernel', d)} -inherit core-image +inherit core-image features_check LICENSE = "MIT" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
@@ -80,6 +80,8 @@ DO_IMAGE_MCDEPENDS := "${@ '${MC_DOIMAGE_MCDEPENDS}' if d.getVar('BBMULTICONFIG' # Apply mc dependency. Empty string if multiconfig not enabled do_image[mcdepends] += "${DO_IMAGE_MCDEPENDS}" +REQUIRED_DISTRO_FEATURES += 'arm-autonomy-host' +REQUIRED_DISTRO_FEATURES += 'xen' python __anonymous() { import re
@@ -87,12 +89,6 @@ python __anonymous() { guestname_pattern = re.compile(r";guestname=([^;]+);?") guestcount_pattern = re.compile(r";guestcount=(\d+);?") - if bb.utils.contains('DISTRO_FEATURES', 'arm-autonomy-host', False, True, d): - raise bb.parse.SkipRecipe("DISTRO_FEATURES does not contain 'arm-autonomy-host'") - - if bb.utils.contains('DISTRO_FEATURES', 'xen', False, True, d): - raise bb.parse.SkipRecipe("DISTRO_FEATURES does not contain 'xen'") - # Check in ARM_AUTONOMY_HOST_IMAGE_EXTERN_GUESTS for extra guests and add them # to SRC_URI with xenguest parameter if not set guestlist = d.getVar('ARM_AUTONOMY_HOST_IMAGE_EXTERN_GUESTS')
Signature · 1 line
2.17.1
Quoted 6 lines · Nathan Dunne
From: Nathan Dunne <[email protected]>
Add guestcount parameter to
ARM_AUTONOMY_HOST_IMAGE_EXTERN_GUESTS, to create multiple guests with the same config. Symlinks are created in the host rootfs pointing to the original xenguest file
Quoted 8 lines
Parameters for
ARM_AUTONOMY_HOST_IMAGE_EXTERN_GUESTSare now retrieved using python regex rather than split, so that they can appear in any orderIssue-Id: SCM-1863
Signed-off-by Nathan Dunne <[email protected]>Change-Id Ifa5f5ab3b284815427c94979b3f1a5eed592ec3c---
Series pushed into the master branch.
Thanks,
Jon
Quoted 147 lines
.../images/arm-autonomy-host-image-minimal.bb | 54 +++++++++++++------ .../xenguest/files/xenguest-manager | 22 ++++++-- 2 files changed, 58 insertions(+), 18 deletions(-)meta-arm-autonomy/recipes-core/images/arm-autonomy-host-image-minimal.bb +39
-15@@ -14,12 +14,21 @@ LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda # The ARM_AUTONOMY_HOST_IMAGE_EXTERN_GUESTS variable can be used to include in the # image one or several xenguest images. # The list must be space separated and each entry must have the following -# format: URL[;guestname=NAME] +# format: URL[;params] # - URL can be the full path to a file or a Yocto compatible SRC_URI url -# - guestname=NAME can be used to specify the name of the guest. If not -# specified the basename of the file (without .xenguest extension) is used. +# - params encompasses two values that can be optionally set: +# - guestname=NAME can be used to specify the name of the guest. If not +# specified the default value is the basename of the file +# (without .xenguest extension). +# - guestcount=NUM can be used to created NUM guests with the same config. +# All guests after the first will have numbers appended to the guestname, +# starting from 2. In the rootfs additional xenguest files will be +# symlinks to the original. +# params should be semicolon seperated, without a space, and can appear in +# any order. +# # Here are examples of values: -# /home/mydir/myguest.xenguest;guestname=guest1 +# /home/mydir/myguest.xenguest;guestname=guest1;guestcount=3 # http://www.url.com/testguest.xenguest # # If you are using the output of an other Yocto project, you should use the@@ -73,6 +82,11 @@ do_image[mcdepends] += "${DO_IMAGE_MCDEPENDS}" python __anonymous() { + import re + guestfile_pattern = re.compile(r"^([^;]+);") + guestname_pattern = re.compile(r";guestname=([^;]+);?") + guestcount_pattern = re.compile(r";guestcount=(\d+);?") + if bb.utils.contains('DISTRO_FEATURES', 'arm-autonomy-host', False, True, d): raise bb.parse.SkipRecipe("DISTRO_FEATURES does not contain 'arm-autonomy-host'")@@ -87,16 +101,19 @@ python __anonymous() { # If the user just specified a file instead of file://FILE, add # the file:// prefix if guest.startswith('/'): - guestfile = '' - guestname = '' - if ';guestname=' in guest: - # user specified a guestname - guestname = guest.split(';guestname=')[1] - guestfile = guest.split(';guestname=')[0] - else: - # no guestname so use the basename - guestname = os.path.basename(guest) - guestfile = guest + guestname = os.path.basename(guest) + guestfile = guest + guestcount = "1" + f = guestfile_pattern.search(guest) + n = guestname_pattern.search(guest) + c = guestcount_pattern.search(guest) + + if f is not None: + guestfile = f.group(1) + if n is not None: + guestname = n.group(1) + if c is not None: + guestcount = c.group(1) # in case we have a link we need the destination guestfile = os.path.realpath(guestfile)@@ -105,7 +122,7 @@ python __anonymous() { raise bb.parse.SkipRecipe("ARM_AUTONOMY_HOST_IMAGE_EXTERN_GUESTS entry does not exist: " + guest) # In case the file is a symlink make sure we use the destination - d.appendVar('SRC_URI', ' file://' + guestfile + ';guestname=' + guestname) + d.appendVar('SRC_URI', ' file://' + guestfile + ';guestname=' + guestname + ';guestcount=' + guestcount) else: # we have a Yocto URL try:@@ -141,8 +158,15 @@ python add_extern_guests () { # Add file extension if not there if not dstname.endswith('.xenguest'): dstname += '.xenguest' + if not bb.utils.copyfile(path, guestdir + '/' + dstname): bb.fatal("Fail to copy Guest file " + path) + + if 'guestcount' in parm: + guestcount = int(parm['guestcount']) + 1 + + for i in range(2, guestcount): + os.symlink('./' + dstname, guestdir + '/' + dstname.replace('.xenguest', str(i) + '.xenguest')) } IMAGE_PREPROCESS_COMMAND += "add_extern_guests; "meta-arm-autonomy/recipes-extended/xenguest/files/xenguest-manager +19
-3@@ -1017,15 +1017,31 @@ case ${cmd} in create) guestfile="${arg1}" guestname="${arg2}" - if [ -z "${guestfile}" -o ! -f "${guestfile}" ]; then + # guestfile invalid if empty + if [ -z "${guestfile}" ]; then log fatal "Usage ${this} create XENGUEST_FILE [NAME]" fi + # Set Guest name before resolving any symlinks if [ -z "${guestname}" ]; then guestname=$(basename ${guestfile} .xenguest) + log info "guestname argument not provided, using '${guestname}'" fi - + # Check for and resolve symlink + if [ -L "${guestfile}" ]; then + errmsg="'${guestfile}' is a broken symlink" + guestfile=$(readlink -e "${guestfile}") + if [ -z "${guestfile}" ]; then + log fatal "${errmsg}" + else + log info "Guestfile symlink resolved to path '${guestfile}'" + fi + fi + # Check that guestfile is a valid file + if [ ! -f "${guestfile}" ]; then + log fatal "File '${guestfile}' not found" + fi + # Check if guest already exists if [ -f ${XENGUEST_CONF_BASE}/guests/${guestname}/guest.cfg ]; then - # Guest already exist log fatal "Guest '${guestname}' already exists" fiSignature · 1 line
2.17.1