1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-11 12:46:49 +00:00

perf(instances): VM lists read each host once, not three calls a VM

A VM list row showed the VM's state, memory, vCPUs and title, read
through the VM's own connection object: a lookup by UUID, virDomainGetInfo
and the live XML, one after the other for every VM on the page.

The lists (Instances, grouped or not, and a compute's VMs) now read each
host once: the states in one getAllDomainStats call (the state group
only, as the lists' poll; no other group, so a VM busy in the QEMU
monitor holds nothing up) and the memory, vCPUs and title from each
VM's live XML, which the title already read. Checked on QEMU against
virDomainGetInfo for running, paused and shut-off VMs: the same values.

A VM gone from its host, or a host that cannot be read or fails its
listing, shows its VMs unknown as before. Only the grouped list, a
superuser's, prefetches every host's VMs and owners.
This commit is contained in:
catborise 2026-11-04 20:43:00 +03:00
parent 37b87839c1
commit 2d0f41ee57
9 changed files with 130 additions and 104 deletions

View file

@ -39,7 +39,7 @@
</div>
{% endif %}
<div class="col-lg-12">
{% if instances.exists %}
{% if instances %}
{# the state filter: table_filter.js counts each state's VMs the search finds #}
<input type="hidden" id="state-filter" value="">
<nav class="mb-3" aria-label="{% trans "VM states" %}">
@ -56,7 +56,7 @@
</nav>
<div id="filter-status" class="visually-hidden" role="status" data-text="{% trans "%(shown)s of %(all)s VMs match" %}"></div>
{% endif %}
{% if not instances.exists %}
{% if not instances %}
<p class="text-center text-body-secondary py-4">{% trans "There are no VMs here yet." %}</p>
{% elif app_settings.VIEW_INSTANCES_LIST_STYLE == 'grouped' and request.user.is_superuser %}
{% include 'allinstances_index_grouped.html' %}