summaryrefslogtreecommitdiffstats
path: root/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc
diff options
context:
space:
mode:
authorSimon Rettberg2017-11-24 14:36:46 +0100
committerSimon Rettberg2017-11-24 14:36:46 +0100
commitd919efe86f80879848e1a43007680d3c92d7c40b (patch)
treed07d80fc2ef396e1605517be8408501e7152ff2b /core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc
parent[vmware*] Set up additional bridged vmnets if SLX_BRIDGE_OTHER_NICS is set (diff)
downloadmltk-d919efe86f80879848e1a43007680d3c92d7c40b.tar.gz
mltk-d919efe86f80879848e1a43007680d3c92d7c40b.tar.xz
mltk-d919efe86f80879848e1a43007680d3c92d7c40b.zip
[vmware*/run-virt] Implement NIC bridging
Implements #3109
Diffstat (limited to 'core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc')
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc15
1 files changed, 15 insertions, 0 deletions
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc
index 48a5cf3c..04f3b22e 100644
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc
+++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc
@@ -69,6 +69,7 @@ set_virt_memory() {
# Suffix template is taken from /opt/openslx/vmchooser/config/virtualization.conf
# and will have the VMID inserted as first byte.
set_virt_mac() {
+ local i mac byte
# First, determine prefix of the host's MAC address
isset HOSTMACADDR || writelog "Host's MAC address was not defined in ${VMCHOOSER_CONF_DIR}/virtualizer.conf"
isset MACADDRPREFIX || writelog "No MAC address prefix was defined in ${VMCHOOSER_CONF_DIR}/virtualizer.conf"
@@ -83,6 +84,20 @@ set_virt_mac() {
slxlog "virt-mac" "Could not properly generate mac address suffix (got $MACADDRSUFFIX)"
fi
declare -g VM_MAC_ADDR="$MACADDRPREFIX:$MACADDRSUFFIX"
+ declare -g OTHER_NICS=
+ # Set up additional NICs if enabled
+ if [ "$SLX_BRIDGE_OTHER_NICS" = "yes" ]; then
+ for i in /sys/class/net/br-nic-*/address; do
+ [ -s "$i" ] || continue
+ mac=$(tr '[a-f]' '[A-F]' < "$i")
+ # Calc checksum of mac by summing the bytes mod 256
+ byte=$(( $(<<<$mac sed 's/^/ ( 0x/;s/:/ + 0x/g;s/$/ ) % 256/') ))
+ byte=$(printf "%02X" "$byte")
+ # (PR:EF:IX):LA:ST:CH - use general prefix for VMs, then last two octets of source mac, plus the checksum
+ mac="${MACADDRPREFIX}:${mac:12:5}:${byte}"
+ OTHER_NICS+=" $mac"
+ done
+ fi
}
# Virtual fd/cd/dvd and drive devices, floppy b: for configuration