mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 09:26:03 +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:
parent
2e3ffba851
commit
eeae606d08
15 changed files with 409 additions and 309 deletions
|
|
@ -284,6 +284,23 @@ class MigrateJobTestCase(TransactionTestCase):
|
|||
Operation.objects.all().delete()
|
||||
Claim.objects.all().delete()
|
||||
|
||||
def test_tls_only_when_both_hosts_encrypt_migrations(self):
|
||||
for source_tls, dest_tls, key in ((True, False, "key-mig00021"), (True, True, "key-mig00022")):
|
||||
with self.subTest(source=source_tls, dest=dest_tls):
|
||||
Compute.objects.filter(pk=self.source.pk).update(migration_tls=source_tls)
|
||||
Compute.objects.filter(pk=self.dest.pk).update(migration_tls=dest_tls)
|
||||
self.vm.compute = self.source # back where the last one moved it from
|
||||
self.vm.save()
|
||||
self.client.post(reverse("instances:migrate", args=[self.vm.pk]),
|
||||
{"compute_id": self.dest.pk, "submission_key": key, "live_migrate": "true"})
|
||||
op = Operation.objects.latest("created_at")
|
||||
ctx = self.start(op)
|
||||
get_kind(op.kind).precheck(op, ctx)
|
||||
get_kind(op.kind).run(op, ctx)
|
||||
self.assertEqual(self.dest_conn.moveto.call_args.kwargs["tls"], source_tls and dest_tls)
|
||||
Operation.objects.all().delete()
|
||||
Claim.objects.all().delete()
|
||||
|
||||
def test_cancel_and_progress_ask_the_source_vm(self):
|
||||
op = self.queue(live_migrate="true")
|
||||
with patch("instances.jobs.wvmInstance") as proxy:
|
||||
|
|
|
|||
|
|
@ -344,6 +344,7 @@ def migrate_instance(
|
|||
autoconverge,
|
||||
compress,
|
||||
uri=new_compute.migration_uri,
|
||||
tls=source.migration_tls and new_compute.migration_tls,
|
||||
pools=disk_pools,
|
||||
on_copy=on_copy,
|
||||
running_only=running_only,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue