summaryrefslogtreecommitdiffstats
path: root/core/modules/vmware12
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/vmware12
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/vmware12')
-rwxr-xr-xcore/modules/vmware12/data/opt/openslx/scripts/systemd-vmware_env5
-rw-r--r--core/modules/vmware12/data/opt/openslx/vmchooser/plugins/vmware/includes/write_final_vmx.inc32
2 files changed, 35 insertions, 2 deletions
diff --git a/core/modules/vmware12/data/opt/openslx/scripts/systemd-vmware_env b/core/modules/vmware12/data/opt/openslx/scripts/systemd-vmware_env
index 0c0e5966..4e381bf0 100755
--- a/core/modules/vmware12/data/opt/openslx/scripts/systemd-vmware_env
+++ b/core/modules/vmware12/data/opt/openslx/scripts/systemd-vmware_env
@@ -67,18 +67,19 @@ vmnetif () {
brctl addif vsw2 vmnet2
# 2) see if we should bridge additional interfaces
NICS=
- if [ "$SLX_BRIDGE_OTHER_NICS" = "ON" ]; then
+ if [ "$SLX_BRIDGE_OTHER_NICS" = "yes" ]; then
# These will have been set up in our init
NICS=$( ls -1 /sys/class/net | grep '^br-nic-' | cut -c 8- )
+ vmnet=10
for nic in $NICS; do
if ! [ "$nic" -gt 0 ] && ! [ "$nic" -eq 0 ]; then
slxlog "vmware-other-nics" "NaN: br-nic-X has X='$nic'"
continue
fi
# create vmnet10 - vmnetN for these
- vmnet="$(( nic + 10 ))"
vmnet_create "$vmnet"
brctl addif "br-nic-${nic}" "vmnet${vmnet}"
+ vmnet="$(( vmnet + 1 ))"
done
fi
diff --git a/core/modules/vmware12/data/opt/openslx/vmchooser/plugins/vmware/includes/write_final_vmx.inc b/core/modules/vmware12/data/opt/openslx/vmchooser/plugins/vmware/includes/write_final_vmx.inc
index a431560f..8bc6cb3d 100644
--- a/core/modules/vmware12/data/opt/openslx/vmchooser/plugins/vmware/includes/write_final_vmx.inc
+++ b/core/modules/vmware12/data/opt/openslx/vmchooser/plugins/vmware/includes/write_final_vmx.inc
@@ -22,6 +22,38 @@ replace_placeholders() {
setup_ethernet() {
echo 'ethernet0.addressType = "static"' >> "${TMPCONFIG}"
echo 'ethernet0.address = "'"${VM_MAC_ADDR}"'"' >> "${TMPCONFIG}"
+ if [ -n "$OTHER_NICS" ]; then
+ local devtype mac cnt eth
+ # Copy type of eth0, in case the others don't specify a type in the vmx, we'll use the same
+ # so we know the drivers are there
+ devtype=$(grep -m1 -i '^ethernet0\.virtualDev' | sed -r 's/^[^=]+//;s/^(\s|=|")*//;s/(\s|")+$//') # TODO: Make a helper like "getVmxOption"
+ cnt=0
+ for mac in $OTHER_NICS; do
+ vmnet=$(( cnt + 10 ))
+ cnt=$(( cnt + 1 ))
+ eth="ethernet${cnt}"
+ # Check device exists
+ if ! [ -c "/dev/vmnet${vmnet}" ]; then
+ slxlog "vmware-bridge-setup" "Cannot bridge NIC into VM: /dev/vmnet${vmnet} does not exist"
+ continue
+ fi
+ # Remove lines that could break things
+ sed -i "/^${eth}\.connectionType/Id;/^${eth}\.present/Id" "${TMPCONFIG}"
+ # Set up devType
+ devline=
+ if ! grep -q -i "^${eth}\.virtualDev" "${TMPCONFIG}" && [ -n "$devtype" ]; then
+ devline="${eth}.virtualDev = "'"'"${devtype}"'"'
+ fi
+ cat >> "${TMPCONFIG}" <<-HEND
+ ${eth}.connectionType = "custom"
+ ${eth}.present = "TRUE"
+ ${eth}.vnet = "vmnet${vmnet}"
+ ${eth}.addressType = "static"
+ ${eth}.address = "${mac}"
+ ${devline}
+ HEND
+ done
+ fi
}
# DVD, CDROM