mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-02 17:06:09 +00:00
feat(instances): a VM a fault stopped or paused says why
libvirt gives each state its reason; the panel showed only the state, so a VM QEMU paused because its storage filled up read "Suspended" like one an administrator paused. - instances.states.REASONS: the fault reasons told (disk error, watchdog, guest crash or kernel panic, a crash of the guest or its QEMU process, libvirt stopping it after a restart, failed post-copy migration, libvirt error, failed start); the ordinary ones (user, migration, snapshot) are not - the lists read the reason with the state in their one getAllDomainStats call (get_domain_rows, get_domain_states: a change of reason reloads a list) and show it under the state badge - the VM page reads state and reason in one virDomainGetState (a reason means something only with its own state) and tells it in an alert; a VM paused by a disk error names each disk and what it met (virDomainGetDiskErrors), and when a storage has no free space, what to do: an administrator frees space and resumes it. Disk errors are read only then: libvirt keeps the last one after a resume. The page's poll reloads on a change of reason too Checked live on a Vagrant host: a guest filling a disk on a 40 MiB pool was paused (I/O error, vda: no space); the page said so, and after the pool grew and the VM was resumed the alert was gone.
This commit is contained in:
parent
7408a575d6
commit
bdc5569cc8
17 changed files with 330 additions and 18 deletions
|
|
@ -1173,14 +1173,15 @@ class wvmConnect(object):
|
|||
return instances
|
||||
|
||||
def get_domain_states(self):
|
||||
"""{uuid: [name, state]} of every domain, in one call."""
|
||||
return {dom.UUIDString(): [dom.name(), stats["state.state"]]
|
||||
"""{uuid: [name, state, reason]} of every domain, in one call."""
|
||||
return {dom.UUIDString(): [dom.name(), stats["state.state"], stats["state.reason"]]
|
||||
for dom, stats in self.wvm.getAllDomainStats(libvirt.VIR_DOMAIN_STATS_STATE)}
|
||||
|
||||
def get_domain_rows(self, uuids=None):
|
||||
"""{uuid: (info, title)} of every domain, or of those in uuids, 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
|
||||
"""{uuid: (info, title, reason)} of every domain, or of those in uuids,
|
||||
as the VM lists show them: info in virDomainGetInfo's shape (state, max
|
||||
memory KiB, memory KiB, vCPUs), reason the state's (virDomainGetState),
|
||||
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 = {}
|
||||
|
|
@ -1194,7 +1195,7 @@ class wvmConnect(object):
|
|||
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 "")
|
||||
rows[dom.UUIDString()] = (info, doc.findtext("title") or "", stats["state.reason"])
|
||||
return rows
|
||||
|
||||
def domain_trees(self, running_only=False):
|
||||
|
|
|
|||
|
|
@ -920,6 +920,14 @@ class wvmInstance(wvmConnect):
|
|||
self._read_cache.clear()
|
||||
return self.wvm.defineXML(xml)
|
||||
|
||||
def get_state(self):
|
||||
"""[state, reason] of the domain (virDomainGetState), in one read."""
|
||||
return self.instance.state()
|
||||
|
||||
def get_disk_errors(self):
|
||||
"""{target: virDomainDiskErrorCode} of the disks QEMU stopped on (virDomainGetDiskErrors)."""
|
||||
return self.instance.diskErrors()
|
||||
|
||||
def get_status(self):
|
||||
"""
|
||||
VIR_DOMAIN_NOSTATE = 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue