mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 09:26:03 +00:00
feat(vmbackups): what a VM's backup holds and the target files
wvmBackup.backup_plan reads a VM's persistent definition and says what a backup copies: each file disk (qcow2 or raw) with its pool and virtual size, the NVRAM file, and what is left out (CD-ROMs, floppies). It refuses, naming the reason, what a backup could not restore as it is: encrypted, block, network, volume, directory and shareable disks, other disk formats, a disk in no storage pool, shared host directories, a kernel file boot, host devices, a saved state, TPM state (a later layer), an NVRAM file outside libvirt's directory, and a running VM whose disks change at its next start. The target side: the files' names from the backup's UUID only, the free space check (virtual size plus the snapshots' margin), small files written and read back with their SHA-256, read, removed and the manifests listed. download_volume is taken out of copy_nvram for both. Every user of the NVRAM pool runs in the worker, so its process lock holds. A push backup target of a raw disk (live backup or live clone) is made without qcow2's compat and features, which libvirt refuses for raw.
This commit is contained in:
parent
022737f143
commit
89835f2b06
10 changed files with 785 additions and 239 deletions
|
|
@ -502,17 +502,7 @@ class wvmInstances(wvmConnect):
|
|||
if self._find_volume(target, name) is None:
|
||||
raise util.OperationError(gettext_noop("The destination host cannot see the NVRAM file %(path)s"), path=path)
|
||||
return None
|
||||
chunks = []
|
||||
stream = conn.wvm.newStream(0)
|
||||
try:
|
||||
vol.download(stream, 0, 0, 0)
|
||||
stream.recvAll(lambda _stream, data, out: out.append(data), chunks)
|
||||
stream.finish()
|
||||
except Exception:
|
||||
with contextlib.suppress(libvirtError):
|
||||
stream.abort()
|
||||
raise
|
||||
self.upload_volume(target, name, b"".join(chunks))
|
||||
self.upload_volume(target, name, conn.download_volume(vol))
|
||||
return name
|
||||
|
||||
def delete_nvram(self, name):
|
||||
|
|
@ -2567,6 +2557,8 @@ class wvmInstance(wvmConnect):
|
|||
return tree, disks
|
||||
|
||||
def _clone_volume_xml(self, name, capacity, vol_format, owner_uid, owner_gid):
|
||||
# compat and features are qcow2's: libvirt refuses them for another format
|
||||
qcow2 = "<compat>1.1</compat><features><lazy_refcounts/></features>" if vol_format == "qcow2" else ""
|
||||
return f"""<volume>
|
||||
<name>{util.xml_escape(name)}</name>
|
||||
<capacity>{capacity}</capacity>
|
||||
|
|
@ -2579,8 +2571,7 @@ class wvmInstance(wvmConnect):
|
|||
<mode>0644</mode>
|
||||
<label>virt_image_t</label>
|
||||
</permissions>
|
||||
<compat>1.1</compat>
|
||||
<features><lazy_refcounts/></features>
|
||||
{qcow2}
|
||||
</target>
|
||||
</volume>"""
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue