1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 09:26:03 +00:00

feat(migrations): a migration's bandwidth can be capped

A migration took all the network it could, its disk copies too, and the VMs
on both hosts felt it. Settings has a Migrations group with "Migration
bandwidth" (MiB/s, 0: libvirt's default, the default); every migration, by
hand, in bulk or for maintenance, passes it to libvirt, and its log line
names it. libvirt applies it to the memory until the final switchover and to
each copied disk on its own; the help and README say so. A refused setting
is now named in the page's language.
This commit is contained in:
catborise 2026-11-20 09:17:45 +03:00
parent 46931bdbdb
commit 3da55342da
14 changed files with 438 additions and 333 deletions

View file

@ -120,6 +120,19 @@ class DiskCopyTestCase(unittest.TestCase):
source.instance.migrate.assert_called_once()
source.instance.migrate3.assert_not_called()
def test_the_bandwidth_limit_goes_to_libvirt(self):
# MiB/s; 0: none
source = Source(1, domain(disk(f"{IMAGES}/vm.qcow2")))
self.assertEqual(migrate(destination(Pool("default", IMAGES), shared=True), source, {}, bandwidth=100),
("live, 100 MiB/s", []))
self.assertEqual(source.instance.migrate.call_args.args[4], 100)
source = Source(1, domain(disk(f"{IMAGES}/vm.qcow2")))
migrate(destination(Pool("default", IMAGES)), source, {"vda": "default"}, bandwidth=100)
self.assertEqual(source.instance.migrate3.call_args.args[1][libvirt.VIR_MIGRATE_PARAM_BANDWIDTH], 100)
source = Source(1, domain(disk(f"{IMAGES}/vm.qcow2")))
migrate(destination(Pool("default", IMAGES)), source, {"vda": "default"})
self.assertNotIn(libvirt.VIR_MIGRATE_PARAM_BANDWIDTH, source.instance.migrate3.call_args.args[1])
def test_a_disk_the_destination_does_not_share_needs_a_pool(self):
for pools, shared in (((IMAGES,), False), ((), True)): # not shared; no pool to probe on the source
with self.subTest(pools=pools):