close
Skip to content

Update unsupported qemu models in XMLs#2625

Draft
SimonFair wants to merge 4 commits intounraid:masterfrom
SimonFair:fix(VMs)-supported-QEMU-Models-
Draft

Update unsupported qemu models in XMLs#2625
SimonFair wants to merge 4 commits intounraid:masterfrom
SimonFair:fix(VMs)-supported-QEMU-Models-

Conversation

@SimonFair
Copy link
Copy Markdown
Contributor

@SimonFair SimonFair commented Apr 24, 2026

This change is to update the minimum support q35 of i440fx model in the XML.

Support of older values are being dropped. This will update all values < 8.0 to 8.0

These are still supported but deprecated so will be removed in future updates. The current best level is 8.0

root@computenode:~# virsh capabilities | grep "deprecated='yes'>pc-"
pc-q35-5.2
pc-i440fx-6.2
pc-i440fx-5.2
pc-q35-7.1
pc-q35-6.1
pc-i440fx-7.1
pc-q35-5.1
pc-i440fx-6.1
pc-i440fx-5.1
pc-q35-7.0
pc-q35-6.0
pc-i440fx-7.0
pc-q35-5.0
pc-q35-7.2
pc-i440fx-6.0
pc-i440fx-5.0
pc-q35-6.2
pc-i440fx-7.2
pc-q35-5.2
pc-i440fx-6.2
pc-i440fx-5.2
pc-q35-7.1
pc-q35-6.1
pc-i440fx-7.1
pc-q35-5.1
pc-i440fx-6.1
pc-i440fx-5.1
pc-q35-7.0
pc-q35-6.0
pc-i440fx-7.0
pc-q35-5.0
pc-q35-7.2
pc-i440fx-6.0
pc-i440fx-5.0
pc-q35-6.2
pc-i440fx-7.2

Summary by CodeRabbit

  • Chores
    • Added an automatic startup step that scans installed libvirt VM configurations and normalizes legacy machine-type entries to the 8.0 format.
    • Runs during system boot and updates on-disk VM XML files so stored configurations consistently use the standardized 8.0 machine-type notation.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 24, 2026

Walkthrough

Adds update_legacy_machine_types() to the libvirt init script; it scans /etc/libvirt/qemu/*.xml for machine='pc-(i440fx|q35)-<major>.<minor>' and rewrites entries with major < 8 to pc-(i440fx|q35)-8.0 before running the rest of libvirtd_start XML modifications.

Changes

Cohort / File(s) Summary
Libvirt Legacy Machine Type Update
etc/rc.d/rc.libvirt
Added update_legacy_machine_types() and call it from libvirtd_start to preprocess /etc/libvirt/qemu/*.xml, replacing `pc-(i440fx

Sequence Diagram(s)

sequenceDiagram
    participant Init as "rc.libvirt (init script)"
    participant XML as "/etc/libvirt/qemu/*.xml"
    participant Libvirtd as "libvirtd_start"
    participant Vendor as "Vendor ID Conversion"

    Init->>XML: scan domain XML files
    Init->>XML: update_legacy_machine_types() — rewrite pc-*-<major>.<minor> to pc-*-8.0 if major < 8
    Init->>Libvirtd: continue libvirtd_start
    Libvirtd->>XML: apply vendor_id conversion and other XML edits
    Libvirtd->>Libvirtd: start libvirt services
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰
I nibble bytes where old tags hide,
I bump their years and smooth their stride.
From pc-q35 to i440fx, too,
I hop them up to eight point view.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: updating unsupported/legacy QEMU machine models in XMLs to version 8.0. It directly reflects the primary objective of the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 24, 2026

🔧 PR Test Plugin Available

A test plugin has been generated for this PR that includes the modified files.

Version: 2026.04.24.1042
Build: View Workflow Run

📥 Installation Instructions:

Install via Unraid Web UI:

  1. Go to Plugins → Install Plugin
  2. Copy and paste this URL:
https://preview.dl.unraid.net/pr-plugins/pr-2625/webgui-pr-2625.plg
  1. Click Install

Alternative: Direct Download

⚠️ Important Notes:

  • Testing only: This plugin is for testing PR changes
  • Backup included: Original files are automatically backed up
  • Easy removal: Files are restored when plugin is removed
  • Conflicts: Remove this plugin before installing production updates
  • Post-merge behavior: This preview stays available after merge until preview storage expires or it is manually cleaned up

📝 Modified Files:

Click to expand file list
etc/rc.d/rc.libvirt

🔄 To Remove:

Navigate to Plugins → Installed Plugins and remove webgui-pr-2625, or run:

plugin remove webgui-pr-2625

🤖 This comment is automatically generated and will be updated with each new push to this PR.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@etc/rc.d/rc.libvirt`:
- Around line 184-190: The sed replacement is too broad and only handles single
quotes and an unescaped $MACHINE; update the logic so the sed invocation matches
machine attributes with either single or double quotes and only replaces the
numeric version suffix (e.g. -N.N) rather than the whole $MACHINE string, and
ensure any regex-special characters from $MACHINE/PREFIX are treated literally
(escape them or use a safer capture-based pattern). Concretely, modify the sed
call referenced by the sed -ri line to use a regex like matching
machine=(["'])PREFIX-[0-9]+\.[0-9]+\1 and replace only the -X.Y portion with
-8.0 (preserving the original quote capture), leaving $XML and variables
MACHINE, PREFIX, MAJOR, and the grep-derived input logic intact.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 57fa0c77-9c9e-4cad-acb9-972de543915a

📥 Commits

Reviewing files that changed from the base of the PR and between ef1f4d6 and 8c951ba.

📒 Files selected for processing (1)
  • etc/rc.d/rc.libvirt

Comment thread etc/rc.d/rc.libvirt Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@etc/rc.d/rc.libvirt`:
- Around line 187-190: The sed expression under the MAJOR < 8 branch is too
broad and replaces any "${PREFIX}-X.Y" regardless of X; update the sed regex in
the block that defines ESC_PREFIX and calls sed -ri so it only matches major
versions 0–7 (e.g. use ${ESC_PREFIX}-[0-7]\.[0-9]+) and preserves the
surrounding quote via the existing capture groups; in short, change the pattern
machine=([\"'])${ESC_PREFIX}-[0-9]+\.[0-9]+\1 to
machine=\1${ESC_PREFIX}-[0-7]\.[0-9]+\1 (or equivalent) so only legacy <8
entries are rewritten to -8.0.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f2fdefe2-97ef-4bed-b28b-b966a1875bea

📥 Commits

Reviewing files that changed from the base of the PR and between d1a0d62 and c013e46.

📒 Files selected for processing (1)
  • etc/rc.d/rc.libvirt

Comment thread etc/rc.d/rc.libvirt
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
etc/rc.d/rc.libvirt (1)

177-191: Avoid repeated full-file rewrites for the same machine prefix.

When a file has multiple legacy versions of one prefix (e.g., pc-q35-5.2 and pc-q35-7.1), this loop can run the same sed scan multiple times. Track processed prefixes and rewrite once per prefix.

Proposed refactor
 update_legacy_machine_types(){
   local XML=$1
   local MACHINE=
   local PREFIX=
   local MAJOR=
+  local -A UPDATED_PREFIXES=()
 
   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
+    if (( MAJOR < 8 )) && [[ -z ${UPDATED_PREFIXES[$PREFIX]} ]]; 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"
+      UPDATED_PREFIXES[$PREFIX]=1
     fi
   done < <(grep -oP "machine=[\"']pc-(?:i440fx|q35)-[0-9]+\.[0-9]+[\"']" "$XML" | grep -oP "pc-(?:i440fx|q35)-[0-9]+\.[0-9]+" | sort -u)
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@etc/rc.d/rc.libvirt` around lines 177 - 191, The loop in
update_legacy_machine_types repeatedly runs the same sed replacement for the
same machine PREFIX (e.g., pc-q35) when multiple legacy versions exist; modify
update_legacy_machine_types to track processed prefixes (e.g., using a bash
associative array or a simple string/set) and skip handling a PREFIX if already
processed, so only a single sed invocation per unique PREFIX/ESC_PREFIX is done
on the given XML; keep variables XML, PREFIX, MAJOR, ESC_PREFIX and the existing
grep pipeline but add the prefix-tracking check before computing ESC_PREFIX and
calling sed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@etc/rc.d/rc.libvirt`:
- Around line 177-191: The loop in update_legacy_machine_types repeatedly runs
the same sed replacement for the same machine PREFIX (e.g., pc-q35) when
multiple legacy versions exist; modify update_legacy_machine_types to track
processed prefixes (e.g., using a bash associative array or a simple string/set)
and skip handling a PREFIX if already processed, so only a single sed invocation
per unique PREFIX/ESC_PREFIX is done on the given XML; keep variables XML,
PREFIX, MAJOR, ESC_PREFIX and the existing grep pipeline but add the
prefix-tracking check before computing ESC_PREFIX and calling sed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 841d0e1d-601d-43ae-a493-604dd30f7c8c

📥 Commits

Reviewing files that changed from the base of the PR and between c013e46 and 65f21d2.

📒 Files selected for processing (1)
  • etc/rc.d/rc.libvirt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant