close
Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions etc/rc.d/rc.libvirt
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,23 @@ version(){
echo $1 | awk -F. '{printf("%03d%03d",$1,$2);}'
}

update_legacy_machine_types(){
local XML=$1
local MACHINE=
local PREFIX=
local MAJOR=

while IFS= read -r MACHINE; do
[[ $MACHINE =~ ^((pc-(i440fx|q35)))-([0-9]+)\.([0-9]+)$ ]] || continue
PREFIX=${BASH_REMATCH[1]}
MAJOR=${BASH_REMATCH[4]}
if (( MAJOR < 8 )); then
local ESC_PREFIX=${PREFIX//./\\.}
sed -ri "s/machine=([\"'])${ESC_PREFIX}-[0-7]\.[0-9]+\1/machine=\1${ESC_PREFIX}-8.0\1/g" "$XML"
fi
Comment thread
coderabbitai[bot] marked this conversation as resolved.
done < <(grep -oP "machine=[\"']pc-(?:i440fx|q35)-[0-9]+\.[0-9]+[\"']" "$XML" | grep -oP "pc-(?:i440fx|q35)-[0-9]+\.[0-9]+" | sort -u)
}

libvirtd_start(){
log "Starting $DAEMON..."
if ! mountpoint /etc/libvirt &>/dev/null; then
Expand All @@ -188,6 +205,7 @@ libvirtd_start(){
# update interface section((s) of VM configuration files
for XML in /etc/libvirt/qemu/*.xml; do
[[ -f "$XML" ]] || continue
update_legacy_machine_types "$XML"
if grep -qm1 "<vendor_id='none'/>" "$XML"; then
# 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" "$XML"
Expand Down
Loading