mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-11 12:46:49 +00:00
fix(vrtManager): refuse to migrate a VM with snapshots in every state
libvirt keeps snapshot metadata on the source host and a migration does not carry it, even when both hosts share the disks. Only the shut-off path refused such a VM itself; a running or paused one relied on libvirt's own refusal. moveto now refuses it for every state, before any check against the destination, with the same message.
This commit is contained in:
parent
097a91592c
commit
5388743053
2 changed files with 16 additions and 3 deletions
|
|
@ -237,7 +237,6 @@ class ShutOffMigrationTestCase(unittest.TestCase):
|
|||
|
||||
def test_refused_before_anything_changes(self):
|
||||
cases = {
|
||||
"snapshots": (FakeHost(), {"snapshots": 2}),
|
||||
"saved state": (FakeHost(), {"saved": True}),
|
||||
"same uuid on the destination": (FakeHost(existing={"u-1"}), {}),
|
||||
"same name on the destination": (FakeHost(existing={"vm"}), {}),
|
||||
|
|
@ -300,6 +299,18 @@ class MigrationModeTestCase(unittest.TestCase):
|
|||
destination().moveto(source, "vm", unsafe=False, **{"live": False, "offline": False, **request})
|
||||
self.assertEqual(source.instance.calls, [])
|
||||
|
||||
def test_a_vm_with_snapshots_is_refused_in_every_state(self):
|
||||
"""libvirt keeps snapshot metadata on the source host; a migration
|
||||
does not carry it, even with shared disks."""
|
||||
for state, request in ((1, {"live": True}), (1, {}), (3, {}), (5, {})):
|
||||
with self.subTest(state=state, request=request):
|
||||
host = FakeHost()
|
||||
source = FakeSource(state, snapshots=1)
|
||||
with self.assertRaisesRegex(util.OperationError, "A VM with snapshots cannot be migrated"):
|
||||
destination(host).moveto(source, "vm", unsafe=False, **{"live": False, "offline": False, **request})
|
||||
self.assertEqual(source.instance.calls, [])
|
||||
self.assertEqual(host.defined, [])
|
||||
|
||||
def test_modes(self):
|
||||
live, unsafe = libvirt.VIR_MIGRATE_LIVE, libvirt.VIR_MIGRATE_UNSAFE
|
||||
converge, compressed = libvirt.VIR_MIGRATE_AUTO_CONVERGE, libvirt.VIR_MIGRATE_COMPRESSED
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue