mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-09 11: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:
parent
37b87839c1
commit
2d0f41ee57
9 changed files with 130 additions and 104 deletions
|
|
@ -1098,6 +1098,23 @@ class wvmConnect(object):
|
|||
return {dom.UUIDString(): [dom.name(), stats["state.state"]]
|
||||
for dom, stats in self.wvm.getAllDomainStats(libvirt.VIR_DOMAIN_STATS_STATE)}
|
||||
|
||||
def get_domain_rows(self):
|
||||
"""{uuid: (info, title)} of every domain, as the VM lists show them:
|
||||
info in virDomainGetInfo's shape (state, max memory KiB, memory KiB,
|
||||
vCPUs), the states in one call and the rest from each domain's live
|
||||
XML, which the title needs anyway. A domain gone meanwhile is left out."""
|
||||
rows = {}
|
||||
for dom, stats in self.wvm.getAllDomainStats(libvirt.VIR_DOMAIN_STATS_STATE):
|
||||
try:
|
||||
doc = etree.fromstring(dom.XMLDesc(0))
|
||||
except libvirtError:
|
||||
continue
|
||||
vcpu = doc.find("vcpu")
|
||||
info = [stats["state.state"], int(doc.findtext("memory")), int(doc.findtext("currentMemory")),
|
||||
int(vcpu.get("current", vcpu.text))]
|
||||
rows[dom.UUIDString()] = (info, doc.findtext("title") or "")
|
||||
return rows
|
||||
|
||||
def domain_trees(self, running_only=False):
|
||||
"""Each domain's name with its definitions, parsed: the live one, and
|
||||
for a persistent domain the one saved for its next boot too, read
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue