All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [arm-autonomy] rework initramfs support in xenguest FSTYPE
@ 2020-05-07 10:43 Bertrand Marquis
  2020-05-08 13:04 ` [meta-arm] " Jon Mason
  0 siblings, 1 reply; 2+ messages in thread
From: Bertrand Marquis @ 2020-05-07 10:43 UTC (permalink / raw)
  To: meta-arm; +Cc: nd

Rework the initramfs support in xenguest FSTYPE to be compatible with
Dunfell and remove an error with non existing recipeinfo during build.
- remove initramfs support in FSTYPE and do_deploy function
- create a KERNEL CLASS to create a xenguest image containing the kernel
bundle with initramfs during kernel compilation (only done if FSTYPE
contain xenguest and initramfs bundle is activated)
- add kernel-xenguest to KERNEL_CLASSES when autonomy-guest
DISTRO_FEATURE is activated
- remove unused parameters from xenguest-image class

Change-Id: If163aa74a2bbbd4f22651abefe8d2ab4677e82b0
Issue-Id: SCM-990
Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>
---
 .../classes/image_types_xenguest.bbclass      | 56 ++++++-------------
 .../classes/kernel-xenguest.bbclass           | 34 +++++++++++
 .../classes/xenguest-image.bbclass            |  5 +-
 .../distro/include/arm-autonomy-guest.inc     |  2 +
 4 files changed, 53 insertions(+), 44 deletions(-)
 create mode 100644 meta-arm-autonomy/classes/kernel-xenguest.bbclass

diff --git a/meta-arm-autonomy/classes/image_types_xenguest.bbclass b/meta-arm-autonomy/classes/image_types_xenguest.bbclass
index ff1e41a..195d6ed 100644
--- a/meta-arm-autonomy/classes/image_types_xenguest.bbclass
+++ b/meta-arm-autonomy/classes/image_types_xenguest.bbclass
@@ -1,7 +1,7 @@
 # Create a xenguest image with kernel and filesystem produced by Yocto
 # This will create a .xenguest file that the xenguest-manager can use.
 
-inherit xenguest-image deploy
+inherit xenguest-image
 
 # We are creating our guest in a local subdirectory
 # force the value so that we are not impacted if the user is changing it
@@ -10,9 +10,6 @@ XENGUEST_IMAGE_DEPLOY_DIR = "${WORKDIR}/tmp-xenguest"
 # Name of deployed file (keep standard image name and add .xenguest)
 XENGUEST_IMAGE_DEPLOY ??= "${IMAGE_NAME}"
 
-# Deployed file when building with initramfs
-XENGUEST_IMAGE_INITRAMFS_DEPLOY ??= "Image-initramfs-${MACHINE}"
-
 # Add kernel XENGUEST_IMAGE_KERNEL from DEPLOY_DIR_IMAGE to image
 xenguest_image_add_kernel() {
     srcfile="${1:-}"
@@ -36,20 +33,6 @@ xenguest_image_pack() {
         ${IMGDEPLOYDIR}/${XENGUEST_IMAGE_DEPLOY}.xenguest
 }
 
-# do_deploy is used for initramfs to pack the kernel initramfs in an image
-do_deploy() {
-    # Add kernel
-    xenguest_image_add_kernel
-
-    # Pack the image in deploydir
-    mkdir -p ${DEPLOYDIR}
-    rm -f ${DEPLOYDIR}/${XENGUEST_IMAGE_INITRAMFS_DEPLOY}.xenguest
-    call_xenguest_mkimage pack \
-        ${DEPLOYDIR}/${XENGUEST_IMAGE_INITRAMFS_DEPLOY}.xenguest
-}
-do_deploy[depends] += "${PN}:do_bootimg_xenguest"
-do_deploy[depends] += "virtual/kernel:do_deploy"
-
 #
 # Task finishing the bootimg
 # We need this task to actually create the symlinks
@@ -88,28 +71,24 @@ python __anonymous() {
         rootfs_needed = False
         rootfs_file = ''
         kernel_needed = False
-        initramfs_needed = False
 
         rootfs_file = xenguest_image_rootfs_file(d)
         if rootfs_file:
             rootfs_needed = True
 
-        if d.getVar('XENGUEST_IMAGE_KERNEL'):
+        if d.getVar('XENGUEST_IMAGE_KERNEL') and not d.getVar('INITRAMFS_IMAGE'):
+            # If INITRAMFS_IMAGE is set, even if INITRAMFS_IMAGE_BUNDLE is not
+            # set to 1 to bundle the initramfs with the kernel, kernel.bbclass
+            # is setting a dependency on ${PN}:do_image_complete. We cannot
+            # in this case depend on do_deploy as it would create a circular
+            # dependency:
+            # do_image_complete would depend on kernel:do_deploy which would
+            # depend on ${PN}:do_image_complete
+            # In the case INITRAMFS_IMAGE_BUNDLE = 1, the kernel-xenguest class
+            # will handle the creation of a xenguest image with the kernel.
+            # In the other case the kernel can be added manually to the image.
             kernel_needed = True
 
-        if d.getVar('INITRAMFS_IMAGE'):
-            if int(d.getVar('INITRAMFS_IMAGE_BUNDLE')) != 1:
-                bb.error("xenguest-fstype: INITRAMFS_IMAGE is set but INITRAMFS_IMAGE_BUNDLE is set to 0.\n")
-                bb.fatal("xenguest-fstype: This configuration is not supported by xenguest image type\n")
-            initramfs_needed = True
-
-        if initramfs_needed and rootfs_needed:
-            bb.warn("xenguest-fstype: Final image will use an initramfs kernel and rootfs in disk.\n")
-            bb.warn("xenguest-fstype: rootfs.tar.%s should be removed from XENGUEST_IMAGE_DISK_PARTITIONS.\n")
-
-        if not initramfs_needed and not rootfs_needed and not kernel_needed:
-            bb.warn("xenguest-fstype: Generated image will have no kernel and no rootfs.\n")
-
         bb.build.addtask('do_bootimg_xenguest', 'do_image_complete', None, d)
 
         if rootfs_needed:
@@ -121,12 +100,9 @@ python __anonymous() {
             d.setVar('IMAGE_TYPEDEP_xenguest', 'tar' + (rootfs_file.split('.tar', 1)[1] or ''))
 
         if kernel_needed:
-            if initramfs_needed:
-                bb.build.addtask('do_deploy', 'do_build', None, d)
-            else:
-                # Tell do_bootimg_xenguest to call xenguest_image_add_kernel
-                d.appendVarFlag('do_bootimg_xenguest', 'subtasks', ' xenguest_image_add_kernel')
-                # we will need kernel do_deploy
-                d.appendVarFlag('do_bootimg_xenguest', 'depends', ' virtual/kernel:do_deploy')
+            # Tell do_bootimg_xenguest to call xenguest_image_add_kernel
+            d.appendVarFlag('do_bootimg_xenguest', 'subtasks', ' xenguest_image_add_kernel')
+            # we will need kernel do_deploy
+            d.appendVarFlag('do_bootimg_xenguest', 'depends', ' virtual/kernel:do_deploy')
 }
 
diff --git a/meta-arm-autonomy/classes/kernel-xenguest.bbclass b/meta-arm-autonomy/classes/kernel-xenguest.bbclass
new file mode 100644
index 0000000..a4954aa
--- /dev/null
+++ b/meta-arm-autonomy/classes/kernel-xenguest.bbclass
@@ -0,0 +1,34 @@
+# Create a xenguest image containing the kernel with initramfs when
+# initramfs is activated
+# This is done using kernel-fitimage as model
+# To activate this, kernel-xenguest must be added to KERNEL_CLASSES
+
+inherit xenguest-image
+
+# use a local copy to pack all together
+XENGUEST_IMAGE_DEPLOY_DIR = "${WORKDIR}/tmp-xenguest"
+
+python __anonymous () {
+    # only if xenguest image type is present
+    if bb.utils.contains('IMAGE_FSTYPES', 'xenguest', '1', '0', d):
+        # only if initramfs bundle is activated
+        if d.getVar('INITRAMFS_IMAGE') and d.getVar('INITRAMFS_IMAGE_BUNDLE') == "1":
+            if not bb.utils.contains('KERNEL_IMAGETYPES', 'Image', '1', '0', d):
+                bb.fatal("xenguest image type with initramfs require Image kernel image type")
+            bb.build.addtask('do_assemble_xenguest_initramfs', 'do_deploy', 'do_bundle_initramfs', d)
+}
+
+do_assemble_xenguest_initramfs() {
+    xenguest_image_clone
+    call_xenguest_mkimage partial --xen-kernel=${B}/${KERNEL_OUTPUT_DIR}/Image.initramfs
+    rm -f ${B}/${KERNEL_OUTPUT_DIR}/Image-initramfs.xenguest
+    call_xenguest_mkimage pack ${B}/${KERNEL_OUTPUT_DIR}/Image-initramfs.xenguest
+}
+do_assemble_xenguest_initramfs[depends] += "${INITRAMFS_IMAGE}:do_image_complete"
+
+kernel_do_deploy_append() {
+    if [ -f "${B}/${KERNEL_OUTPUT_DIR}/Image-initramfs.xenguest" ]; then
+        install -m 0644 ${B}/${KERNEL_OUTPUT_DIR}/Image-initramfs.xenguest "$deployDir/Image-${INITRAMFS_NAME}.xenguest"
+        ln -snf Image-${INITRAMFS_NAME}.xenguest $deployDir/Image-${INITRAMFS_LINK_NAME}.xenguest
+    fi
+}
diff --git a/meta-arm-autonomy/classes/xenguest-image.bbclass b/meta-arm-autonomy/classes/xenguest-image.bbclass
index b4d4122..e8880f3 100644
--- a/meta-arm-autonomy/classes/xenguest-image.bbclass
+++ b/meta-arm-autonomy/classes/xenguest-image.bbclass
@@ -36,11 +36,8 @@ XENGUEST_IMAGE_EXTRA_CMD ??= ""
 # Kernel binary
 # This value is used by the xenguest image type but is declared here to have
 # all variables in the same place
-# Default value is:
-# - Image if INITRAMFS_IMAGE is not set
-# - Image-initramfs-${MACHINE}.bin if INITRAMFS_IMAGE is set
 # If this value is empty no kernel will be added to the image
-XENGUEST_IMAGE_KERNEL ??= "${@ 'Image' if not d.getVar('INITRAMFS_IMAGE') else 'Image-initramfs-${MACHINE}.bin'}"
+XENGUEST_IMAGE_KERNEL ??= "Image"
 
 # Size of the disk to create (if 0 no disk will be created and rootfs will not
 # be included in the xenguest image)
diff --git a/meta-arm-autonomy/conf/distro/include/arm-autonomy-guest.inc b/meta-arm-autonomy/conf/distro/include/arm-autonomy-guest.inc
index 9b5889e..16b9f7e 100644
--- a/meta-arm-autonomy/conf/distro/include/arm-autonomy-guest.inc
+++ b/meta-arm-autonomy/conf/distro/include/arm-autonomy-guest.inc
@@ -7,3 +7,5 @@ DISTRO_FEATURES_append = " ipv4"
 IMAGE_CLASSES += "image_types_xenguest"
 IMAGE_FSTYPES += "xenguest"
 
+# xenguest kernel extension to handle initramfs
+KERNEL_CLASSES += "kernel-xenguest"
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [meta-arm] [PATCH] [arm-autonomy] rework initramfs support in xenguest FSTYPE
  2020-05-07 10:43 [PATCH] [arm-autonomy] rework initramfs support in xenguest FSTYPE Bertrand Marquis
@ 2020-05-08 13:04 ` Jon Mason
  0 siblings, 0 replies; 2+ messages in thread
From: Jon Mason @ 2020-05-08 13:04 UTC (permalink / raw)
  To: meta-arm

On Thu, May 07, 2020 at 11:43:26AM +0100, Bertrand Marquis wrote:
> Rework the initramfs support in xenguest FSTYPE to be compatible with
> Dunfell and remove an error with non existing recipeinfo during build.
> - remove initramfs support in FSTYPE and do_deploy function
> - create a KERNEL CLASS to create a xenguest image containing the kernel
> bundle with initramfs during kernel compilation (only done if FSTYPE
> contain xenguest and initramfs bundle is activated)
> - add kernel-xenguest to KERNEL_CLASSES when autonomy-guest
> DISTRO_FEATURE is activated
> - remove unused parameters from xenguest-image class
> 
> Change-Id: If163aa74a2bbbd4f22651abefe8d2ab4677e82b0
> Issue-Id: SCM-990
> Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>

Pulled into the master branch.

Thanks,
Jon

> ---
>  .../classes/image_types_xenguest.bbclass      | 56 ++++++-------------
>  .../classes/kernel-xenguest.bbclass           | 34 +++++++++++
>  .../classes/xenguest-image.bbclass            |  5 +-
>  .../distro/include/arm-autonomy-guest.inc     |  2 +
>  4 files changed, 53 insertions(+), 44 deletions(-)
>  create mode 100644 meta-arm-autonomy/classes/kernel-xenguest.bbclass
> 
> diff --git a/meta-arm-autonomy/classes/image_types_xenguest.bbclass b/meta-arm-autonomy/classes/image_types_xenguest.bbclass
> index ff1e41a..195d6ed 100644
> --- a/meta-arm-autonomy/classes/image_types_xenguest.bbclass
> +++ b/meta-arm-autonomy/classes/image_types_xenguest.bbclass
> @@ -1,7 +1,7 @@
>  # Create a xenguest image with kernel and filesystem produced by Yocto
>  # This will create a .xenguest file that the xenguest-manager can use.
>  
> -inherit xenguest-image deploy
> +inherit xenguest-image
>  
>  # We are creating our guest in a local subdirectory
>  # force the value so that we are not impacted if the user is changing it
> @@ -10,9 +10,6 @@ XENGUEST_IMAGE_DEPLOY_DIR = "${WORKDIR}/tmp-xenguest"
>  # Name of deployed file (keep standard image name and add .xenguest)
>  XENGUEST_IMAGE_DEPLOY ??= "${IMAGE_NAME}"
>  
> -# Deployed file when building with initramfs
> -XENGUEST_IMAGE_INITRAMFS_DEPLOY ??= "Image-initramfs-${MACHINE}"
> -
>  # Add kernel XENGUEST_IMAGE_KERNEL from DEPLOY_DIR_IMAGE to image
>  xenguest_image_add_kernel() {
>      srcfile="${1:-}"
> @@ -36,20 +33,6 @@ xenguest_image_pack() {
>          ${IMGDEPLOYDIR}/${XENGUEST_IMAGE_DEPLOY}.xenguest
>  }
>  
> -# do_deploy is used for initramfs to pack the kernel initramfs in an image
> -do_deploy() {
> -    # Add kernel
> -    xenguest_image_add_kernel
> -
> -    # Pack the image in deploydir
> -    mkdir -p ${DEPLOYDIR}
> -    rm -f ${DEPLOYDIR}/${XENGUEST_IMAGE_INITRAMFS_DEPLOY}.xenguest
> -    call_xenguest_mkimage pack \
> -        ${DEPLOYDIR}/${XENGUEST_IMAGE_INITRAMFS_DEPLOY}.xenguest
> -}
> -do_deploy[depends] += "${PN}:do_bootimg_xenguest"
> -do_deploy[depends] += "virtual/kernel:do_deploy"
> -
>  #
>  # Task finishing the bootimg
>  # We need this task to actually create the symlinks
> @@ -88,28 +71,24 @@ python __anonymous() {
>          rootfs_needed = False
>          rootfs_file = ''
>          kernel_needed = False
> -        initramfs_needed = False
>  
>          rootfs_file = xenguest_image_rootfs_file(d)
>          if rootfs_file:
>              rootfs_needed = True
>  
> -        if d.getVar('XENGUEST_IMAGE_KERNEL'):
> +        if d.getVar('XENGUEST_IMAGE_KERNEL') and not d.getVar('INITRAMFS_IMAGE'):
> +            # If INITRAMFS_IMAGE is set, even if INITRAMFS_IMAGE_BUNDLE is not
> +            # set to 1 to bundle the initramfs with the kernel, kernel.bbclass
> +            # is setting a dependency on ${PN}:do_image_complete. We cannot
> +            # in this case depend on do_deploy as it would create a circular
> +            # dependency:
> +            # do_image_complete would depend on kernel:do_deploy which would
> +            # depend on ${PN}:do_image_complete
> +            # In the case INITRAMFS_IMAGE_BUNDLE = 1, the kernel-xenguest class
> +            # will handle the creation of a xenguest image with the kernel.
> +            # In the other case the kernel can be added manually to the image.
>              kernel_needed = True
>  
> -        if d.getVar('INITRAMFS_IMAGE'):
> -            if int(d.getVar('INITRAMFS_IMAGE_BUNDLE')) != 1:
> -                bb.error("xenguest-fstype: INITRAMFS_IMAGE is set but INITRAMFS_IMAGE_BUNDLE is set to 0.\n")
> -                bb.fatal("xenguest-fstype: This configuration is not supported by xenguest image type\n")
> -            initramfs_needed = True
> -
> -        if initramfs_needed and rootfs_needed:
> -            bb.warn("xenguest-fstype: Final image will use an initramfs kernel and rootfs in disk.\n")
> -            bb.warn("xenguest-fstype: rootfs.tar.%s should be removed from XENGUEST_IMAGE_DISK_PARTITIONS.\n")
> -
> -        if not initramfs_needed and not rootfs_needed and not kernel_needed:
> -            bb.warn("xenguest-fstype: Generated image will have no kernel and no rootfs.\n")
> -
>          bb.build.addtask('do_bootimg_xenguest', 'do_image_complete', None, d)
>  
>          if rootfs_needed:
> @@ -121,12 +100,9 @@ python __anonymous() {
>              d.setVar('IMAGE_TYPEDEP_xenguest', 'tar' + (rootfs_file.split('.tar', 1)[1] or ''))
>  
>          if kernel_needed:
> -            if initramfs_needed:
> -                bb.build.addtask('do_deploy', 'do_build', None, d)
> -            else:
> -                # Tell do_bootimg_xenguest to call xenguest_image_add_kernel
> -                d.appendVarFlag('do_bootimg_xenguest', 'subtasks', ' xenguest_image_add_kernel')
> -                # we will need kernel do_deploy
> -                d.appendVarFlag('do_bootimg_xenguest', 'depends', ' virtual/kernel:do_deploy')
> +            # Tell do_bootimg_xenguest to call xenguest_image_add_kernel
> +            d.appendVarFlag('do_bootimg_xenguest', 'subtasks', ' xenguest_image_add_kernel')
> +            # we will need kernel do_deploy
> +            d.appendVarFlag('do_bootimg_xenguest', 'depends', ' virtual/kernel:do_deploy')
>  }
>  
> diff --git a/meta-arm-autonomy/classes/kernel-xenguest.bbclass b/meta-arm-autonomy/classes/kernel-xenguest.bbclass
> new file mode 100644
> index 0000000..a4954aa
> --- /dev/null
> +++ b/meta-arm-autonomy/classes/kernel-xenguest.bbclass
> @@ -0,0 +1,34 @@
> +# Create a xenguest image containing the kernel with initramfs when
> +# initramfs is activated
> +# This is done using kernel-fitimage as model
> +# To activate this, kernel-xenguest must be added to KERNEL_CLASSES
> +
> +inherit xenguest-image
> +
> +# use a local copy to pack all together
> +XENGUEST_IMAGE_DEPLOY_DIR = "${WORKDIR}/tmp-xenguest"
> +
> +python __anonymous () {
> +    # only if xenguest image type is present
> +    if bb.utils.contains('IMAGE_FSTYPES', 'xenguest', '1', '0', d):
> +        # only if initramfs bundle is activated
> +        if d.getVar('INITRAMFS_IMAGE') and d.getVar('INITRAMFS_IMAGE_BUNDLE') == "1":
> +            if not bb.utils.contains('KERNEL_IMAGETYPES', 'Image', '1', '0', d):
> +                bb.fatal("xenguest image type with initramfs require Image kernel image type")
> +            bb.build.addtask('do_assemble_xenguest_initramfs', 'do_deploy', 'do_bundle_initramfs', d)
> +}
> +
> +do_assemble_xenguest_initramfs() {
> +    xenguest_image_clone
> +    call_xenguest_mkimage partial --xen-kernel=${B}/${KERNEL_OUTPUT_DIR}/Image.initramfs
> +    rm -f ${B}/${KERNEL_OUTPUT_DIR}/Image-initramfs.xenguest
> +    call_xenguest_mkimage pack ${B}/${KERNEL_OUTPUT_DIR}/Image-initramfs.xenguest
> +}
> +do_assemble_xenguest_initramfs[depends] += "${INITRAMFS_IMAGE}:do_image_complete"
> +
> +kernel_do_deploy_append() {
> +    if [ -f "${B}/${KERNEL_OUTPUT_DIR}/Image-initramfs.xenguest" ]; then
> +        install -m 0644 ${B}/${KERNEL_OUTPUT_DIR}/Image-initramfs.xenguest "$deployDir/Image-${INITRAMFS_NAME}.xenguest"
> +        ln -snf Image-${INITRAMFS_NAME}.xenguest $deployDir/Image-${INITRAMFS_LINK_NAME}.xenguest
> +    fi
> +}
> diff --git a/meta-arm-autonomy/classes/xenguest-image.bbclass b/meta-arm-autonomy/classes/xenguest-image.bbclass
> index b4d4122..e8880f3 100644
> --- a/meta-arm-autonomy/classes/xenguest-image.bbclass
> +++ b/meta-arm-autonomy/classes/xenguest-image.bbclass
> @@ -36,11 +36,8 @@ XENGUEST_IMAGE_EXTRA_CMD ??= ""
>  # Kernel binary
>  # This value is used by the xenguest image type but is declared here to have
>  # all variables in the same place
> -# Default value is:
> -# - Image if INITRAMFS_IMAGE is not set
> -# - Image-initramfs-${MACHINE}.bin if INITRAMFS_IMAGE is set
>  # If this value is empty no kernel will be added to the image
> -XENGUEST_IMAGE_KERNEL ??= "${@ 'Image' if not d.getVar('INITRAMFS_IMAGE') else 'Image-initramfs-${MACHINE}.bin'}"
> +XENGUEST_IMAGE_KERNEL ??= "Image"
>  
>  # Size of the disk to create (if 0 no disk will be created and rootfs will not
>  # be included in the xenguest image)
> diff --git a/meta-arm-autonomy/conf/distro/include/arm-autonomy-guest.inc b/meta-arm-autonomy/conf/distro/include/arm-autonomy-guest.inc
> index 9b5889e..16b9f7e 100644
> --- a/meta-arm-autonomy/conf/distro/include/arm-autonomy-guest.inc
> +++ b/meta-arm-autonomy/conf/distro/include/arm-autonomy-guest.inc
> @@ -7,3 +7,5 @@ DISTRO_FEATURES_append = " ipv4"
>  IMAGE_CLASSES += "image_types_xenguest"
>  IMAGE_FSTYPES += "xenguest"
>  
> +# xenguest kernel extension to handle initramfs
> +KERNEL_CLASSES += "kernel-xenguest"
> -- 
> 2.17.1
> 

> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-08 13:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-07 10:43 [PATCH] [arm-autonomy] rework initramfs support in xenguest FSTYPE Bertrand Marquis
2020-05-08 13:04 ` [meta-arm] " Jon Mason

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.