summaryrefslogtreecommitdiffstats
path: root/classes/qemuboot-testimage-network.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'classes/qemuboot-testimage-network.bbclass')
-rw-r--r--classes/qemuboot-testimage-network.bbclass36
1 files changed, 35 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;'