From 80dd145bcfe07206325f55ee03163a0f9f070621 Mon Sep 17 00:00:00 2001 From: catborise Date: Thu, 29 Oct 2026 13:45:27 +0300 Subject: [PATCH] feat(instances): PCI devices of the host given to a shut-off VM - The Host devices tab gives a shut-off VM a PCI device of its host and takes it back; libvirt binds the device to vfio-pci when the VM starts and gives it back when it stops (managed). The VM's PCI devices are listed with whether the running VM and its next start have them. - A device is offered, and accepted on the server under the compute's claim, only when it is no bridge of any kind (bridge header, PCIe port, or of the bridge class: host bridge, LPC), the host has none of its own network interfaces, disks or graphics card on it (else: bind it to vfio-pci on the host first), no other VM names it, and every other endpoint of its IOMMU group is the VM's too or has no driver or vfio-pci and no other VM; bridges in the group stay with pcieport, and a member that cannot be read keeps the group. Nothing in the group is taken implicitly. - A snapshot revert checks the PCI devices of the snapshot with the same rules; migration and clones already leave host devices out. - The add forms of the tab load together, when the tab opens. --- instances/templates/instance.html | 16 +-- .../instances/host_devices_form.html | 29 ++++ .../templates/instances/host_usb_form.html | 15 -- .../templates/instances/settings_tab.html | 43 +++++- instances/tests/test_console_listener.py | 2 +- .../tests/test_console_settings_access.py | 2 +- instances/tests/test_host_devices.py | 67 +++++++-- instances/tests/test_page_controls.py | 2 +- instances/tests/test_pending_edits.py | 2 +- instances/tests/test_quota.py | 2 +- instances/tests/test_snapshot_views.py | 2 +- instances/tests/test_states.py | 2 +- instances/tests/test_xss.py | 2 +- instances/urls.py | 4 +- instances/views.py | 80 ++++++++--- nodedevs/tests/test_nodedevs.py | 15 +- nodedevs/tests/test_pci_rules.py | 134 ++++++++++++++++++ vrtManager/instance.py | 65 +++++++-- vrtManager/nodedevs.py | 128 +++++++++++++---- 19 files changed, 509 insertions(+), 103 deletions(-) create mode 100644 instances/templates/instances/host_devices_form.html delete mode 100644 instances/templates/instances/host_usb_form.html create mode 100644 nodedevs/tests/test_pci_rules.py diff --git a/instances/templates/instance.html b/instances/templates/instance.html index bba4f00e..e4c3088f 100644 --- a/instances/templates/instance.html +++ b/instances/templates/instance.html @@ -428,19 +428,19 @@ });