mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-02 08:56:07 +00:00
feat(instances): external snapshots use libvirt's snapshot API
Create, revert and delete are one libvirt call each. The pflash-to-rom loader rewrite, the hand-written block commit and the s1./s2. names are gone, so UEFI VMs can take external snapshots, a revert keeps disks added later, and deleting an older snapshot keeps the newer one. Create refuses what libvirt could not revert or delete later: internal snapshots on the VM, a saved state, a running snapshot job, disks that are not files, CD-ROM media, a branch after a revert, and memory without a running VM or room in the first disk's pool. A disk-only revert keeps the VM running, paused or shut off; one with memory resumes it as saved. A revert in the same second as the previous one, which libvirt fails after stopping the VM, is retried once. A snapshot the old code took of a UEFI VM saved the loader as rom; its revert is refused (deleting it still works). The snapshots tab lists internal and external snapshots separately, can save memory too, shows running snapshot jobs, and the revert confirmation names the disks it detaches and that NVRAM is not restored.
This commit is contained in:
parent
c55f52f025
commit
ff1508b3c2
13 changed files with 994 additions and 311 deletions
|
|
@ -92,7 +92,6 @@ class LiveDataLossTestCase(TestCase):
|
|||
|
||||
# External snapshots
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_revert_external_snapshot_keeps_disk_added_later(self):
|
||||
base = livetest.create_volume(self.conn, P + "r03-a")
|
||||
dom, inst = self.vm("r03-a", [base])
|
||||
|
|
@ -104,11 +103,11 @@ class LiveDataLossTestCase(TestCase):
|
|||
f"<source file='{later}'/><target dev='vdb' bus='virtio'/></disk>",
|
||||
libvirt.VIR_DOMAIN_AFFECT_CONFIG,
|
||||
)
|
||||
self.post("revert_external_snapshot", inst, {"name": "s1.snap", "date": "", "desc": ""})
|
||||
self.post("revert_external_snapshot", inst, {"name": "snap"})
|
||||
|
||||
self.assertTrue(livetest.volume_exists(self.conn, later), "revert deleted a disk the snapshot never had")
|
||||
self.assertEqual(set(self.disk_sources(dom, libvirt.VIR_DOMAIN_XML_INACTIVE)), {"vda"})
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_delete_older_external_snapshot_keeps_newer_snapshot_files(self):
|
||||
base = livetest.create_volume(self.conn, P + "r03-b")
|
||||
dom, inst = self.vm("r03-b", [base])
|
||||
|
|
@ -116,11 +115,11 @@ class LiveDataLossTestCase(TestCase):
|
|||
self.post("create_external_snapshot", inst, {"name": "newer"})
|
||||
sources = set(self.disk_sources(dom).values())
|
||||
|
||||
self.post("delete_external_snapshot", inst, {"name": "s1.older"})
|
||||
self.post("delete_external_snapshot", inst, {"name": "older"})
|
||||
|
||||
for path in sources:
|
||||
self.assertTrue(livetest.volume_exists(self.conn, path), f"{path} was deleted")
|
||||
self.assertIn("s1.newer", dom.snapshotListNames(0))
|
||||
self.assertIn("newer", dom.snapshotListNames(0))
|
||||
|
||||
# Internal snapshots of UEFI VMs
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue