Skip to contentSkip to conversation

sanity-bbappend.bbclass: add class for bbappend files checking

PATCH Superseded Chen Qi 4 participants 9 messages Sep 25, 2017

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Chen Qi

author
#0 lore raw

PATCH v2 1/3 sanity-bbappend.bbclass: add class for bbappend files checking

Add a new class, sanity-bbappend.bbclass, to check for whether necessary settings are available for bbappend files in this layer to be effective, and warn users if not.

In addition, a variable SKIP_SANITY_BBAPPEND_CHECK is added to enable users to explicitly skip the checking to avoid unwanted warnings.

---
 classes/sanity-bbappend.bbclass | 10 ++++++++++
 conf/layer.conf                 |  4 ++++
 2 files changed, 14 insertions(+)
 create mode 100644 classes/sanity-bbappend.bbclass
classes/sanity-bbappend.bbclass new file +10 -0
new file mode 100644
index 0000000..bd2b717
@@ -0,0 +1,10 @@
+addhandler virt_bbappend_distrocheck
+virt_bbappend_distrocheck[eventmask] = "bb.event.ConfigParsed"
+python virt_bbappend_distrocheck() {
+    skip_check = e.data.getVar('SKIP_SANITY_BBAPPEND_CHECK') == "1"
+    if 'virtualization' not in e.data.getVar('DISTRO_FEATURES').split() and not skip_check:
+        bb.warn("You have included the meta-virtualization layer, but \
+'virtualization' has not been enabled in your DISTRO_FEATURES. Some bbappend files \
+may not take effect. See the meta-virtualization README for details on enabling \
+virtualization support.")
+}
conf/layer.conf +4 -0
index be08a98..341ad38 100644
@@ -22,3 +22,7 @@ require conf/distro/include/virt_security_flags.inc
 
 PREFERRED_PROVIDER_virtual/runc ?= "runc-docker"
 PREFERRED_PROVIDER_virtual/containerd ?= "containerd-docker"
+
+# Sanity check for application of bbappend files.
+# Setting SKIP_SANITY_BBAPPEND_CHECK to "1" would skip the check.
+INHERIT += "sanity-bbappend"
Signature · 1 line
2.11.0
author
#1 lore raw

PATCH v2 2/3 linux-yocto: make bbappend have effect conditionally

Make these bbappend files to take effect only when DISTRO_FEATURES contain 'virtualization'. Otherwise, we would meet failure failure at system booting up qemux86. Related logs are as below.

systemd-modules-load[113]: Failed to insert 'kvm_amd': Operation not supported systemd-modules-load[113]: Failed to insert 'kvm_intel': Operation not supported

---
 recipes-kernel/linux/linux-yocto_4.10.bbappend      | 21 +--------------------
 recipes-kernel/linux/linux-yocto_4.12.bbappend      | 21 +--------------------
 recipes-kernel/linux/linux-yocto_4.4.bbappend       | 21 +--------------------
 recipes-kernel/linux/linux-yocto_4.9.bbappend       | 21 +--------------------
 recipes-kernel/linux/linux-yocto_virtualization.inc | 20 ++++++++++++++++++++
 5 files changed, 24 insertions(+), 80 deletions(-)
 create mode 100644 recipes-kernel/linux/linux-yocto_virtualization.inc
recipes-kernel/linux/linux-yocto_4.10.bbappend +1 -20
index f163fdf..617cacc 100644
@@ -1,20 +1 @@
-FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
-
-SRC_URI += "file://xt-checksum.scc \
-            file://ebtables.scc \
-	    file://vswitch.scc \
-	    file://lxc.scc \
-            file://docker.scc \
-	    "
-KERNEL_FEATURES_append = " features/kvm/qemu-kvm-enable.scc"
-
-KERNEL_MODULE_AUTOLOAD += "openvswitch"
-KERNEL_MODULE_AUTOLOAD += "kvm"
-KERNEL_MODULE_AUTOLOAD += "kvm-amd"
-KERNEL_MODULE_AUTOLOAD += "kvm-intel"
-
-# aufs kernel support required for xen-image-minimal
-KERNEL_FEATURES_append += "${@bb.utils.contains('DISTRO_FEATURES', 'aufs', ' features/aufs/aufs-enable.scc', '', d)}"
-
-# xen kernel support
-SRC_URI += "${@bb.utils.contains('DISTRO_FEATURES', 'xen', ' file://xen.scc', '', d)}"
+require ${@bb.utils.contains('DISTRO_FEATURES', 'virtualization', '${BPN}_virtualization.inc', '', d)}
recipes-kernel/linux/linux-yocto_4.12.bbappend +1 -20
index f163fdf..617cacc 100644
@@ -1,20 +1 @@
-FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
-
-SRC_URI += "file://xt-checksum.scc \
-            file://ebtables.scc \
-	    file://vswitch.scc \
-	    file://lxc.scc \
-            file://docker.scc \
-	    "
-KERNEL_FEATURES_append = " features/kvm/qemu-kvm-enable.scc"
-
-KERNEL_MODULE_AUTOLOAD += "openvswitch"
-KERNEL_MODULE_AUTOLOAD += "kvm"
-KERNEL_MODULE_AUTOLOAD += "kvm-amd"
-KERNEL_MODULE_AUTOLOAD += "kvm-intel"
-
-# aufs kernel support required for xen-image-minimal
-KERNEL_FEATURES_append += "${@bb.utils.contains('DISTRO_FEATURES', 'aufs', ' features/aufs/aufs-enable.scc', '', d)}"
-
-# xen kernel support
-SRC_URI += "${@bb.utils.contains('DISTRO_FEATURES', 'xen', ' file://xen.scc', '', d)}"
+require ${@bb.utils.contains('DISTRO_FEATURES', 'virtualization', '${BPN}_virtualization.inc', '', d)}
recipes-kernel/linux/linux-yocto_4.4.bbappend +1 -20
index f163fdf..617cacc 100644
@@ -1,20 +1 @@
-FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
-
-SRC_URI += "file://xt-checksum.scc \
-            file://ebtables.scc \
-	    file://vswitch.scc \
-	    file://lxc.scc \
-            file://docker.scc \
-	    "
-KERNEL_FEATURES_append = " features/kvm/qemu-kvm-enable.scc"
-
-KERNEL_MODULE_AUTOLOAD += "openvswitch"
-KERNEL_MODULE_AUTOLOAD += "kvm"
-KERNEL_MODULE_AUTOLOAD += "kvm-amd"
-KERNEL_MODULE_AUTOLOAD += "kvm-intel"
-
-# aufs kernel support required for xen-image-minimal
-KERNEL_FEATURES_append += "${@bb.utils.contains('DISTRO_FEATURES', 'aufs', ' features/aufs/aufs-enable.scc', '', d)}"
-
-# xen kernel support
-SRC_URI += "${@bb.utils.contains('DISTRO_FEATURES', 'xen', ' file://xen.scc', '', d)}"
+require ${@bb.utils.contains('DISTRO_FEATURES', 'virtualization', '${BPN}_virtualization.inc', '', d)}
recipes-kernel/linux/linux-yocto_4.9.bbappend +1 -20
index f163fdf..617cacc 100644
@@ -1,20 +1 @@
-FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
-
-SRC_URI += "file://xt-checksum.scc \
-            file://ebtables.scc \
-	    file://vswitch.scc \
-	    file://lxc.scc \
-            file://docker.scc \
-	    "
-KERNEL_FEATURES_append = " features/kvm/qemu-kvm-enable.scc"
-
-KERNEL_MODULE_AUTOLOAD += "openvswitch"
-KERNEL_MODULE_AUTOLOAD += "kvm"
-KERNEL_MODULE_AUTOLOAD += "kvm-amd"
-KERNEL_MODULE_AUTOLOAD += "kvm-intel"
-
-# aufs kernel support required for xen-image-minimal
-KERNEL_FEATURES_append += "${@bb.utils.contains('DISTRO_FEATURES', 'aufs', ' features/aufs/aufs-enable.scc', '', d)}"
-
-# xen kernel support
-SRC_URI += "${@bb.utils.contains('DISTRO_FEATURES', 'xen', ' file://xen.scc', '', d)}"
+require ${@bb.utils.contains('DISTRO_FEATURES', 'virtualization', '${BPN}_virtualization.inc', '', d)}
recipes-kernel/linux/linux-yocto_virtualization.inc new file +20 -0
new file mode 100644
index 0000000..8b296d7
@@ -0,0 +1,20 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/linux-yocto:"
+
+SRC_URI += "file://xt-checksum.scc \
+            file://ebtables.scc \
+	    file://vswitch.scc \
+	    file://lxc.scc \
+            file://docker.scc \
+	    "
+KERNEL_FEATURES_append = " features/kvm/qemu-kvm-enable.scc"
+
+KERNEL_MODULE_AUTOLOAD += "openvswitch"
+KERNEL_MODULE_AUTOLOAD += "kvm"
+KERNEL_MODULE_AUTOLOAD += "kvm-amd"
+KERNEL_MODULE_AUTOLOAD += "kvm-intel"
+
+# aufs kernel support required for xen-image-minimal
+KERNEL_FEATURES_append += "${@bb.utils.contains('DISTRO_FEATURES', 'aufs', ' features/aufs/aufs-enable.scc', '', d)}"
+
+# xen kernel support
+SRC_URI += "${@bb.utils.contains('DISTRO_FEATURES', 'xen', ' file://xen.scc', '', d)}"
Signature · 1 line
2.11.0
author
#2 lore raw

PATCH v2 3/3 README: update to include information about bbappend inclusion

In reply to Chen Qi

Update README file to include information about bbappend file inclusion, telling the users that 'virtualization' needs to be in DISTRO_FEATURES to make some bbappend files to be effective.

---
 README | 5 +++++
 1 file changed, 5 insertions(+)
README +5 -0
index 2578f90..49fda10 100644
@@ -4,6 +4,11 @@ meta-virtualization
 This layer provides support for building Xen, KVM, Libvirt, and associated
 packages necessary for constructing OE-based virtualized solutions.
 
+The bbappend files for some recipe (e.g. linux-yocto) in this layer need to
+have 'virtualization' in DISTRO_FEATURES to have effect. To enable them, add
+in configuration file the following line.
+DISTRO_FEATURES_append = " virtualization"
+
 Dependencies
 ------------
 This layer depends on:
Signature · 1 line
2.11.0
#3 lore raw
In reply to Chen Qi
Quoted 6 lines · Chen Qi

Add a new class, sanity-bbappend.bbclass, to check for whether necessary
settings are available for bbappend files in this layer to be effective,
and warn users if not.

Quoted 7 lines

In addition, a variable SKIP_SANITY_BBAPPEND_CHECK is added to enable users
to explicitly skip the checking to avoid unwanted warnings.

---
 classes/sanity-bbappend.bbclass | 10 ++++++++++

That is a horrible name for a bbclass, could easily clash with another layer.

Quoted 3 lines

 conf/layer.conf                 |  4 ++++

 2 files changed, 14 insertions(+)

 create mode 100644 classes/sanity-bbappend.bbclass

Looking at this patch series, I suspect this is partly related to YP Compatibility v2.

I do think that its highlighting an issue here in that we have several very similar bbappends where the functionality would likely be better in a common file and secondly, better in the core recipes.

This layer would then just need to configure it rather than adding the config fragements and so on as well.

So yes, I think there is a valid issue here and in many senses, YP Compat v2 is probably highlighting a real problem but I suspect this patch series is not the way to fix it...

Is there a good reason we wouldn't want "virt" markup in the main recipes and it being a configuration option?

Cheers,

Richard

#5 lore raw
Quoted 4 lines · Rich Persaud

On Sep 25, 2017, at 06:40, Richard Purdie <richard.purdie@linuxfounda tion.org> wrote:
...

Quoted 1 line
Quoted 8 lines
Quoted 4 lines

So yes, I think there is a valid issue here and in many senses, YP Compat v2 is probably highlighting a real problem but I suspect this
patch series is not the way to fix it...

Are there docs on YP Compat v2?  A web search turned up this RFC:

https://lists.yoctoproject.org/pipermail/yocto/2017-February/034489.h
tml

There is the yocto-layer-check script which basically embodies the planned changes. I do need to write up a lot of the information but am struggling to find the time to do that the justice it needs...

Cheers,

Richard

#6 lore raw
In reply to Richard Purdie
Quoted 18 lines · Richard Purdie
Quoted 6 lines · Chen Qi

Add a new class, sanity-bbappend.bbclass, to check for whether necessary
settings are available for bbappend files in this layer to be effective,
and warn users if not.

Quoted 7 lines

In addition, a variable SKIP_SANITY_BBAPPEND_CHECK is added to enable users
to explicitly skip the checking to avoid unwanted warnings.

---
 classes/sanity-bbappend.bbclass | 10 ++++++++++

That is a horrible name for a bbclass, could easily clash with another layer.

Quoted 7 lines
Quoted 3 lines
 conf/layer.conf                 |  4 ++++
 2 files changed, 14 insertions(+)
 create mode 100644 classes/sanity-bbappend.bbclass

Looking at this patch series, I suspect this is partly related to YP Compatibility v2.

It is.

The first series arrived that created a magic distro variable 'virtualization'
that no one would know about, and have no idea how to use it .. as a result existing configurations would have a silent and drastic change on the behaviour.

I wasn't about to merge that change, so I suggested that if everything was to be triggered off a variable, that variable needed to be advertised by more
than just its use in the code, and more than a mention in a README.

That led to this first effort at making the new distro variable visible.

Quoted 8 lines

I do think that its highlighting an issue here in that we have several very similar bbappends where the functionality would likely be better in a common file and secondly, better in the core recipes.

This layer would then just need to configure it rather than adding the config fragements and so on as well.

Quoted 7 lines

So yes, I think there is a valid issue here and in many senses, YP Compat v2 is probably highlighting a real problem but I suspect this patch series is not the way to fix it...

Is there a good reason we wouldn't want "virt" markup in the main recipes and it being a configuration option?

I'm not following the configuration option 100%. Do you just mean setting 'virtualization' in distro features or some other similar configuration variable ? If that had to be manually done via distro or local.conf that would
leave my original concern outstanding.

Bruce

Quoted 12 lines

Cheers,

Richard

--
_______________________________________________
meta-virtualization mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/meta-virtualization

Signature · 2 lines
"Thou shalt not follow the NULL pointer, for chaos and madness await thee
at its end"
#7 lore raw
Quoted 40 lines · Bruce Ashfield
Quoted 7 lines · Richard Purdie

Quoted 3 lines

 conf/layer.conf                 |  4 ++++

 2 files changed, 14 insertions(+)

 create mode 100644 classes/sanity-bbappend.bbclass

Looking at this patch series, I suspect this is partly related to YP Compatibility v2.

It is.

The first series arrived that created a magic distro variable 'virtualization' that no one would know about, and have no idea how to use it .. as a result existing configurations would have a silent and drastic change on the behaviour.

I wasn't about to merge that change, so I suggested that if everything was to be triggered off a variable, that variable needed to be advertised by more than just its use in the code, and more than a mention in a README.

That led to this first effort at making the new distro variable visible.

Quoted 16 lines

I do think that its highlighting an issue here in that we have several
very similar bbappends where the functionality would likely be better
in a common file and secondly, better in the core recipes.

This layer would then just need to configure it rather than adding the
config fragements and so on as well.

So yes, I think there is a valid issue here and in many senses, YP Compat v2 is probably highlighting a real problem but I suspect this
patch series is not the way to fix it...

Quoted 7 lines
Quoted 2 lines

Is there a good reason we wouldn't want "virt" markup in the main recipes and it being a configuration option?

I'm not following the configuration option 100%. Do you just mean setting 'virtualization' in distro features or some other similar configuration variable ? If that had to be manually done via distro or local.conf that would leave my original concern outstanding.

I'll spell this out from the ground up since I know you understand this but I think others reading might not have thought about all of this quite as much.

One of the bigger problems we have today is that as you add layers, your build subtly changes and most users have any idea that it happens. This means sstate becomes invalid, things rebuild and people don't really understand or control what they're building.

In this case, changing the kernel to enable virtualisation when adding a virtualisation layer isn't totally unexpected but there are other cases which are more subtle and problematic. Even here, spelling it out as a configuration option which users (or distro) opt into is a good thing.

I'm fine with the warning in this patch series, that makes a lot of sense. The naming of the class is horrible IMO though.

What I am a little more worried about is that we have to bbappend recipes like linux-yocto. I have to ask the question, why not put the configuration markup into the upstream recipe?

There still may be something in meta-virt that warns if key configuration isn't enabled but the actual code that handles the option perhaps shouldn't be there now its established?

In new layers pushing the boundaries of technology with things that are rapidly changing, bbappends in layers make sense. In this case I have to wonder why we don't just put some configuration options in linux- yocto in OE-Core. Its not rapid changing, its well established and fairly universally useful.

We could consider whether it should be based on DISTRO_FEATURE or we whether we add 'PACKAGECONFIG' for the kernel?

Whilst there are easy ways to make the YP Compat tests pass, I do want us to think about what actually makes sense...

Cheers,

Richard

#8 lore raw
Quoted 58 lines · Richard Purdie
Quoted 40 lines · Bruce Ashfield
Quoted 7 lines · Richard Purdie
Quoted 4 lines
 conf/layer.conf                 |  4 ++++
 2 files changed, 14 insertions(+)
 create mode 100644 classes/sanity-bbappend.bbclass

Looking at this patch series, I suspect this is partly related to YP Compatibility v2.

It is.

The first series arrived that created a magic distro variable 'virtualization' that no one would know about, and have no idea how to use it .. as a result existing configurations would have a silent and drastic change on the behaviour.

I wasn't about to merge that change, so I suggested that if everything was to be triggered off a variable, that variable needed to be advertised by more than just its use in the code, and more than a mention in a README.

That led to this first effort at making the new distro variable visible.

Quoted 16 lines

I do think that its highlighting an issue here in that we have several
very similar bbappends where the functionality would likely be better
in a common file and secondly, better in the core recipes.

This layer would then just need to configure it rather than adding the
config fragements and so on as well.

So yes, I think there is a valid issue here and in many senses, YP Compat v2 is probably highlighting a real problem but I suspect this
patch series is not the way to fix it...

Quoted 7 lines
Quoted 2 lines

Is there a good reason we wouldn't want "virt" markup in the main recipes and it being a configuration option?

I'm not following the configuration option 100%. Do you just mean setting 'virtualization' in distro features or some other similar configuration variable ? If that had to be manually done via distro or local.conf that would leave my original concern outstanding.

I'll spell this out from the ground up since I know you understand this but I think others reading might not have thought about all of this quite as much.

One of the bigger problems we have today is that as you add layers, your build subtly changes and most users have any idea that it happens. This means sstate becomes invalid, things rebuild and people don't really understand or control what they're building.

Quoted 6 lines

In this case, changing the kernel to enable virtualisation when adding a virtualisation layer isn't totally unexpected but there are other cases which are more subtle and problematic. Even here, spelling it out as a configuration option which users (or distro) opt into is a good thing.

Agreed. I don't object to this being controlled by a variable, I object to a silent change to require that variable.

Quoted 4 lines

I'm fine with the warning in this patch series, that makes a lot of sense. The naming of the class is horrible IMO though.

I don't disagree on that point. A better namespace-safe name for the class could be used. As long as the functionality is there, I'm happy.

Quoted 5 lines

What I am a little more worried about is that we have to bbappend recipes like linux-yocto. I have to ask the question, why not put the configuration markup into the upstream recipe?

I'm not following on this one. You mean have the relevant recipes be able to inject changes that impact how the kernel is configured or built ? i.e. pkg-config or something similar ?

Quoted 11 lines

There still may be something in meta-virt that warns if key configuration isn't enabled but the actual code that handles the option perhaps shouldn't be there now its established?

In new layers pushing the boundaries of technology with things that are rapidly changing, bbappends in layers make sense. In this case I have to wonder why we don't just put some configuration options in linux- yocto in OE-Core. Its not rapid changing, its well established and fairly universally useful.

We've been using fragments to that end, and with my code that makes the fragments available to any kernel, that should help on this front.

Quoted 4 lines

We could consider whether it should be based on DISTRO_FEATURE or we whether we add 'PACKAGECONFIG' for the kernel?

I have lots of thoughts on this topic, but I want to understand before I head
off on a tangent. The kernel is a royal pain in this area given the drastic difference in capabilities, versions, h/w, etc. I have old bugzilla entries on this
topic, and have the first stage of code ready to make available early in the next release cycle.

Quoted 4 lines

Whilst there are easy ways to make the YP Compat tests pass, I do want us to think about what actually makes sense...

Agreed.

Bruce

Quoted 7 lines

Cheers,

Richard

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