Skip to content
Open
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
14 changes: 12 additions & 2 deletions libvirt/tests/src/daemon/crash_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,18 @@ def run_shutdown_console(params, libvirtd, vm):
"""
Start a vm with console connected and then shut it down.
"""
vm.start(autoconsole=True)
vm.shutdown()
vm_xml = VMXML.new_from_inactive_dumpxml(vm.name)
vm_xml_backup = vm_xml.copy()
try:
iface = vm_xml.get_devices(device_type="interface")[0]
driver_dict = dict(iface.driver.driver_attr)
driver_dict['queues'] = '1'
iface.driver = iface.new_driver(driver_attr=driver_dict)
virsh.update_device(vm.name, iface.xml, debug=True)
Comment on lines +46 to +50
Copy link
Contributor

@chloerh chloerh Sep 12, 2025

Choose a reason for hiding this comment

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


        # Workaround bug: Remove multi-queue setting
        vmxml = vm_xml.VMXML.new_from_inactive_dumpxml(vm_name)
        libvirt_vmxml.modify_vm_device(vmxml, 'interface', {'driver': None})

We used to have this workaround for managed save tests. Would you like to consider it ?
I also want to make sure if the current fix is a workaround, would it be removed someday ? If so, maybe we could consider adding a comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it's not a workaround since selinux-policy does not support running daemons from cli.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure. I mean we could replace the 5 lines with libvirt_vmxml.modify_vm_device if it's simply modifying vmxml

vm.start(autoconsole=True)
vm.shutdown()
finally:
vm_xml_backup.sync()

Comment on lines +46 to 55
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix: update persistent XML instead of calling virsh.update_device with raw XML (and missing --config).

virsh.update_device expects a file path and, for an inactive VM, requires --config. As written, this likely no-ops or fails silently, so multiqueue may remain enabled and the crash can persist.

Apply this diff to persist the change before boot and wait for shutdown:

-        iface = vm_xml.get_devices(device_type="interface")[0]
-        driver_dict = dict(iface.driver.driver_attr)
-        driver_dict['queues'] = '1'
-        iface.driver = iface.new_driver(driver_attr=driver_dict)
-        virsh.update_device(vm.name, iface.xml, debug=True)
-        vm.start(autoconsole=True)
-        vm.shutdown()
+        # Disable NIC multiqueue persistently to avoid AVC attach_queue when qemu runs in foreground.
+        devices = vm_xml.devices
+        for dev in devices:
+            if getattr(dev, "device_tag", "") == "interface":
+                driver_attr = dict(getattr(getattr(dev, "driver", None), "driver_attr", {}) or {})
+                driver_attr["queues"] = "1"
+                dev.driver = dev.new_driver(driver_attr=driver_attr)
+                break
+        vm_xml.devices = devices
+        vm_xml.sync()
+        vm.start(autoconsole=True)
+        vm.shutdown()
+        vm.wait_for_shutdown()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
iface = vm_xml.get_devices(device_type="interface")[0]
driver_dict = dict(iface.driver.driver_attr)
driver_dict['queues'] = '1'
iface.driver = iface.new_driver(driver_attr=driver_dict)
virsh.update_device(vm.name, iface.xml, debug=True)
vm.start(autoconsole=True)
vm.shutdown()
finally:
vm_xml_backup.sync()
# Disable NIC multiqueue persistently to avoid AVC attach_queue when qemu runs in foreground.
devices = vm_xml.devices
for dev in devices:
if getattr(dev, "device_tag", "") == "interface":
driver_attr = dict(getattr(getattr(dev, "driver", None), "driver_attr", {}) or {})
driver_attr["queues"] = "1"
dev.driver = dev.new_driver(driver_attr=driver_attr)
break
vm_xml.devices = devices
vm_xml.sync()
vm.start(autoconsole=True)
vm.shutdown()
vm.wait_for_shutdown()
finally:
vm_xml_backup.sync()
🤖 Prompt for AI Agents
libvirt/tests/src/daemon/crash_regression.py lines 46-55: the test modifies the
interface driver XML then calls virsh.update_device with raw XML (and omits
--config), which does not persist the change for the inactive VM; instead write
the updated device XML into the VM's persistent/domain XML (or call virsh
update-device with the --config flag and a file path), ensure you apply the
updated XML to the domain configuration before starting the VM, and wait for the
VM to shutdown to confirm persistence before restoring the backup.


def run_restart_console(params, libvirtd, vm):
Expand Down