diff --git a/etc/rc.d/rc.libvirt b/etc/rc.d/rc.libvirt
index ae1c88e7b..564fe16f7 100755
--- a/etc/rc.d/rc.libvirt
+++ b/etc/rc.d/rc.libvirt
@@ -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
+ 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
@@ -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 "" "$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///g" "$XML"