[1/1] replace custom OVA logic with imagetype logic

Message ID 20230209085042.420572-1-felix.moessbauer@siemens.com
State Superseded, archived
Headers show
Series [1/1] replace custom OVA logic with imagetype logic | expand

Commit Message

MOESSBAUER, Felix Feb. 9, 2023, 8:50 a.m. UTC
This patch refactors the imagetypes_vm class for virtualbox and vmware
images. The existing manual implementation does not work anymore when
referencing ova config files across layers. Instead, we now use the
imagetypes logic, which avoids the problematic changes of
FILESEXTRAPATHS and SRC_URI.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 RECIPE-API-CHANGELOG.md                               | 10 ++++++++++
 .../images/virtualbox}/vm-img-virtualbox.ovf.tmpl     |  0
 .../images/vmware}/vm-img-vmware.ovf.tmpl             |  0
 meta/classes/imagetypes_vm.bbclass                    | 11 ++++-------
 4 files changed, 14 insertions(+), 7 deletions(-)
 rename {meta/classes/vm-img => meta-isar/recipes-core/images/virtualbox}/vm-img-virtualbox.ovf.tmpl (100%)
 rename {meta/classes/vm-img => meta-isar/recipes-core/images/vmware}/vm-img-vmware.ovf.tmpl (100%)

Comments

Schmidt, Adriaan Feb. 10, 2023, 8:30 a.m. UTC | #1
Hi Felix,

nice cleanup!
I had to look up IMAGE_TEMPLATE_* and IMAGE_SRC_URI... somehow I missed/forgot
that we had that infrastructure.

In this case I would leave out the API-CHANGELOG entry. OVF_TEMPLATE_FILE was
never introduced there (and is not in the manual), so I think that entry would
just cause confusion.
Also IMO you're not really changing, but rather fixing, an API here.

Adriaan

Moessbauer, Felix (T CED INW-CN) <felix.moessbauer@siemens.com>, Donnerstag, 9. Februar 2023 09:51
> This patch refactors the imagetypes_vm class for virtualbox and vmware
> images. The existing manual implementation does not work anymore when
> referencing ova config files across layers. Instead, we now use the
> imagetypes logic, which avoids the problematic changes of
> FILESEXTRAPATHS and SRC_URI.
> 
> Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
> ---
>  RECIPE-API-CHANGELOG.md                               | 10 ++++++++++
>  .../images/virtualbox}/vm-img-virtualbox.ovf.tmpl     |  0
>  .../images/vmware}/vm-img-vmware.ovf.tmpl             |  0
>  meta/classes/imagetypes_vm.bbclass                    | 11 ++++-------
>  4 files changed, 14 insertions(+), 7 deletions(-)
>  rename {meta/classes/vm-img => meta-isar/recipes-core/images/virtualbox}/vm-
> img-virtualbox.ovf.tmpl (100%)
>  rename {meta/classes/vm-img => meta-isar/recipes-core/images/vmware}/vm-img-
> vmware.ovf.tmpl (100%)
> 
> diff --git a/RECIPE-API-CHANGELOG.md b/RECIPE-API-CHANGELOG.md
> index e48c98c7..b66a4441 100644
> --- a/RECIPE-API-CHANGELOG.md
> +++ b/RECIPE-API-CHANGELOG.md
> @@ -476,3 +476,13 @@ Bitbake 2.0 for better performance. It also requires
> isar-sstate script to be
>  migrated to zstd.
>  Mixing old Gzip-based and new ZStandatd-based sstate cache is not
> recommended
>  and should be avoid for correct compatibility.
> +
> +### VM Image
> +
> +As a result of the Bitbake 2.0 migration, the vm image type has to be
> reworked:
> +Previously, a path to the `OVF_TEMPLATE_FILE` had to be somehow injected so
> +that the description file was located. This is now replaced by the imagetype
> +logic. By that, the `OVF_TEMPLATE_FILE` needs to be located in a directory
> +named according to the machine, next to the image file. If this is not
> possible
> +(e.g. in cross-layer scenarios), add the location to the FILESEXTRAPATHS of
> the
> +corresponding machine.conf.
> diff --git a/meta/classes/vm-img/vm-img-virtualbox.ovf.tmpl b/meta-
> isar/recipes-core/images/virtualbox/vm-img-virtualbox.ovf.tmpl
> similarity index 100%
> rename from meta/classes/vm-img/vm-img-virtualbox.ovf.tmpl
> rename to meta-isar/recipes-core/images/virtualbox/vm-img-virtualbox.ovf.tmpl
> diff --git a/meta/classes/vm-img/vm-img-vmware.ovf.tmpl b/meta-isar/recipes-
> core/images/vmware/vm-img-vmware.ovf.tmpl
> similarity index 100%
> rename from meta/classes/vm-img/vm-img-vmware.ovf.tmpl
> rename to meta-isar/recipes-core/images/vmware/vm-img-vmware.ovf.tmpl
> diff --git a/meta/classes/imagetypes_vm.bbclass
> b/meta/classes/imagetypes_vm.bbclass
> index 81ef866f..c52c96e5 100644
> --- a/meta/classes/imagetypes_vm.bbclass
> +++ b/meta/classes/imagetypes_vm.bbclass
> @@ -6,14 +6,11 @@
> 
>  inherit buildchroot
> 
> -USING_OVA = "${@bb.utils.contains('IMAGE_BASETYPES', 'ova', '1', '0', d)}"
> -
> -FILESEXTRAPATHS:prepend := "${LAYERDIR_core}/classes/vm-img:"
>  OVF_TEMPLATE_FILE ?= "vm-img-virtualbox.ovf.tmpl"
> -SRC_URI += "${@'file://${OVF_TEMPLATE_FILE}' if d.getVar('USING_OVA') == '1'
> else ''}"
> +IMAGE_SRC_URI:ova = "file://${OVF_TEMPLATE_FILE}"
> 
>  IMAGE_TYPEDEP:ova = "wic"
> -IMAGER_INSTALL:ova += "qemu-utils gawk uuid-runtime"
> +IMAGER_INSTALL:append:ova = " qemu-utils gawk uuid-runtime"
> 
>  # virtual machine disk settings
>  SOURCE_IMAGE_FILE ?= "${IMAGE_FULLNAME}.wic"
> @@ -67,8 +64,8 @@ OVA_VARS = "OVA_NAME OVA_MEMORY OVA_NUMBER_OF_CPU OVA_VRAM
> \
>              OVA_FIRMWARE OVA_ACPI OVA_3D_ACCEL \
>              OVA_SHA_ALG VIRTUAL_MACHINE_IMAGE_FILE"
> 
> -TEMPLATE_FILES += "${@'${OVF_TEMPLATE_FILE}' if d.getVar('USING_OVA') == '1'
> else ''}"
> -TEMPLATE_VARS += "${OVA_VARS}"
> +IMAGE_TEMPLATE_FILES:ova = "${OVF_TEMPLATE_FILE}"
> +IMAGE_TEMPLATE_VARS:ova = "${OVA_VARS}"
> 
>  do_image_ova[prefuncs] += "convert_wic"
>  IMAGE_CMD:ova() {
> --
> 2.34.1

Patch

diff --git a/RECIPE-API-CHANGELOG.md b/RECIPE-API-CHANGELOG.md
index e48c98c7..b66a4441 100644
--- a/RECIPE-API-CHANGELOG.md
+++ b/RECIPE-API-CHANGELOG.md
@@ -476,3 +476,13 @@  Bitbake 2.0 for better performance. It also requires isar-sstate script to be
 migrated to zstd.
 Mixing old Gzip-based and new ZStandatd-based sstate cache is not recommended
 and should be avoid for correct compatibility.
+
+### VM Image
+
+As a result of the Bitbake 2.0 migration, the vm image type has to be reworked:
+Previously, a path to the `OVF_TEMPLATE_FILE` had to be somehow injected so
+that the description file was located. This is now replaced by the imagetype
+logic. By that, the `OVF_TEMPLATE_FILE` needs to be located in a directory
+named according to the machine, next to the image file. If this is not possible
+(e.g. in cross-layer scenarios), add the location to the FILESEXTRAPATHS of the
+corresponding machine.conf.
diff --git a/meta/classes/vm-img/vm-img-virtualbox.ovf.tmpl b/meta-isar/recipes-core/images/virtualbox/vm-img-virtualbox.ovf.tmpl
similarity index 100%
rename from meta/classes/vm-img/vm-img-virtualbox.ovf.tmpl
rename to meta-isar/recipes-core/images/virtualbox/vm-img-virtualbox.ovf.tmpl
diff --git a/meta/classes/vm-img/vm-img-vmware.ovf.tmpl b/meta-isar/recipes-core/images/vmware/vm-img-vmware.ovf.tmpl
similarity index 100%
rename from meta/classes/vm-img/vm-img-vmware.ovf.tmpl
rename to meta-isar/recipes-core/images/vmware/vm-img-vmware.ovf.tmpl
diff --git a/meta/classes/imagetypes_vm.bbclass b/meta/classes/imagetypes_vm.bbclass
index 81ef866f..c52c96e5 100644
--- a/meta/classes/imagetypes_vm.bbclass
+++ b/meta/classes/imagetypes_vm.bbclass
@@ -6,14 +6,11 @@ 
 
 inherit buildchroot
 
-USING_OVA = "${@bb.utils.contains('IMAGE_BASETYPES', 'ova', '1', '0', d)}"
-
-FILESEXTRAPATHS:prepend := "${LAYERDIR_core}/classes/vm-img:"
 OVF_TEMPLATE_FILE ?= "vm-img-virtualbox.ovf.tmpl"
-SRC_URI += "${@'file://${OVF_TEMPLATE_FILE}' if d.getVar('USING_OVA') == '1' else ''}"
+IMAGE_SRC_URI:ova = "file://${OVF_TEMPLATE_FILE}"
 
 IMAGE_TYPEDEP:ova = "wic"
-IMAGER_INSTALL:ova += "qemu-utils gawk uuid-runtime"
+IMAGER_INSTALL:append:ova = " qemu-utils gawk uuid-runtime"
 
 # virtual machine disk settings
 SOURCE_IMAGE_FILE ?= "${IMAGE_FULLNAME}.wic"
@@ -67,8 +64,8 @@  OVA_VARS = "OVA_NAME OVA_MEMORY OVA_NUMBER_OF_CPU OVA_VRAM \
             OVA_FIRMWARE OVA_ACPI OVA_3D_ACCEL \
             OVA_SHA_ALG VIRTUAL_MACHINE_IMAGE_FILE"
 
-TEMPLATE_FILES += "${@'${OVF_TEMPLATE_FILE}' if d.getVar('USING_OVA') == '1' else ''}"
-TEMPLATE_VARS += "${OVA_VARS}"
+IMAGE_TEMPLATE_FILES:ova = "${OVF_TEMPLATE_FILE}"
+IMAGE_TEMPLATE_VARS:ova = "${OVA_VARS}"
 
 do_image_ova[prefuncs] += "convert_wic"
 IMAGE_CMD:ova() {