mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
fix(instances): USB device changes as PCI ones; device refusals name no VM to owners
- A USB device added to or removed from a VM with a saved state applied only at the next cold boot: refused now, as for PCI devices, and the form says so. - A USB hot plug or removal that failed half way said only libvirt's error: it now says where the device is, as for PCI devices (_hostdev_outcome, shared). - A host device refusal (check_hostdevs) names the other VMs that have the device; users who do not see the hosts, such as an owner whose snapshot revert is refused, now read that a device is not free and that an administrator can see why. - The host's USB devices named among a PCI device's host resources were English in every language.
This commit is contained in:
parent
d07362106a
commit
2db25314ea
12 changed files with 662 additions and 563 deletions
|
|
@ -8,13 +8,14 @@
|
|||
<div class="alert alert-warning">{% blocktrans with problems=unmatched|join:"; " %}The VM does not start until this is fixed: {{ problems }}. Remove the device and add the one the host has.{% endblocktrans %}</div>
|
||||
{% endif %}
|
||||
<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>
|
||||
<select name="usb_device" class="form-select w-auto mw-100" aria-label="{% trans "USB device of the host" %}"{% if usb_frozen %} aria-describedby="usb_help"{% endif %} required{% if usb_frozen %} disabled{% endif %}>
|
||||
<option value="" selected disabled>{% trans "Choose a USB device of the host…" %}</option>
|
||||
{% for device in host_usb %}
|
||||
<option value="{{ device.bus }}/{{ device.device }}/{{ device.ids }}"{% 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>
|
||||
<button type="submit" class="btn btn-primary"{% if usb_frozen %} disabled{% endif %}>{% bs_icon 'plus-lg' %} {% trans "Add USB device" %}</button>
|
||||
{% if usb_frozen %}<div class="form-text w-100" id="usb_help">{% trans "A VM with a saved state does not change its USB devices: start it, or start it without its saved state" %}</div>{% endif %}
|
||||
</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 %}>
|
||||
|
|
|
|||
|
|
@ -2134,10 +2134,10 @@ def host_devices(request, pk):
|
|||
state = domain.info()[0]
|
||||
# the VM's next start takes its USB devices as its definition names them
|
||||
unmatched = usb_unmatched([etree.fromstring(domain.XMLDesc(VIR_DOMAIN_XML_INACTIVE))], usb)
|
||||
saved = domain.hasManagedSaveImage(0) # the VM would start from it without the change
|
||||
context = {"instance": instance, "host_pci": pci, "host_usb": usb, "running": state == VIR_DOMAIN_RUNNING,
|
||||
"unmatched": [util.render(m["text"], m["values"], _) for m in unmatched],
|
||||
# paused, or with a saved state the VM would start from without the change
|
||||
"pci_frozen": state not in (VIR_DOMAIN_RUNNING, VIR_DOMAIN_SHUTOFF) or domain.hasManagedSaveImage(0)}
|
||||
"unmatched": [util.render(m["text"], m["values"], _) for m in unmatched], "usb_frozen": saved,
|
||||
"pci_frozen": state not in (VIR_DOMAIN_RUNNING, VIR_DOMAIN_SHUTOFF) or saved}
|
||||
except libvirtError as err:
|
||||
context = {"instance": instance, "error": err}
|
||||
return render(request, "instances/host_devices_form.html", context)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue