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

feat(migration): encrypt migrations over TLS between hosts that have it

QEMU sends a migrating VM's memory and copied disks in the clear. A
compute gets "Encrypt migrations (TLS)" (edit page, Advanced; API
field migration_tls); a migration between two hosts that both have it
passes VIR_MIGRATE_TLS whenever data moves (not for a shut-off VM's
definition alone), and the log says TLS. The hosts need QEMU's
certificates in /etc/pki/qemu; a host without them refuses before
anything moves. Tried on two AlmaLinux 10 hosts: the TLS stream starts
with a TLS record, the plain one with QEMU's QEVM header.
This commit is contained in:
catborise 2026-11-19 15:19:18 +03:00
parent 2e3ffba851
commit eeae606d08
15 changed files with 409 additions and 309 deletions

View file

@ -225,6 +225,16 @@ class MigrationModeTestCase(unittest.TestCase):
# asked while it ran, then shut down: it moves offline, the tuning options unused
self.assertEqual(self.migrate(5, live=True, autoconverge=True, compress=True), ("offline", None))
def test_tls_encrypts_what_carries_memory_or_disks(self):
tls = libvirt.VIR_MIGRATE_TLS
for state, request, mode in ((1, {"live": True}, "live, TLS"), (1, {}, "non-live, TLS"), (3, {}, "non-live, TLS")):
with self.subTest(state=state, request=request):
got, flags = self.migrate(state, tls=True, **request)
self.assertEqual((got, flags & tls), (mode, tls))
self.assertEqual(self.migrate(state, **request)[1] & tls, 0)
# a shut-off VM's definition alone: no data to encrypt
self.assertEqual(self.migrate(5, tls=True), ("offline", None))
FILE_DISK = "<disk type='file' device='disk'><source file='/pool/vm.qcow2'/><target dev='vda'/></disk>"