mirror of
https://git.yoctoproject.org/meta-arm
synced 2026-06-03 13:50:11 +00:00
arm-autonomy: Create xenguest network bridge
Add a xenguest-network-bridge script to create a network bridge with the host interfaces. Add a xenguest init script to create a xen network interface connected to the bridge Add a network interfaces configuration file to have dhcp configuration on the network bridge Add xenguest-network-bridge to the default host image Add XENGUEST_IMAGE_NETWORK_BRIDGE parameter to xenguest-image to let user setup if a guest should be or not connected to the bridge Change-Id: Id15fde234386376e89c2562e1ffa935c51affa5b Issue-Id: SCM-767 Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com> Reviewed-by: Diego Sueiro <diego.sueiro@arm.com> Signed-off-by: Jon Mason <jon.mason@arm.com>
This commit is contained in:
committed by
Jon Mason
parent
16e4f7450e
commit
df189a806b
@@ -42,6 +42,7 @@ its documentation.
|
|||||||
Those documentation files should be checked for variables:
|
Those documentation files should be checked for variables:
|
||||||
- [xen-devicetree](documentation/xen-devicetree.md)
|
- [xen-devicetree](documentation/xen-devicetree.md)
|
||||||
- [xenguest-manager](documentation/xenguest-manager.md)
|
- [xenguest-manager](documentation/xenguest-manager.md)
|
||||||
|
- [xenguest-network-bridge](documentation/xenguest-network-bridge.md)
|
||||||
|
|
||||||
BSPs
|
BSPs
|
||||||
----
|
----
|
||||||
@@ -74,6 +75,10 @@ This layer is adding the following recipes and classes:
|
|||||||
* [xenguest-manager](documentation/xenguest-manager.md): this is a tool to
|
* [xenguest-manager](documentation/xenguest-manager.md): this is a tool to
|
||||||
create/remove/start/stop xen guest generated using xenguest-mkimage.
|
create/remove/start/stop xen guest generated using xenguest-mkimage.
|
||||||
|
|
||||||
|
* [xenguest-network-bridge](documentation/xenguest-network-bridge.md): this
|
||||||
|
recipe add tools and init scripts to create a bridge connected to the
|
||||||
|
external network on the host and allow guests to be connected to it.
|
||||||
|
|
||||||
Contributing
|
Contributing
|
||||||
------------
|
------------
|
||||||
This project has not put in place a process for contributions currently. If you
|
This project has not put in place a process for contributions currently. If you
|
||||||
|
|||||||
@@ -61,6 +61,11 @@ XENGUEST_IMAGE_DISK_SIZE ??= "${@ '4' if not d.getVar('INITRAMFS_IMAGE') else '0
|
|||||||
# and containing the root filesystem produced by Yocto
|
# and containing the root filesystem produced by Yocto
|
||||||
XENGUEST_IMAGE_DISK_PARTITIONS ??= "1:${XENGUEST_IMAGE_DISK_SIZE}:ext4:rootfs.tar.gz"
|
XENGUEST_IMAGE_DISK_PARTITIONS ??= "1:${XENGUEST_IMAGE_DISK_SIZE}:ext4:rootfs.tar.gz"
|
||||||
|
|
||||||
|
# XENGUEST_IMAGE_NETWORK_BRIDGE can be set to 1 to have a network interface
|
||||||
|
# on the guest connected to host bridged network. This will provide the guest
|
||||||
|
# with a network interface connected directly to the external network
|
||||||
|
XENGUEST_IMAGE_NETWORK_BRIDGE ??= "1"
|
||||||
|
|
||||||
# Sub-directory in wich the guest is created. This is create in deploy as a
|
# Sub-directory in wich the guest is created. This is create in deploy as a
|
||||||
# subdirectory and must be coherent between all components using this class so
|
# subdirectory and must be coherent between all components using this class so
|
||||||
# it must only be modified from local.conf if needed
|
# it must only be modified from local.conf if needed
|
||||||
@@ -144,6 +149,12 @@ xenguest_image_create() {
|
|||||||
else
|
else
|
||||||
call_xenguest_mkimage update --set-param=GUEST_AUTOBOOT=0
|
call_xenguest_mkimage update --set-param=GUEST_AUTOBOOT=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "${XENGUEST_IMAGE_NETWORK_BRIDGE}" = "1" ]; then
|
||||||
|
call_xenguest_mkimage update --set-param=NETWORK_BRIDGE=1
|
||||||
|
else
|
||||||
|
call_xenguest_mkimage update --set-param=NETWORK_BRIDGE=0
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
xenguest network bridge
|
||||||
|
=======================
|
||||||
|
|
||||||
|
Introduction
|
||||||
|
------------
|
||||||
|
|
||||||
|
xenguest-network-bridge is creating a network bridge to allow some guests to
|
||||||
|
have a direct connection to the external network.
|
||||||
|
To do this, a bridge is created on the host using brctl with the network
|
||||||
|
interfaces added to it so that the bridge is connected to the external network.
|
||||||
|
It is also adding a guest init script which will, for guests configured to use
|
||||||
|
it, create a virtual network interface for the guest and connect it to the
|
||||||
|
network bridge on the host.
|
||||||
|
|
||||||
|
Usage
|
||||||
|
-----
|
||||||
|
|
||||||
|
On the host the package xenguest-network-bridge must be included in your image.
|
||||||
|
|
||||||
|
On the xenguest image of your guest, the parameter NETWORK_BRIDGE must be set
|
||||||
|
to 1 (using xenguest-mkimage --set-param=NETWORK_BRIDGE=1).
|
||||||
|
|
||||||
|
Bitbake parameters
|
||||||
|
------------------
|
||||||
|
Several parameters are available to configure the xenguest network bridge
|
||||||
|
during Yocto project compilation (those can be set in your project local.conf,
|
||||||
|
for example).
|
||||||
|
|
||||||
|
The following parameters are available:
|
||||||
|
|
||||||
|
- XENGUEST_NETWORK_BRIDGE_NAME: This variable defines the name of the network
|
||||||
|
bridge that is created on the host during init.
|
||||||
|
This is set by default to "xenbr0".
|
||||||
|
|
||||||
|
- XENGUEST_NETWORK_BRIDGE_MEMBERS: This variable defines the list of network
|
||||||
|
interfaces that are added to the bridge when it is created on the host during
|
||||||
|
init.
|
||||||
|
This is set by default to "eth0".
|
||||||
|
|
||||||
|
- XENGUEST_NETWORK_BRIDGE_CONFIG: This variable defines the configuration file
|
||||||
|
to use to configure the bridge network. By default it points to have file
|
||||||
|
configuring the network using dhcp.
|
||||||
|
You can provide a different file using a bbappend and make this variable
|
||||||
|
point to it if you want to customize your network configuration.
|
||||||
|
|
||||||
|
- XENGUEST_IMAGE_NETWORK_BRIDGE: This variable can be set to 0 or 1 on guest
|
||||||
|
projects to enable or not the connection of the guest to the host bridge.
|
||||||
|
This is set by default to "1".
|
||||||
|
|
||||||
@@ -17,6 +17,7 @@ IMAGE_INSTALL += " \
|
|||||||
xen-base \
|
xen-base \
|
||||||
qemu \
|
qemu \
|
||||||
xenguest-manager \
|
xenguest-manager \
|
||||||
|
xenguest-network-bridge \
|
||||||
"
|
"
|
||||||
|
|
||||||
# Build xen-devicetree to produce a xen ready devicetree
|
# Build xen-devicetree to produce a xen ready devicetree
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# This script is setting up a virtual network interface connected to the
|
||||||
|
# xenguest-network-bridge if NETWORK_BRIDGE is set to 1 in the guest params
|
||||||
|
|
||||||
|
guestname="${1}"
|
||||||
|
|
||||||
|
BRIDGE_NAME="###BRIDGE_NAME###"
|
||||||
|
|
||||||
|
# get guest parameters
|
||||||
|
. ./params.cfg
|
||||||
|
|
||||||
|
if [ "${NETWORK_BRIDGE:-}" = "1" ]; then
|
||||||
|
echo "vif = ['${BRIDGE_NAME}']" >> ${guestname}.cfg
|
||||||
|
fi
|
||||||
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# Xenguest Network Bridge interface configuration
|
||||||
|
auto ###BRIDGE_NAME###
|
||||||
|
iface ###BRIDGE_NAME### inet dhcp
|
||||||
+44
@@ -0,0 +1,44 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Xenguest Network Bridge init
|
||||||
|
# This script creates a network bridge and add host interfaces to it
|
||||||
|
# It will then be used by xen guests to connect to the external nework
|
||||||
|
#
|
||||||
|
|
||||||
|
INTFS="###BRIDGE_MEMBERS###"
|
||||||
|
BR_INTF="###BRIDGE_NAME###"
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
echo "Starting $BR_INTF"
|
||||||
|
brctl addbr $BR_INTF
|
||||||
|
for intf in $INTFS; do
|
||||||
|
echo "Adding $intf to $BR_INTF"
|
||||||
|
brctl addif $BR_INTF $intf
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
status)
|
||||||
|
true
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
echo "Stopping $BR_INTF"
|
||||||
|
ifdown $BR_INTF
|
||||||
|
brctl delbr $BR_INTF
|
||||||
|
;;
|
||||||
|
reload)
|
||||||
|
echo >&2 'Reload not available; use force-reload'; exit 1
|
||||||
|
;;
|
||||||
|
force-reload|restart)
|
||||||
|
echo "Restarting host-bridge"
|
||||||
|
$0 stop
|
||||||
|
$0 start
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# do not advertise unreasonable commands that there is no reason
|
||||||
|
# to use with this device
|
||||||
|
echo $"Usage: $0 {start|stop|status|restart|force-reload}"
|
||||||
|
exit 1
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit $?
|
||||||
|
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
# Recipe to handle xenguest network configuration
|
||||||
|
DESCRIPTION = "XenGuest Network Bridge"
|
||||||
|
|
||||||
|
LICENSE = "MIT"
|
||||||
|
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
|
||||||
|
|
||||||
|
S = "${WORKDIR}"
|
||||||
|
|
||||||
|
# Please refer to documentation/xenguest-network-bridge.md for documentation on
|
||||||
|
# those parameters
|
||||||
|
XENGUEST_NETWORK_BRIDGE_NAME ?= "xenbr0"
|
||||||
|
XENGUEST_NETWORK_BRIDGE_MEMBERS ?= "eth0"
|
||||||
|
XENGUEST_NETWORK_BRIDGE_CONFIG ?= "xenguest-network-bridge-dhcp.cfg.in"
|
||||||
|
|
||||||
|
SRC_URI = " \
|
||||||
|
file://xenguest-network-bridge.in \
|
||||||
|
file://xenguest-network-bridge-dhcp.cfg.in \
|
||||||
|
file://network-bridge.sh.in \
|
||||||
|
"
|
||||||
|
|
||||||
|
# Bridge configurator needs to run before S01networking init script
|
||||||
|
# Prefix with a_ to make sure it is executed in runlevel 01 before others
|
||||||
|
INITSCRIPT_NAME = "a_xenguest-network-bridge"
|
||||||
|
INITSCRIPT_PARAMS = "defaults 01"
|
||||||
|
|
||||||
|
inherit update-rc.d
|
||||||
|
|
||||||
|
do_install() {
|
||||||
|
cat ${WORKDIR}/xenguest-network-bridge.in \
|
||||||
|
| sed -e "s,###BRIDGE_MEMBERS###,${XENGUEST_NETWORK_BRIDGE_MEMBERS}," \
|
||||||
|
| sed -e "s,###BRIDGE_NAME###,${XENGUEST_NETWORK_BRIDGE_NAME}," \
|
||||||
|
> ${WORKDIR}/xenguest-network-bridge
|
||||||
|
cat ${WORKDIR}/${XENGUEST_NETWORK_BRIDGE_CONFIG} \
|
||||||
|
| sed -e "s,###BRIDGE_NAME###,${XENGUEST_NETWORK_BRIDGE_NAME}," \
|
||||||
|
> ${WORKDIR}/xenguest-network-bridge.cfg
|
||||||
|
cat ${WORKDIR}/network-bridge.sh.in \
|
||||||
|
| sed -e "s,###BRIDGE_NAME###,${XENGUEST_NETWORK_BRIDGE_NAME}," \
|
||||||
|
> ${WORKDIR}/network-bridge.sh
|
||||||
|
install -d -m 755 ${D}${sysconfdir}/init.d
|
||||||
|
install -m 755 ${WORKDIR}/xenguest-network-bridge \
|
||||||
|
${D}${sysconfdir}/init.d/${INITSCRIPT_NAME}
|
||||||
|
install -d -m 755 ${D}${sysconfdir}/network/interfaces.d
|
||||||
|
install -m 755 ${WORKDIR}/xenguest-network-bridge.cfg \
|
||||||
|
${D}${sysconfdir}/network/interfaces.d/.
|
||||||
|
install -d -m 755 ${D}${sysconfdir}/xenguest/init.pre
|
||||||
|
install -m 755 ${WORKDIR}/network-bridge.sh \
|
||||||
|
${D}${sysconfdir}/xenguest/init.pre/.
|
||||||
|
}
|
||||||
|
|
||||||
|
RDEPENDS_${PN} += "bridge-utils"
|
||||||
|
FILES_${PN} += "${sysconfdir}/network/interfaces.d/xenguest-network-bridge.cfg"
|
||||||
|
FILES_${PN} += "${sysconfdir}/xenguest/init.pre/network-bridge.sh"
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
# Juno board has 2 network interfaces, add both of them to the bridge
|
||||||
|
XENGUEST_NETWORK_BRIDGE_MEMBERS_juno ?= "eth0 eth1"
|
||||||
Reference in New Issue
Block a user