Skip to contentSkip to conversation

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

PATCH In review Chen Qi 4 participants 8 messages Sep 30, 2017 – Oct 12, 2017

lore
Share & tools
lore

Chen Qi

author
#0 lore raw

PATCH v4 1/3 sanity-meta-virt.bbclass: add class for bbappend files checking

Add a new class, sanity-meta-virt.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-meta-virt.bbclass | 10 ++++++++++
 conf/layer.conf                  |  4 ++++
 2 files changed, 14 insertions(+)
 create mode 100644 classes/sanity-meta-virt.bbclass
classes/sanity-meta-virt.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..51ca8ee 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 meta-virtualization layer.
+# Setting SKIP_SANITY_BBAPPEND_CHECK to "1" would skip the bbappend files check.
+INHERIT += "sanity-meta-virt"
Signature · 1 line
2.11.0
author
#1 lore raw

PATCH v4 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

Also, make kvm related settings depend on the 'kvm' distro feature.

---
 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..9905ed9
@@ -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 = " ${@bb.utils.contains('DISTRO_FEATURES', 'kvm', 'features/kvm/qemu-kvm-enable.scc', '', d)}"
+
+KERNEL_MODULE_AUTOLOAD += "openvswitch"
+KERNEL_MODULE_AUTOLOAD += "${@bb.utils.contains('DISTRO_FEATURES', 'kvm', 'kvm', '', d)}"
+KERNEL_MODULE_AUTOLOAD += "${@bb.utils.contains('DISTRO_FEATURES', 'kvm', 'kvm-amd', '', d)}"
+KERNEL_MODULE_AUTOLOAD += "${@bb.utils.contains('DISTRO_FEATURES', 'kvm', 'kvm-intel', '', d)}"
+
+# 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 v4 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

v4 is merged.

Bruce

Quoted 50 lines · Chen Qi

Add a new class, sanity-meta-virt.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-meta-virt.bbclass | 10 ++++++++++
 conf/layer.conf                  |  4 ++++
 2 files changed, 14 insertions(+)
 create mode 100644 classes/sanity-meta-virt.bbclass
classes/sanity-meta-virt.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 -1
index be08a98..51ca8ee 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 meta-virtualization layer.
+# Setting SKIP_SANITY_BBAPPEND_CHECK to "1" would skip the bbappend files check.
+INHERIT += "sanity-meta-virt"
--

2.11.0

--
_______________________________________________
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"
#4 lore raw
Quoted 41 lines · Bruce Ashfield

v4 is merged.

Bruce

Quoted 36 lines · Chen Qi

Add a new class, sanity-meta-virt.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-meta-virt.bbclass | 10 ++++++++++
 conf/layer.conf                  |  4 ++++
 2 files changed, 14 insertions(+)
 create mode 100644 classes/sanity-meta-virt.bbclass
classes/sanity-meta-virt.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 +0 -0
index be08a98..51ca8ee 100644
@@ -22,3 +22,7 @@ require conf/distro/include/virt_security_flags.inc
 
Quoted 9 lines
Quoted 9 lines
conf/layer.conf +4 -1
 PREFERRED_PROVIDER_virtual/runc ?= "runc-docker"
 PREFERRED_PROVIDER_virtual/containerd ?= "containerd-docker"
+
+# Sanity check for meta-virtualization layer.
+# Setting SKIP_SANITY_BBAPPEND_CHECK to "1" would skip the bbappend files check.
+INHERIT += "sanity-meta-virt"
--

2.11.0

I'm getting this new warning up to 4 times on each bitbake invocation:
twice before the "Parsing recipes" line, once after the "Executing SetScene Tasks" line (if present) and once after the "Executing RunQueue Tasks" line.

It's also totally irrelevant for users of a distro like ours (Oryx Linux) which includes meta-virtualization for runc, docker or other related tools but doesn't use kvm or xen.

I guess I can set SKIP_SANITY_BBAPPEND_CHECK in our distro config but this sounds like a universal skip for all sanity bbappend checks - is this intended? Or does this variable just apply to the check in this layer? If it's specific to this layer I think it needs a better name.

Thanks,

Signature · 2 lines
Paul Barker
Togán Labs Ltd
#5 lore raw
Quoted 42 lines · Paul Barker
Quoted 41 lines · Bruce Ashfield

v4 is merged.

Bruce

Quoted 36 lines · Chen Qi

Add a new class, sanity-meta-virt.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-meta-virt.bbclass | 10 ++++++++++
 conf/layer.conf                  |  4 ++++
 2 files changed, 14 insertions(+)
 create mode 100644 classes/sanity-meta-virt.bbclass
classes/sanity-meta-virt.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 +0 -0
index be08a98..51ca8ee 100644
@@ -22,3 +22,7 @@ require conf/distro/include/virt_security_flags.inc
 
Quoted 14 lines
Quoted 9 lines
Quoted 9 lines
conf/layer.conf +4 -1
 PREFERRED_PROVIDER_virtual/runc ?= "runc-docker"
 PREFERRED_PROVIDER_virtual/containerd ?= "containerd-docker"
+
+# Sanity check for meta-virtualization layer.
+# Setting SKIP_SANITY_BBAPPEND_CHECK to "1" would skip the bbappend files check.
+INHERIT += "sanity-meta-virt"
--

2.11.0

I'm getting this new warning up to 4 times on each bitbake invocation:
twice before the "Parsing recipes" line, once after the "Executing SetScene Tasks" line (if present) and once after the "Executing RunQueue Tasks" line.

Multiple times should get fixed. This can be done by setting a value in the event handler that the message has already been printed.

d.setVar('SKIP_SANITY_BBAPPEND_CHECK', '1')

...

--Mark

Quoted 11 lines

It's also totally irrelevant for users of a distro like ours (Oryx Linux) which includes meta-virtualization for runc, docker or other related tools but doesn't use kvm or xen.

I guess I can set SKIP_SANITY_BBAPPEND_CHECK in our distro config but this sounds like a universal skip for all sanity bbappend checks - is this intended? Or does this variable just apply to the check in this layer? If it's specific to this layer I think it needs a better name.

Thanks,

#6 lore raw
In reply to Paul Barker
Quoted 57 lines · Paul Barker
Quoted 41 lines · Bruce Ashfield

v4 is merged.

Bruce

Quoted 36 lines · Chen Qi

Add a new class, sanity-meta-virt.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-meta-virt.bbclass | 10 ++++++++++
 conf/layer.conf                  |  4 ++++
 2 files changed, 14 insertions(+)
 create mode 100644 classes/sanity-meta-virt.bbclass
classes/sanity-meta-virt.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 +0 -0
index be08a98..51ca8ee 100644
@@ -22,3 +22,7 @@ require conf/distro/include/virt_security_flags.inc
 
Quoted 9 lines
Quoted 9 lines
conf/layer.conf +4 -1
 PREFERRED_PROVIDER_virtual/runc ?= "runc-docker"
 PREFERRED_PROVIDER_virtual/containerd ?= "containerd-docker"
+
+# Sanity check for meta-virtualization layer.
+# Setting SKIP_SANITY_BBAPPEND_CHECK to "1" would skip the bbappend files check.
+INHERIT += "sanity-meta-virt"
--

2.11.0

I'm getting this new warning up to 4 times on each bitbake invocation:
twice before the "Parsing recipes" line, once after the "Executing SetScene Tasks" line (if present) and once after the "Executing RunQueue Tasks" line.

Quoted 8 lines

It's also totally irrelevant for users of a distro like ours (Oryx Linux) which includes meta-virtualization for runc, docker or other related tools but doesn't use kvm or xen.

I guess I can set SKIP_SANITY_BBAPPEND_CHECK in our distro config but this sounds like a universal skip for all sanity bbappend checks - is this intended? Or does this variable just apply to the check in this layer? If it's specific to this layer I think it needs a better name.

Fire off a patch to make the name more specific and I'll merge it right away.

I'm actively testing some other things, and have the distro flags set, so I'd like a patch
from someone that was seeing the warning, and can confirm that we can actually disable it.

Cheers,

Bruce

Quoted 6 lines

Thanks,

--
Paul Barker
Togán Labs Ltd

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

I'm getting this new warning up to 4 times on each bitbake invocation:
twice before the "Parsing recipes" line, once after the "Executing SetScene Tasks" line (if present) and once after the "Executing RunQueue Tasks" line.

Quoted 8 lines

It's also totally irrelevant for users of a distro like ours (Oryx Linux) which includes meta-virtualization for runc, docker or other related tools but doesn't use kvm or xen.

I guess I can set SKIP_SANITY_BBAPPEND_CHECK in our distro config but this sounds like a universal skip for all sanity bbappend checks - is this intended? Or does this variable just apply to the check in this layer? If it's specific to this layer I think it needs a better name.

Quoted 7 lines

Fire off a patch to make the name more specific and I'll merge it right away.

I'm actively testing some other things, and have the distro flags set, so I'd like a patch
from someone that was seeing the warning, and can confirm that we can actually disable it.

Patch incoming as soon as my current builds are done :)

Signature · 2 lines
Paul Barker
Togán Labs Ltd