diff options
author | Christopher Clark <christopher.w.clark@gmail.com> | 2022-04-27 17:06:09 -0700 |
---|---|---|
committer | Bruce Ashfield <bruce.ashfield@gmail.com> | 2022-05-09 08:08:31 -0400 |
commit | d7a2d1b7ab94f7ac8e882ab66810d80e686cb62c (patch) | |
tree | bdbe2687a62ad69bc61e15c5d5cf72bf62fb811c | |
parent | 1c746a976830ebaf85c7c8c25612bea349b0a7c5 (diff) | |
download | meta-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.bbclass | 36 | ||||
-rw-r--r-- | recipes-extended/images/xen-image-minimal.bb | 2 |
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. | ||
6 | QB_NETWORK_XEN_BRIDGE ??= "" | ||
7 | |||
4 | enable_runqemu_network() { | 8 | enable_runqemu_network() { |
5 | : # no-op for non-qemu MACHINES | 9 | : # no-op for non-qemu MACHINES |
6 | } | 10 | } |
11 | |||
7 | enable_runqemu_network:qemuall() { | 12 | enable_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 | ||
22 | iface eth0 inet manual | ||
23 | |||
24 | auto xenbr0 | ||
25 | iface xenbr0 inet dhcp | ||
26 | bridge_ports eth0 | ||
27 | EOF | ||
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 | |||
33 | if [ "\$IFACE" = xenbr0 ]; then | ||
34 | brctl addbr xenbr0 || /bin/true | ||
35 | brctl addif xenbr0 eth0 || /bin/true | ||
36 | ifconfig eth0 up | ||
37 | fi | ||
38 | EOF | ||
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 |
12 | auto eth0 | 45 | auto eth0 |
13 | iface eth0 inet dhcp | 46 | iface eth0 inet dhcp |
14 | EOF | 47 | EOF |
48 | fi | ||
15 | fi | 49 | fi |
16 | } | 50 | } |
17 | ROOTFS_POSTPROCESS_COMMAND += 'enable_runqemu_network;' | 51 | 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 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 | ||
35 | LICENSE = "MIT" | 35 | LICENSE = "MIT" |
36 | 36 | ||
37 | QB_NETWORK_XEN_BRIDGE = "1" | ||
38 | |||
37 | inherit core-image | 39 | inherit 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 |
39 | QB_QEMU_CLASSES = "" | 41 | QB_QEMU_CLASSES = "" |