diff options
Diffstat (limited to 'classes/qemuboot-testimage-network.bbclass')
-rw-r--r-- | classes/qemuboot-testimage-network.bbclass | 36 |
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. | ||
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;' |