rc.libvirt: skip non-existing XML files

This commit is contained in:
bergware
2023-12-09 10:48:08 +01:00
parent 7b7b941c84
commit b7a51773c1

View File

@@ -181,14 +181,15 @@ libvirtd_start(){
return 1
fi
# convert libvirt 1.3.1 w/ eric's hyperv vendor id patch to how libvirt does it in libvirt 1.3.3+
sed -ri "s/<vendor id='none'\/>/<vendor_id state='on' value='none'\/>/g" /etc/libvirt/qemu/*.xml &>/dev/null
sed -ri "s/<vendor id='none'\/>/<vendor_id state='on' value='none'\/>/g" /etc/libvirt/qemu/*.xml 2>/dev/null
# remove <locked/> from xml because libvirt + virlogd + virlockd has an issue with locked
sed -ri "/<locked\/>/d" /etc/libvirt/qemu/*.xml &>/dev/null
sed -ri "/<locked\/>/d" /etc/libvirt/qemu/*.xml 2>/dev/null
# Remove "<watchdog model='itco' action='reset'/>" if reverting from later release.
. /etc/unraid-version
[[ $(version $version) -le $(version "6.12") ]] && sed -ri "/<watchdog model='itco' action='reset'\/>/d" /etc/libvirt/qemu/*.xml &>/dev/null
[[ $(version $version) -le $(version "6.12") ]] && sed -ri "/<watchdog model='itco' action='reset'\/>/d" /etc/libvirt/qemu/*.xml 2>/dev/null
# update interface section((s) of VM configuration files
for XML in /etc/libvirt/qemu/*.xml; do
[[ -f "$XML" ]] || continue
# get all interface sections
ROW=($(grep -nhP '<interface type=' "$XML" | grep -Pom1 '^[0-9]+'))
# get all source sections