mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
feat(instances): the VM page shows the VM's screen
A running or paused VM with a VNC or SPICE console shows its screen beside the summary (virDomainScreenshot, PNG), read again every 10 s while the page is in view; clicking it opens the console. It is for those who may open the console (the screen shows what the console does) and is left out while there is none to show, also on a host whose libvirt gives PPM. The VM list does not read screens: one a VM would cost too much.
This commit is contained in:
parent
8625d6250a
commit
d5cc696d73
18 changed files with 205 additions and 9 deletions
|
|
@ -2979,6 +2979,21 @@ class wvmInstance(wvmConnect):
|
|||
def abort_backup(self):
|
||||
self.instance.abortJob()
|
||||
|
||||
def screenshot(self):
|
||||
"""The running or paused VM's screen as libvirt gives it: (MIME type, bytes); PNG from
|
||||
libvirt 9.x with QEMU 7.1 on, PPM before."""
|
||||
stream = self.wvm.newStream(0)
|
||||
try:
|
||||
mime = self.instance.screenshot(stream, 0, 0)
|
||||
data = bytearray()
|
||||
stream.recvAll(lambda _stream, chunk, buffer: buffer.extend(chunk), data)
|
||||
stream.finish()
|
||||
except libvirtError:
|
||||
with contextlib.suppress(libvirtError):
|
||||
stream.abort()
|
||||
raise
|
||||
return mime, bytes(data)
|
||||
|
||||
def fstrim(self):
|
||||
"""Has the guest agent trim the free space of each mounted file system, waiting
|
||||
FSTRIM_TIMEOUT seconds at most: [{"path", "trimmed": bytes or None, "error": text or None}].
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue