summaryrefslogtreecommitdiffstats
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-09 08:08:31 -0400
commitd7a2d1b7ab94f7ac8e882ab66810d80e686cb62c (patch)
treebdbe2687a62ad69bc61e15c5d5cf72bf62fb811c
parent1c746a976830ebaf85c7c8c25612bea349b0a7c5 (diff)
downloadmeta-virtualization-d7a2d1b7ab94f7ac8e882ab66810d80e686cb62c.tar.gz
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 18af1eea..57e03551 100644
--- a/classes/qemuboot-testimage-network.bbclass
+++ b/classes/qemuboot-testimage-network.bbclass
@@ -1,17 +1,51 @@
1# The recipe for init-ifupdown in core has a special-case for all 1# The recipe for init-ifupdown in core has a special-case for all
2# the Qemu MACHINES: it removes all external network interfaces 2# the Qemu MACHINES: it removes all external network interfaces
3# by default. However, eth0 is needed for testimage, so enable it here. 3# by default. However, eth0 is needed for testimage, so enable it here.
4
5# If QB_NETWORK_XEN_BRIDGE is set, configure bridging for the network.
6QB_NETWORK_XEN_BRIDGE ??= ""
7
4enable_runqemu_network() { 8enable_runqemu_network() {
5 : # no-op for non-qemu MACHINES 9 : # no-op for non-qemu MACHINES
6} 10}
11
7enable_runqemu_network:qemuall() { 12enable_runqemu_network:qemuall() {
13 # Do not override a network configuration for eth0 if one is present
8 if ! grep -q eth0 "${IMAGE_ROOTFS}${sysconfdir}/network/interfaces" ; then 14 if ! grep -q eth0 "${IMAGE_ROOTFS}${sysconfdir}/network/interfaces" ; then
9 cat <<EOF >>${IMAGE_ROOTFS}${sysconfdir}/network/interfaces 15
16 # Xen host networking: use bridging to support guest networks
17 if [ -n "${QB_NETWORK_XEN_BRIDGE}" ] ; then
18 # Configure a Xen host network bridge and put eth0 on it
19 cat <<EOF >>${IMAGE_ROOTFS}${sysconfdir}/network/interfaces
20
21# Bridged host network for Xen testimage
22iface eth0 inet manual
23
24auto xenbr0
25iface xenbr0 inet dhcp
26 bridge_ports eth0
27EOF
28
29# Add a script to create the bridge and add eth0 if necessary
30 cat <<EOF >>${IMAGE_ROOTFS}${sysconfdir}/network/if-pre-up.d/xenbr0
31#!/bin/sh
32
33if [ "\$IFACE" = xenbr0 ]; then
34 brctl addbr xenbr0 || /bin/true
35 brctl addif xenbr0 eth0 || /bin/true
36 ifconfig eth0 up
37fi
38EOF
39 chmod 755 ${IMAGE_ROOTFS}${sysconfdir}/network/if-pre-up.d/xenbr0
40 else
41 # Just configure eth0
42 cat <<EOF >>${IMAGE_ROOTFS}${sysconfdir}/network/interfaces
10 43
11# Network for testimage 44# Network for testimage
12auto eth0 45auto eth0
13iface eth0 inet dhcp 46iface eth0 inet dhcp
14EOF 47EOF
48 fi
15 fi 49 fi
16} 50}
17ROOTFS_POSTPROCESS_COMMAND += 'enable_runqemu_network;' 51ROOTFS_POSTPROCESS_COMMAND += 'enable_runqemu_network;'
diff --git a/recipes-extended/images/xen-image-minimal.bb b/recipes-extended/images/xen-image-minimal.bb
index 9b7f4150..dd5b39d8 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"
34 34
35LICENSE = "MIT" 35LICENSE = "MIT"
36 36
37QB_NETWORK_XEN_BRIDGE = "1"
38
37inherit core-image 39inherit core-image
38# Only inherit the qemuboot classes when building for a qemu machine 40# Only inherit the qemuboot classes when building for a qemu machine
39QB_QEMU_CLASSES = "" 41QB_QEMU_CLASSES = ""