Network devices are now only managed by NetworkManager.

Systemd-networkd is no longer used.
NetworkManager creates a MACVTAP device for each physical Ethernet device.
When calling vm-run with option macvtap, all macvtap-devices are passed to the VM.
This commit is contained in:
Raphael Dannecker 2024-05-23 09:58:41 +02:00
parent a8d74fce5b
commit 93d261e73b
4 changed files with 42 additions and 15 deletions

View file

@ -19,6 +19,7 @@ options:
--os OS operating system (win10|linux|..)
--data-disk size additional data-disk
--bridge virbrX additional network interface on bridge virbrX
--macvtap additional network interface on device macvtap
--options options additional options for virt-install command
EOF
}
@ -115,7 +116,7 @@ NO_VIEWER=0
source /etc/lmn/vm.conf
TEMP=$(getopt -o no:ps --long new,no-viewer,options:,persistent,system,memory:,data-disk:,heads:,cpu:,bridge:,os:,help -n $0 -- "$@")
TEMP=$(getopt -o no:ps --long new,no-viewer,options:,persistent,system,memory:,data-disk:,heads:,cpu:,bridge:,macvtap,os:,help -n $0 -- "$@")
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
eval set -- "$TEMP"
@ -180,6 +181,15 @@ while true; do
fi
shift 2
;;
--macvtap )
for interface in $(ip link | sed -En 's/.*(macvtap-.*)@.*/\1/p'); do
mac="$(ip link | grep -A1 "${interface}" | \
sed -nE "s%\s+link/ether ([[:xdigit:]:]{17}) .+%\1%p")"
type="ethernet,mac=${mac},target.dev=${interface},xpath1.set=./target/@managed=no,model.type=virtio"
LIBVIRTOPTS="${LIBVIRTOPTS} --network type=$type"
done
shift
;;
--os )
LIBVIRTOSINFO=$2
shift 2