Implement netboot VM with macvtap interface.

This commit is contained in:
Andreas B. Mundt 2023-11-28 11:17:12 +01:00
parent 70b5a51565
commit 25c9a4db4b
4 changed files with 38 additions and 5 deletions

View file

@ -41,8 +41,8 @@ fi
# hardware addresses need to be removed, libvirt will assign
# new addresses automatically
sed -i /uuid/d "${VM_NAME}-${VM_CLONE}.xml"
sed -i '/mac address/d' "${VM_NAME}-${VM_CLONE}.xml"
# and actually rename the vm: (this also updates the storage path)
sed -i "s/${VM_NAME}/${VM_NAME}-${VM_CLONE}/" "${VM_NAME}-${VM_CLONE}.xml"
sed -i -E \
-e '/<uuid>.+<\/uuid>/d' \
-e '/.+mac address.+[[:xdigit:]:]{17}.+/d' \
-e "s/${VM_NAME}/${VM_NAME}-${VM_CLONE}/" "${VM_NAME}-${VM_CLONE}.xml"

View file

@ -97,6 +97,11 @@ create-clone() {
sed -i "s/${VM_NAME}/${VM_NAME}-clone/" "${VM_XML}"
# set virtiofs-Socket
sed -i "s:VIRTIOFSSOCKET:/run/user/${UID}/virtiofs-${VM_NAME}.sock:" "${VM_XML}"
# find macvtap interface MAC address:
MAC="$(ip link | grep -A1 "vm-macvtap" |
sed -nE "s%\s+link/ether ([[:xdigit:]:]{17}) .+%\1%p")"
sed -i -E -e "s/MACMACVTAP/$MAC/" "${VM_XML}"
}
QEMU='qemu:///session'