aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Clark <christopher.w.clark@gmail.com>2022-04-27 17:06:09 -0700
committerBruce Ashfield <bruce.ashfield@gmail.com>2022-05-18 13:56:43 -0400
commitc988514f4acbd2e8a61a53a16f1eea2d45729b74 (patch)
treebdbe2687a62ad69bc61e15c5d5cf72bf62fb811c
parentbf4f18a0b75ab5111c9990d531ad9a48b3ae0957 (diff)
downloadmeta-virtualization-c988514f4acbd2e8a61a53a16f1eea2d45729b74.tar.gz
meta-virtualization-c988514f4acbd2e8a61a53a16f1eea2d45729b74.tar.bz2
meta-virtualization-c988514f4acbd2e8a61a53a16f1eea2d45729b74.zip
xen images, qemuboot: configure xenbr0 bridge for runqemu, testimage
Networking for Xen guest virtual machines is commonly configured via bridging in the host system between a physical interface and the guest virtual interfaces. To make it easier to test networking and use testimage with Xen guest virtual machines, extend the bbclass that provides network configuration for qemu machines for the Xen images to configure a Xen bridge and put eth0 onto it when QB_XEN_HOST_BRIDGE is set. Signed-off-by: Christopher Clark <christopher.clark@starlab.io> Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
-rw-r--r--classes/qemuboot-testimage-network.bbclass36
-rw-r--r--recipes-extended/images/xen-image-minimal.bb2
2 files changed, 37 insertions, 1 deletions
diff --git a/classes/qemuboot-testimage-network.bbclass b/classes/qemuboot-testimage-network.bbclass
index 18af1ee..57e0355 100644
--- a/classes/qemuboot-testimage-network.bbclass
+++ b/classes/qemuboot-testimage-network.bbclass
@@ -1,17 +1,51 @@
# The recipe for init-ifupdown in core has a special-case for all
# the Qemu MACHINES: it removes all external network interfaces
# by default. However, eth0 is needed for testimage, so enable it here.
+
+# If QB_NETWORK_XEN_BRIDGE is set, configure bridging for the network.
+QB_NETWORK_XEN_BRIDGE ??= ""
+
enable_runqemu_network() {
: # no-op for non-qemu MACHINES
}
+
enable_runqemu_network:qemuall() {
+ # Do not override a network configuration for eth0 if one is present
if ! grep -q eth0 "${IMAGE_ROOTFS}${sysconfdir}/network/interfaces" ; then
- cat <<EOF >>${IMAGE_ROOTFS}${sysconfdir}/network/interfaces
+
+ # Xen host networking: use bridging to support guest networks
+ if [ -n "${QB_NETWORK_XEN_BRIDGE}" ] ; then
+ # Configure a Xen host network bridge and put eth0 on it
+ cat <<EOF >>${IMAGE_ROOTFS}${sysconfdir}/network/interfaces
+
+# Bridged host network for Xen testimage
+iface eth0 inet manual
+
+auto xenbr0
+iface xenbr0 inet dhcp
+ bridge_ports eth0
+EOF
+
+# Add a script to create the bridge and add eth0 if necessary
+ cat <<EOF >>${IMAGE_ROOTFS}${sysconfdir}/network/if-pre-up.d/xenbr0
+#!/bin/sh
+
+if [ "\$IFACE" = xenbr0 ]; then
+ brctl addbr xenbr0 || /bin/true
+ brctl addif xenbr0 eth0 || /bin/true
+ ifconfig eth0 up
+fi
+EOF
+ chmod 755 ${IMAGE_ROOTFS}${sysconfdir}/network/if-pre-up.d/xenbr0
+ else
+ # Just configure eth0
+ cat <<EOF >>${IMAGE_ROOTFS}${sysconfdir}/network/interfaces
# Network for testimage
auto eth0
iface eth0 inet dhcp
EOF
+ fi
fi
}
ROOTFS_POSTPROCESS_COMMAND += 'enable_runqemu_network;'
diff --git a/recipes-extended/images/xen-image-minimal.bb b/recipes-extended/images/xen-image-minimal.bb
index 9b7f415..dd5b39d 100644
--- a/recipes-extended/images/xen-image-minimal.bb
+++ b/recipes-extended/images/xen-image-minimal.bb
@@ -34,6 +34,8 @@ XEN_ACPI_PROCESSOR_MODULE:x86-64 = "kernel-module-xen-acpi-processor"
LICENSE = "MIT"
+QB_NETWORK_XEN_BRIDGE = "1"
+
inherit core-image
# Only inherit the qemuboot classes when building for a qemu machine
QB_QEMU_CLASSES = ""