1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-11 12:46:49 +00:00
webvirtcloud/instances/templates/instances/host_devices_form.html
catborise d43245d996 feat(instances): PCI devices hot-plugged into a running VM
- A running VM gets a PCI device of its host at once and for its next
  start, in one libvirt call; a hot plug libvirt could not keep for the
  next start says that the device is in the running VM only. A q35 VM
  without a free pcie-root-port gets libvirt's error and where a slot
  comes from.
- A PCI device is taken from the running VM and from its next start, each
  as it has it; a refusal by the guest stops there. When the guest has
  not let the device go within libvirt's wait, the page says the removal
  is requested and the Logs row records the request: the device stays in
  the running VM until the guest lets it go or the VM stops.
- A paused VM, or one with a saved state, does not change its PCI devices.
- A device for a running VM is checked alone too, as libvirt takes only
  the hot-plugged device from its host driver.
2026-10-29 14:54:36 +03:00

30 lines
2.6 KiB
HTML

{% load i18n %}
{% load bootstrap_icons %}
{# the add forms of the Host devices tab: each choice disabled with the reasons it cannot be given #}
{% if error %}
<div class="alert alert-warning mb-0">{% blocktrans %}The host's devices could not be read: {{ error }}{% endblocktrans %}</div>
{% else %}
<form method="post" action="{% url 'instances:add_usb_hostdev' instance.id %}" class="d-flex flex-wrap gap-2 mb-2">{% csrf_token %}
<select name="usb_device" class="form-select w-auto mw-100" aria-label="{% trans "USB device of the host" %}" required>
<option value="" selected disabled>{% trans "Choose a USB device of the host…" %}</option>
{% for device in host_usb %}
<option value="{{ device.bus }}/{{ device.device }}"{% if device.problems %} disabled{% endif %}>{{ device.product }} ({{ device.ids }}, {{ device.bus }}/{{ device.device }}){% if device.problems %}: {{ device.problems|join:"; " }}{% endif %}</option>
{% endfor %}
</select>
<button type="submit" class="btn btn-primary">{% bs_icon 'plus-lg' %} {% trans "Add USB device" %}</button>
</form>
<form method="post" action="{% url 'instances:add_pci_hostdev' instance.id %}" class="d-flex flex-wrap gap-2">{% csrf_token %}
<select name="pci_device" class="form-select w-auto mw-100" aria-label="{% trans "PCI device of the host" %}" aria-describedby="pci_help" required{% if pci_frozen %} disabled{% endif %}>
<option value="" selected disabled>{% trans "Choose a PCI device of the host…" %}</option>
{% for device in host_pci %}
<option value="{{ device.address }}"{% if device.problems %} disabled{% endif %}>{{ device.product }} ({{ device.address }}, {{ device.driver|default:_("no driver") }}){% if device.problems %}: {{ device.problems|join:"; " }}{% endif %}</option>
{% endfor %}
</select>
<button type="submit" class="btn btn-primary"{% if pci_frozen %} disabled{% endif %}>{% bs_icon 'plus-lg' %} {% trans "Add PCI device" %}</button>
<div class="form-text w-100" id="pci_help">
{% if pci_frozen %}{% trans "A paused VM, or one with a saved state, does not change its PCI devices." %}
{% elif running %}{% trans "The device is plugged into the running VM at once and kept for its next start; libvirt binds it to vfio-pci. It needs a free slot: on a q35 VM a free pcie-root-port, added while the VM is shut off." %}
{% else %}{% trans "libvirt binds the device to vfio-pci when the VM starts, and gives it back to the host when the VM stops; a device bound to vfio-pci before stays bound to it." %}{% endif %}
</div>
</form>
{% endif %}