1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-02 08:56:07 +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

@ -332,6 +332,7 @@ Firewall: the compute's VNC ports (`5900`–`65535`) must accept connections **o
- **Address:** a migrating VM goes to the destination's address on the Computes page; for a dedicated migration network, set the compute's **Migration address** on its edit page.
- **Without shared storage:** after choosing the destination, the **Disks** list shows each disk and the destination pools that can take a copy (directory, filesystem and NFS pools; a pool with a file of the same name refuses it); a disk on storage both hosts share can stay there. Plain raw or qcow2 disks without a backing file are copied, through the destination's migration port range (49152-49215 by default). **Delete the source files of copied disks** removes them after the migration, unless another VM or volume uses them.
- **Shut-off VMs:** a shut-off VM moves offline, with its NVRAM file (UEFI). When its disks are copied or it has a TPM, it is started paused for the migration instead (its CPUs never run) and shut off on the destination.
- **Encryption:** QEMU sends a VM's memory and copied disks in the clear. With **Encrypt migrations (TLS)** ticked on both hosts' edit pages (Advanced), it sends them over TLS. Each host needs QEMU's certificates from one CA: `ca-cert.pem`, `server-cert.pem`, `server-key.pem`, `client-cert.pem` and `client-key.pem` in `/etc/pki/qemu`, readable by QEMU (owner `root`, group the one QEMU runs as: `qemu` on the RHEL family and openSUSE, `kvm` on Debian and Ubuntu; keys `0640`), the server certificate naming the host's migration address (or the address the panel reaches it at) as it is written there, a name or an IP. A host without them refuses the migration before anything moves: `Unable to access credentials /etc/pki/qemu/ca-cert.pem`.
If libvirt warns `Host SMBIOS information is not available`, install `dmidecode` (`apt-get`, `dnf` or `zypper install -y dmidecode`) and restart `libvirtd` (`virtqemud` on the RHEL family 10).

View file

@ -61,5 +61,5 @@ class ComputeSerializer(serializers.ModelSerializer):
class Meta:
model = Compute
fields = ["id", "name", "hostname", "login", "password", "type", "details", "migration_address", "gstfsd_key",
"tags"]
fields = ["id", "name", "hostname", "login", "password", "type", "details", "migration_address", "migration_tls",
"gstfsd_key", "tags"]

View file

@ -154,4 +154,4 @@ class SocketComputeForm(ComputeTagsMixin, KeepSecretsMixin, forms.ModelForm):
widgets = SECRET_WIDGETS
labels = DETAILS
help_texts = DETAILS_HELP
fields = ["name", "details", "hostname", "migration_address", "gstfsd_key"]
fields = ["name", "details", "hostname", "migration_address", "migration_tls", "gstfsd_key"]

View file

@ -0,0 +1,18 @@
# Generated by Django 5.2.18 on 2026-11-19 11:56
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('computes', '0013_tag_length'),
]
operations = [
migrations.AddField(
model_name='compute',
name='migration_tls',
field=models.BooleanField(default=False, help_text="A VM migrating between two hosts that both have this sends its memory and disks over TLS; each host needs QEMU's certificates in /etc/pki/qemu", verbose_name='encrypt migrations (TLS)'),
),
]

View file

@ -4,7 +4,7 @@ from ipaddress import ip_address
from django.core.exceptions import ValidationError
from django.core.validators import MaxLengthValidator, RegexValidator
from django.db import IntegrityError, transaction
from django.db.models import CharField, DateTimeField, IntegerField, ManyToManyField, Model, Q, UniqueConstraint
from django.db.models import BooleanField, CharField, DateTimeField, IntegerField, ManyToManyField, Model, Q, UniqueConstraint
from django.utils.functional import cached_property
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext_noop
@ -69,6 +69,14 @@ class Compute(Model):
"empty: the address the panel reaches the host at"
),
)
migration_tls = BooleanField(
_("encrypt migrations (TLS)"),
default=False,
help_text=_(
"A VM migrating between two hosts that both have this sends its memory and disks over TLS; "
"each host needs QEMU's certificates in /etc/pki/qemu"
),
)
gstfsd_key = CharField(
_("gstfsd key"),
max_length=64,

View file

@ -33,16 +33,18 @@
</div>
</div>
{# open when one of them is set or refused #}
<details class="border-top pt-3"{% if form.migration_address.value or form.migration_address.errors or form.gstfsd_key.errors %} open{% endif %}>
<details class="border-top pt-3"{% if form.migration_address.value or form.migration_address.errors or form.migration_tls.value or form.gstfsd_key.errors %} open{% endif %}>
<summary>
<span class="fw-semibold">{% trans "Advanced" %}</span>
<span class="d-block small text-body-secondary text-break ms-3">
{% trans "Migration address" %}: {{ form.migration_address.value|default:_("the host name") }}
{% if form.migration_tls.value %}&middot; {% trans "migrations over TLS" %}{% endif %}
&middot; {% trans "gstfsd key" %}: {% if form.instance.gstfsd_key %}{% trans "stored" %}{% else %}{% trans "none" %}{% endif %}
</span>
</summary>
<div class="mt-3">
{% bootstrap_field form.migration_address %}
{% bootstrap_field form.migration_tls %}
{% bootstrap_field form.gstfsd_key %}
</div>
</details>

View file

@ -50,6 +50,13 @@ class MigrationAddressTests(TestCase):
self.client.post(reverse("compute_update", args=[compute.id]), {**data, "migration_address": "tcp://x"})
compute.refresh_from_db()
self.assertEqual(compute.migration_address, "198.51.100.9")
self.assertFalse(compute.migration_tls)
page = self.client.get(reverse("compute_update", args=[compute.id]))
self.assertContains(page, 'name="migration_tls"')
self.client.post(reverse("compute_update", args=[compute.id]), {**data, "migration_tls": "on"})
compute.refresh_from_db()
self.assertTrue(compute.migration_tls)
self.assertContains(self.client.get(reverse("compute_update", args=[compute.id])), "migrations over TLS")
def test_a_migration_uses_the_destination_address(self):
source = Compute.objects.create(name="ma-src", hostname="10.0.0.8", login="root", password="", type=2)

View file

@ -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:

View file

@ -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,

Binary file not shown.

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-11-19 10:35+0000\n"
"POT-Creation-Date: 2026-11-19 12:17+0000\n"
"PO-Revision-Date: \n"
"Last-Translator: \n"
"Language-Team: \n"
@ -295,7 +295,7 @@ msgstr "您在此处保持登录;您的其他会话将结束。"
#: admin/templates/admin/group_form.html:73
#: admin/templates/admin/user_form.html:160
#: admin/templates/admin/user_password_form.html:48
#: computes/templates/computes/form.html:52
#: computes/templates/computes/form.html:54
#: console/templates/console-vnc.html:86
#: instances/templates/add_instance_cdrom.html:38
#: instances/templates/add_instance_network_block.html:55
@ -634,46 +634,46 @@ msgid ""
"VMs that already have it keep it; VMs created from now on do not get it."
msgstr "已有此密钥的虚拟机会保留它;此后创建的虚拟机不会再获得它。"
#: accounts/views.py:237
#: accounts/views.py:238
msgid "Password Changed"
msgstr "密码已修改"
#: accounts/views.py:268
#: accounts/views.py:269
msgid "Create User Instance"
msgstr "创建用户虚拟机"
#: accounts/views.py:303
#: accounts/views.py:304
msgid "Update User Instance"
msgstr "更新用户虚拟机"
#: accounts/views.py:321
#: accounts/views.py:322
msgid "The user loses access to this VM; the VM itself is not changed."
msgstr "该用户将失去对此虚拟机的访问权限;虚拟机本身不受影响。"
#: accounts/views.py:356
#: accounts/views.py:357
#, python-format
msgid "OTP Sent to %(email)s"
msgstr "OTP 已发送至 %(email)s"
#: accounts/views.py:365
#: accounts/views.py:366
msgid "Email OTP"
msgstr "邮件发送 OTP"
#: accounts/views.py:399
#: accounts/views.py:400
#, python-format
msgid "The OTP QR code could not be mailed to %(user)s: %(error)s"
msgstr "无法将 OTP 二维码通过邮件发送给 %(user)s:%(error)s"
#: accounts/views.py:403
#: accounts/views.py:404
#, python-format
msgid "OTP QR code was emailed to user %(user)s"
msgstr "OTP 二维码已通过邮件发送给用户 %(user)s"
#: accounts/views.py:407
#: accounts/views.py:408
msgid "User email not set, failed to send QR code"
msgstr "未设置用户邮箱,无法发送二维码"
#: accounts/views.py:419
#: accounts/views.py:420
#, python-format
msgid "OTP of %(user)s was reset: a new QR code can be mailed."
msgstr "%(user)s 的 OTP 已重置:可以邮寄新的二维码。"
@ -2113,11 +2113,21 @@ msgid ""
"address the panel reaches the host at"
msgstr "其他主机向此主机迁移虚拟机时使用的 IP 地址或主机名;留空:使用面板连接该主机的地址"
#: computes/models.py:73 computes/templates/computes/form.html:41
#: computes/models.py:73
msgid "encrypt migrations (TLS)"
msgstr "加密迁移 (TLS)"
#: computes/models.py:76
msgid ""
"A VM migrating between two hosts that both have this sends its memory and "
"disks over TLS; each host needs QEMU's certificates in /etc/pki/qemu"
msgstr "在两台都启用此项的主机之间迁移的虚拟机通过 TLS 发送其内存和磁盘;每台主机都需要 /etc/pki/qemu 中的 QEMU 证书"
#: computes/models.py:81 computes/templates/computes/form.html:42
msgid "gstfsd key"
msgstr "gstfsd 密钥"
#: computes/models.py:79
#: computes/models.py:87
msgid ""
"GSTFSD_KEY in the host's /etc/default/webvirt-gstfsd: the panel sets the root"
" password and SSH key of a shut-off VM with it; empty: they cannot be set "
@ -2126,40 +2136,40 @@ msgstr ""
"主机 /etc/default/webvirt-gstfsd 中的 GSTFSD_KEY:面板用它为已关机的虚拟机设置 root 密码和 SSH "
"密钥;留空:无法在此设置"
#: computes/models.py:93 instances/models.py:38
#: computes/models.py:101 instances/models.py:38
msgid "tags"
msgstr "标签"
#: computes/models.py:109 computes/templates/computes/instances.html:12
#: computes/models.py:117 computes/templates/computes/instances.html:12
#, python-format
msgid "%(compute)s is in maintenance: no new VM or migration comes to it"
msgstr "%(compute)s 正在维护:不会在其上创建新虚拟机,也不会迁移虚拟机到它"
#: computes/models.py:115
#: computes/models.py:123
#, python-format
msgid ""
"%(compute)s is in maintenance: its VMs cannot be started there; migrate the "
"VM to start it on another host"
msgstr "%(compute)s 正在维护:其虚拟机无法在其上启动;请将虚拟机迁移到其他主机后再启动"
#: computes/models.py:242
#: computes/models.py:250
#, python-format
msgid "This host is already added as %(name)s"
msgstr "此主机已作为 %(name)s 添加"
#: computes/models.py:245
#: computes/models.py:253
#, python-format
msgid ""
"The panel cannot reach the host to tell that its VMs are there: %(error)s"
msgstr "面板无法连接该主机,因此无法确认其虚拟机在那里:%(error)s"
#: computes/models.py:252
#: computes/models.py:260
msgid ""
"The host its VMs are on is not known yet: change the connection when the "
"panel has reached the host at its current one"
msgstr "其虚拟机所在的主机尚不明确:请在面板通过当前连接访问到该主机后再更改连接"
#: computes/models.py:255
#: computes/models.py:263
msgid "This is another host than the one its VMs are on: add it as a new host"
msgstr "这不是其虚拟机所在的主机:请将其添加为新主机"
@ -2489,17 +2499,21 @@ msgid "the host name"
msgstr "主机名"
#: computes/templates/computes/form.html:41
msgid "migrations over TLS"
msgstr "迁移使用 TLS"
#: computes/templates/computes/form.html:42
msgid "stored"
msgstr "已保存"
#: computes/templates/computes/form.html:41
#: computes/templates/computes/form.html:42
#: instances/templates/instances/edit_instance_volume.html:82
#: instances/templates/instances/settings_tab.html:375
#: networks/templates/networks.html:63
msgid "none"
msgstr "无"
#: computes/templates/computes/form.html:53
#: computes/templates/computes/form.html:55
#: instances/templates/instances/edit_instance_volume.html:112
#: instances/templates/instances/nic_qos_form.html:23
#: instances/templates/instances/settings_tab.html:413
@ -3246,7 +3260,7 @@ msgstr "VNC 密码最多 8 个字母、数字或符号,不能有带重音的
msgid "A password takes no line breaks or other control characters."
msgstr "密码不能包含换行或其他控制字符。"
#: instances/forms.py:114 vrtManager/instance.py:1722
#: instances/forms.py:114 vrtManager/instance.py:1728
msgid ""
"The console listens on no address (on a network, a socket or nowhere); change"
" it in the XML editor"
@ -3333,7 +3347,7 @@ msgstr "虚拟机未定义;请检查这些卷,然后处理此任务:%(volu
msgid "Delete snapshot"
msgstr "删除快照"
#: instances/jobs.py:357 vrtManager/instance.py:2483
#: instances/jobs.py:357 vrtManager/instance.py:2489
#, python-format
msgid "The VM has no external snapshot named %(name)s"
msgstr "虚拟机没有名为 %(name)s 的外部快照"
@ -3365,7 +3379,7 @@ msgstr "虚拟机已不在运行该任务的计算节点上"
msgid "Take snapshot"
msgstr "创建快照"
#: instances/jobs.py:425 instances/jobs.py:434 vrtManager/instance.py:2072
#: instances/jobs.py:425 instances/jobs.py:434 vrtManager/instance.py:2078
#, python-format
msgid "A snapshot named %(name)s already exists"
msgstr "名为 %(name)s 的快照已存在"
@ -3506,12 +3520,12 @@ msgstr "镜像已存在。请检查卷或更改虚拟机名称"
msgid "Each network card needs a network"
msgstr "每个网卡都需要一个网络"
#: instances/jobs.py:868 vrtManager/backup.py:367 vrtManager/instance.py:2899
#: instances/jobs.py:868 vrtManager/backup.py:367 vrtManager/instance.py:2905
#, python-format
msgid "This host has no network %(name)s"
msgstr "此主机没有网络 %(name)s"
#: instances/jobs.py:870 vrtManager/backup.py:371 vrtManager/instance.py:2901
#: instances/jobs.py:870 vrtManager/backup.py:371 vrtManager/instance.py:2907
#, python-format
msgid "This host has no network filter %(name)s"
msgstr "此主机没有网络过滤器 %(name)s"
@ -3581,7 +3595,7 @@ msgstr "cloud-init 种子需要为磁盘使用目录类型的存储池"
msgid "This host offers no firmware %(firmware)s"
msgstr "此主机不提供固件 %(firmware)s"
#: instances/jobs.py:957 vrtManager/instance.py:3249
#: instances/jobs.py:957 vrtManager/instance.py:3255
msgid "This host offers no TPM 2.0: install swtpm on it"
msgstr "此主机不提供 TPM 2.0:请在主机上安装 swtpm"
@ -4827,7 +4841,7 @@ msgid "Add USB device"
msgstr "添加 USB 设备"
#: instances/templates/instances/host_devices_form.html:18
#: vrtManager/instance.py:3152
#: vrtManager/instance.py:3158
msgid ""
"A VM with a saved state does not change its USB devices: start it, or start "
"it without its saved state"
@ -6356,21 +6370,21 @@ msgstr "%(quota)s(%(total)s > %(limit)s)"
msgid "None available device name"
msgstr "没有可用的设备名称"
#: instances/utils.py:480
#: instances/utils.py:481
#, python-format
msgid "Connection Failed: %(host)s did not answer within %(seconds)s seconds"
msgstr "连接失败:%(host)s 在 %(seconds)s 秒内无响应"
#: instances/utils.py:508
#: instances/utils.py:509
#, python-format
msgid "%(hostname)s via %(address)s"
msgstr "%(hostname)s,经由 %(address)s"
#: instances/utils.py:541
#: instances/utils.py:542
msgid "Invalid MAC address"
msgstr "无效的 MAC 地址"
#: instances/utils.py:543
#: instances/utils.py:544
msgid "More MAC addresses than networks"
msgstr "MAC 地址数量多于网络数量"
@ -6694,7 +6708,7 @@ msgstr "卷已成功更改。"
msgid "Disk %(dev)s is not a storage volume of this instance"
msgstr "磁盘 %(dev)s 不是此虚拟机的存储卷"
#: instances/views.py:1615 vrtManager/instance.py:2493
#: instances/views.py:1615 vrtManager/instance.py:2499
msgid "The VM has a saved state; start it or remove the saved state first"
msgstr "虚拟机有保存的状态;请先启动它或删除保存的状态"
@ -6748,7 +6762,7 @@ msgstr "快照未删除:%(err)s"
msgid "Add at least one device to the boot order."
msgstr "请至少向启动顺序中添加一个设备。"
#: instances/views.py:1928 vrtManager/instance.py:1263
#: instances/views.py:1928 vrtManager/instance.py:1269
msgid "Invalid Device Type for boot order"
msgstr "启动顺序的设备类型无效"
@ -10313,7 +10327,7 @@ msgid ""
"Disks %(devs)s change at the next start; back the VM up after it restarts"
msgstr "磁盘 %(devs)s 将在下次启动时更改;请在虚拟机重启后再备份"
#: vrtManager/backup.py:126 vrtManager/instance.py:496
#: vrtManager/backup.py:126 vrtManager/instance.py:502
#, python-format
msgid ""
"The NVRAM file %(path)s is not in libvirt's NVRAM directory %(dir)s and "
@ -10417,320 +10431,320 @@ msgid ""
"from cannot be checked; start the pool first"
msgstr "存储池 %(pool)s 未激活:无法检查其中虚拟机磁盘所基于的文件;请先启动该存储池"
#: vrtManager/instance.py:180
#: vrtManager/instance.py:183
msgid "The VM is not running"
msgstr "虚拟机未在运行"
#: vrtManager/instance.py:185
#: vrtManager/instance.py:188
msgid "A running or paused VM cannot be migrated offline"
msgstr "运行中或已暂停的虚拟机不能离线迁移"
#: vrtManager/instance.py:188
#: vrtManager/instance.py:191
msgid "The VM can be migrated when it is running, paused or shut off"
msgstr "虚拟机在运行、暂停或关机时可以迁移"
#: vrtManager/instance.py:211
#: vrtManager/instance.py:214
msgid "A VM with snapshots cannot be migrated"
msgstr "有快照的虚拟机不能迁移"
#: vrtManager/instance.py:214
#: vrtManager/instance.py:217
msgid "A VM with a saved state cannot be migrated"
msgstr "有保存的状态的虚拟机不能迁移"
#: vrtManager/instance.py:221
#: vrtManager/instance.py:224
msgid "A VM with host devices cannot be migrated; remove them first"
msgstr "有主机设备的虚拟机不能迁移;请先移除它们"
#: vrtManager/instance.py:225
#: vrtManager/instance.py:228
#, python-format
msgid "The destination host does not have these networks of the VM: %(names)s"
msgstr "目标主机没有该虚拟机的这些网络:%(names)s"
#: vrtManager/instance.py:229
#: vrtManager/instance.py:232
#, python-format
msgid ""
"The destination host does not have these network filters of the VM: %(names)s"
msgstr "目标主机没有该虚拟机的这些网络过滤器:%(names)s"
#: vrtManager/instance.py:232
#: vrtManager/instance.py:235
#, python-format
msgid ""
"These network filters of the VM have other rules on the destination host: "
"%(names)s"
msgstr "该虚拟机的这些网络过滤器在目标主机上的规则不同:%(names)s"
#: vrtManager/instance.py:235
#: vrtManager/instance.py:238
#, python-format
msgid "The destination host does not have these secrets of the VM: %(names)s"
msgstr "目标主机没有该虚拟机的这些机密:%(names)s"
#: vrtManager/instance.py:242
#: vrtManager/instance.py:245
#, python-format
msgid "The destination host does not have these disks of the VM: %(disks)s"
msgstr "目标主机没有该虚拟机的这些磁盘:%(disks)s"
#: vrtManager/instance.py:243
#: vrtManager/instance.py:246
#, python-format
msgid "%(target)s (%(source)s)"
msgstr "%(target)s(%(source)s)"
#: vrtManager/instance.py:251
#: vrtManager/instance.py:254
msgid "Destination host emulator is different. Cannot be migrated"
msgstr "目标主机的模拟器不同,无法迁移"
#: vrtManager/instance.py:386
#: vrtManager/instance.py:392
msgid "an image is not copied; eject it first"
msgstr "镜像不会被复制;请先弹出它"
#: vrtManager/instance.py:389
#: vrtManager/instance.py:395
msgid "a read-only or encrypted disk is not copied"
msgstr "只读或加密的磁盘不会被复制"
#: vrtManager/instance.py:392
#: vrtManager/instance.py:398
msgid "only raw and qcow2 disks are copied"
msgstr "只复制 raw 和 qcow2 磁盘"
#: vrtManager/instance.py:394
#: vrtManager/instance.py:400
msgid "no storage pool of the source host has it"
msgstr "源主机的任何存储池中都没有它"
#: vrtManager/instance.py:396
#: vrtManager/instance.py:402
msgid "a disk with a backing file is not copied"
msgstr "有后备文件的磁盘不会被复制"
#: vrtManager/instance.py:416
#: vrtManager/instance.py:422
#, python-format
msgid ""
"%(target)s (%(path)s): the destination host does not share it; choose a pool "
"to copy it to"
msgstr "%(target)s (%(path)s):目标主机不共享它;请选择要复制到的存储池"
#: vrtManager/instance.py:420
#: vrtManager/instance.py:426
#, python-format
msgid "%(target)s (%(path)s): %(refusal)s"
msgstr "%(target)s (%(path)s):%(refusal)s"
#: vrtManager/instance.py:425
#: vrtManager/instance.py:431
#, python-format
msgid ""
"%(target)s (%(path)s): the destination host has no pool %(pool)s for disk "
"files"
msgstr "%(target)s (%(path)s):目标主机没有用于磁盘文件的存储池 %(pool)s"
#: vrtManager/instance.py:432
#: vrtManager/instance.py:438
#, python-format
msgid ""
"%(target)s (%(path)s): pool %(pool)s of the destination host already has a "
"file %(file)s"
msgstr "%(target)s (%(path)s):目标主机的存储池 %(pool)s 中已有文件 %(file)s"
#: vrtManager/instance.py:439
#: vrtManager/instance.py:445
#, python-format
msgid "%(target)s (%(path)s): another disk is copied to %(dest)s"
msgstr "%(target)s (%(path)s):另一个磁盘已复制到 %(dest)s"
#: vrtManager/instance.py:444
#: vrtManager/instance.py:450
#, python-format
msgid "%(target)s: the VM has no disk file to copy"
msgstr "%(target)s:虚拟机没有可复制的磁盘文件"
#: vrtManager/instance.py:448
#: vrtManager/instance.py:454
#, python-format
msgid ""
"%(target)s (%(path)s) of the next start: the destination host does not share "
"it"
msgstr "下次启动的 %(target)s (%(path)s):目标主机不共享它"
#: vrtManager/instance.py:452
#: vrtManager/instance.py:458
#, python-format
msgid "The disks cannot be migrated: %(problems)s"
msgstr "磁盘无法迁移:%(problems)s"
#: vrtManager/instance.py:465
#: vrtManager/instance.py:471
#, python-format
msgid ""
"%(error)s; remove the partial disk copies from the destination host: "
"%(copies)s"
msgstr "%(error)s;请从目标主机删除不完整的磁盘副本:%(copies)s"
#: vrtManager/instance.py:482
#: vrtManager/instance.py:488
#, python-format
msgid ""
"%(error)s; remove the partial disk copies from the destination host: %(left)s"
msgstr "%(error)s;请从目标主机删除不完整的磁盘副本:%(left)s"
#: vrtManager/instance.py:505
#: vrtManager/instance.py:511
#, python-format
msgid "The destination host cannot see the NVRAM file %(path)s"
msgstr "目标主机看不到 NVRAM 文件 %(path)s"
#: vrtManager/instance.py:586
#: vrtManager/instance.py:592
#, python-format
msgid "%(type)s disk, cannot be checked"
msgstr "%(type)s 磁盘,无法检查"
#: vrtManager/instance.py:626
#: vrtManager/instance.py:632
#, python-format
msgid "The destination host already has a VM %(key)s"
msgstr "目标主机上已有虚拟机 %(key)s"
#: vrtManager/instance.py:649
#: vrtManager/instance.py:655
msgid "The VM was started on the source host during the migration"
msgstr "迁移期间虚拟机在源主机上被启动"
#: vrtManager/instance.py:665
#: vrtManager/instance.py:671
#, python-format
msgid ""
"%(error)s; the VM may now be defined only on the destination host: check both"
" hosts"
msgstr "%(error)s;虚拟机现在可能只在目标主机上定义:请检查两台主机"
#: vrtManager/instance.py:671
#: vrtManager/instance.py:677
#, python-format
msgid ""
"%(error)s; the VM is now defined on both hosts, remove it from the "
"destination: %(undo_error)s"
msgstr "%(error)s;虚拟机现在在两台主机上都有定义,请从目标主机删除它:%(undo_error)s"
#: vrtManager/instance.py:677
#: vrtManager/instance.py:683
msgid ""
"Snapshot names are 1-64 letters, digits, '.', '_' or '-' and do not start "
"with '.'"
msgstr "快照名称为 1-64 个字母、数字、'.'、'_' 或 '-',且不能以 '.' 开头"
#: vrtManager/instance.py:735
#: vrtManager/instance.py:741
msgid "A VM with a host's or an external TPM is not cloned; remove it first"
msgstr "带有主机 TPM 或外部 TPM 的虚拟机无法克隆;请先将其移除"
#: vrtManager/instance.py:1251
#: vrtManager/instance.py:1257
msgid ""
"A device other than a disk or NIC is in the boot order: change it in the XML "
"editor"
msgstr "启动顺序中有磁盘或网卡以外的设备:请在 XML 编辑器中修改"
#: vrtManager/instance.py:1266
#: vrtManager/instance.py:1272
#, python-format
msgid "Boot device %(dev)s is not in the definition"
msgstr "启动设备 %(dev)s 不在定义中"
#: vrtManager/instance.py:1286
#: vrtManager/instance.py:1292
#, python-format
msgid "CD-ROM %(dev)s is not in the running definition"
msgstr "CD-ROM %(dev)s 不在运行中的定义中"
#: vrtManager/instance.py:1287
#: vrtManager/instance.py:1293
#, python-format
msgid "CD-ROM %(dev)s is not in the persistent definition"
msgstr "CD-ROM %(dev)s 不在持久定义中"
#: vrtManager/instance.py:1300
#: vrtManager/instance.py:1306
#, python-format
msgid "Media of %(dev)s changed in the running VM only: %(err)s"
msgstr "%(dev)s 的介质仅在运行中的虚拟机中更改:%(err)s"
#: vrtManager/instance.py:1311
#: vrtManager/instance.py:1317
#, python-format
msgid "ISO image %(image)s was not found"
msgstr "未找到 ISO 镜像 %(image)s"
#: vrtManager/instance.py:1313
#: vrtManager/instance.py:1319
#, python-format
msgid "ISO image %(image)s is in more than one storage pool"
msgstr "ISO 镜像 %(image)s 位于多个存储池中"
#: vrtManager/instance.py:1408
#: vrtManager/instance.py:1414
#, python-format
msgid "Disk %(target_dev)s is not in the VM's definition"
msgstr "磁盘 %(target_dev)s 不在虚拟机的定义中"
#: vrtManager/instance.py:1540
#: vrtManager/instance.py:1546
msgid "Please shutdown the instance then try to enable vCPU hotplug"
msgstr "请先关闭虚拟机,再启用 vCPU 热插拔"
#: vrtManager/instance.py:1743
#: vrtManager/instance.py:1749
#, python-format
msgid ""
"The serial console is a %(type)s one, the browser opens only a pty one; "
"change it in the XML editor"
msgstr "串行控制台的类型是 %(type)s,浏览器只能打开 pty 类型的;请在 XML 编辑器中更改"
#: vrtManager/instance.py:1854
#: vrtManager/instance.py:1860
msgid "The VM has no video card"
msgstr "虚拟机没有显卡"
#: vrtManager/instance.py:1864
#: vrtManager/instance.py:1870
#, python-format
msgid ""
"The VM's CPU topology has %(count)s vCPUs: change it in the XML editor to set"
" another maximum"
msgstr "该虚拟机的 CPU 拓扑为 %(count)s 个 vCPU:要设置其他最大值,请在 XML 编辑器中修改拓扑"
#: vrtManager/instance.py:1890
#: vrtManager/instance.py:1896
#, python-format
msgid "The VM's next start has a maximum memory of %(max)s MiB"
msgstr "虚拟机下次启动时的最大内存为 %(max)s MiB"
#: vrtManager/instance.py:2031
#: vrtManager/instance.py:2037
msgid ""
"The VM has external snapshots; internal snapshots cannot be mixed with them"
msgstr "虚拟机有外部快照;内部快照不能与其混用"
#: vrtManager/instance.py:2063
#: vrtManager/instance.py:2069
msgid "A snapshot with memory is not quiesced; it keeps the whole guest state"
msgstr "含内存的快照不会静默文件系统;它保存整个客户机状态"
#: vrtManager/instance.py:2065
#: vrtManager/instance.py:2071
msgid "Only a running VM's file systems can be frozen"
msgstr "只有运行中的虚拟机的文件系统可以冻结"
#: vrtManager/instance.py:2067
#: vrtManager/instance.py:2073
msgid "The QEMU guest agent is not connected; it freezes the file systems"
msgstr "QEMU 客户机代理未连接;文件系统由它冻结"
#: vrtManager/instance.py:2070
#: vrtManager/instance.py:2076
msgid ""
"The VM has internal snapshots; external snapshots cannot be mixed with them"
msgstr "虚拟机有内部快照;外部快照不能与其混用"
#: vrtManager/instance.py:2075
#: vrtManager/instance.py:2081
msgid "Newer snapshots exist after the last revert; delete them first"
msgstr "上次还原后存在更新的快照;请先删除它们"
#: vrtManager/instance.py:2078
#: vrtManager/instance.py:2084
msgid "No snapshot is current; revert to a snapshot first"
msgstr "没有当前快照;请先还原到某个快照"
#: vrtManager/instance.py:2084
#: vrtManager/instance.py:2090
#, python-format
msgid "Eject the media from %(dev)s first"
msgstr "请先弹出 %(dev)s 中的介质"
#: vrtManager/instance.py:2086
#: vrtManager/instance.py:2092
#, python-format
msgid "Disk %(dev)s is not a file; external snapshots need file disks"
msgstr "磁盘 %(dev)s 不是文件;外部快照需要文件磁盘"
#: vrtManager/instance.py:2094
#: vrtManager/instance.py:2100
#, python-format
msgid ""
"The storage pools could not be refreshed, so their free space is unknown: "
"%(err)s"
msgstr "无法刷新存储池,其可用空间未知:%(err)s"
#: vrtManager/instance.py:2117
#: vrtManager/instance.py:2123
msgid "Memory is saved only from a running VM"
msgstr "只能保存运行中的虚拟机的内存"
#: vrtManager/instance.py:2119
#: vrtManager/instance.py:2125
msgid "The VM has no disk to keep its memory next to"
msgstr "虚拟机没有可存放其内存的磁盘"
#: vrtManager/instance.py:2123
#: vrtManager/instance.py:2129
#, python-format
msgid "%(disk)s is not in a storage pool; memory is saved only into one"
msgstr "%(disk)s 不在存储池中;内存只能保存到存储池中"
#: vrtManager/instance.py:2154
#: vrtManager/instance.py:2160
#, python-format
msgid ""
"Storage pool %(pool)s has %(free).1f GiB free; the snapshot needs %(size).1f "
@ -10740,147 +10754,147 @@ msgstr ""
"存储池 %(pool)s 可用 %(free).1f GiB;快照需要 %(size).1f GiB(其中虚拟机磁盘的 %(percent)g%%,至少 "
"%(minimum)g GiB,若保存内存则另加内存)"
#: vrtManager/instance.py:2172
#: vrtManager/instance.py:2178
msgid ""
"This snapshot was taken by an older version on a UEFI VM and cannot be "
"reverted; delete it instead"
msgstr "此快照由旧版本在 UEFI 虚拟机上创建,无法还原;请将其删除"
#: vrtManager/instance.py:2202
#: vrtManager/instance.py:2208
#, python-format
msgid ""
"The revert failed twice; try again in a moment (%(error)s). The VM is "
"running."
msgstr "还原两次失败;请稍后重试(%(error)s)。虚拟机正在运行。"
#: vrtManager/instance.py:2204
#: vrtManager/instance.py:2210
#, python-format
msgid ""
"The revert failed twice; try again in a moment (%(error)s). The VM is shut "
"off."
msgstr "还原两次失败;请稍后重试(%(error)s)。虚拟机已关机。"
#: vrtManager/instance.py:2372
#: vrtManager/instance.py:2378
msgid "A disk moves when its VM is defined and running, paused or shut off"
msgstr "仅当虚拟机已定义且处于运行、暂停或关机状态时才能移动磁盘"
#: vrtManager/instance.py:2374
#: vrtManager/instance.py:2380
msgid ""
"A disk of a VM with snapshots, a saved state or a running block job does not "
"move"
msgstr "有快照、保存的状态或正在运行块任务的虚拟机的磁盘不能移动"
#: vrtManager/instance.py:2382
#: vrtManager/instance.py:2388
#, python-format
msgid ""
"%(dev)s is not a disk file of the VM, the same in its running and next "
"start's definition"
msgstr "%(dev)s 不是该虚拟机在运行中的定义和下次启动定义中相同的磁盘文件"
#: vrtManager/instance.py:2387
#: vrtManager/instance.py:2393
#, python-format
msgid "%(dev)s does not move: only writable raw and qcow2 disks do"
msgstr "%(dev)s 不能移动:只能移动可写的 raw 和 qcow2 磁盘"
#: vrtManager/instance.py:2394
#: vrtManager/instance.py:2400
#, python-format
msgid "%(dev)s does not move: no storage pool has %(path)s"
msgstr "%(dev)s 不能移动:没有存储池包含 %(path)s"
#: vrtManager/instance.py:2396
#: vrtManager/instance.py:2402
#, python-format
msgid "%(dev)s does not move: it has a backing file"
msgstr "%(dev)s 不能移动:它有后备文件"
#: vrtManager/instance.py:2399
#: vrtManager/instance.py:2405
#, python-format
msgid "%(pool_name)s is not an active pool of disk files of this host"
msgstr "%(pool_name)s 不是此主机上活动的磁盘文件存储池"
#: vrtManager/instance.py:2402
#: vrtManager/instance.py:2408
#, python-format
msgid "%(dev)s is in pool %(pool_name)s already"
msgstr "%(dev)s 已在存储池 %(pool_name)s 中"
#: vrtManager/instance.py:2406
#: vrtManager/instance.py:2412
#, python-format
msgid "Pool %(pool_name)s already has a file %(name)s"
msgstr "存储池 %(pool_name)s 中已有文件 %(name)s"
#: vrtManager/instance.py:2430
#: vrtManager/instance.py:2436
#, python-format
msgid "The copy of %(dev)s ended before it was complete"
msgstr "%(dev)s 的复制在完成前结束"
#: vrtManager/instance.py:2475
#: vrtManager/instance.py:2481
#, python-format
msgid "%(error)s; remove %(dest)s if it is there: %(cleanup_error)s"
msgstr "%(error)s;如果 %(dest)s 存在请将其删除:%(cleanup_error)s"
#: vrtManager/instance.py:2477
#: vrtManager/instance.py:2483
#, python-format
msgid "%(error)s; the VM may use %(dest)s now: check its disk %(dev)s"
msgstr "%(error)s;虚拟机现在可能在使用 %(dest)s:请检查其磁盘 %(dev)s"
#: vrtManager/instance.py:2484
#: vrtManager/instance.py:2490
#, python-format
msgid "The VM has no internal snapshot named %(name)s"
msgstr "虚拟机没有名为 %(name)s 的内部快照"
#: vrtManager/instance.py:2495
#: vrtManager/instance.py:2501
msgid "A snapshot job is still running on this VM; try again when it ends"
msgstr "此虚拟机上仍有快照任务在运行;请在其结束后重试"
#: vrtManager/instance.py:2505
#: vrtManager/instance.py:2511
msgid "Shut the VM down to revert to an internal snapshot"
msgstr "请关闭虚拟机后再还原到内部快照"
#: vrtManager/instance.py:2572
#: vrtManager/instance.py:2578
msgid "Cannot clone a VM whose NVRAM is not a file"
msgstr "NVRAM 不是文件的虚拟机无法克隆"
#: vrtManager/instance.py:2643
#: vrtManager/instance.py:2649
#, python-format
msgid "Clone failed (%(err)s); remove these copies by hand: %(path)s"
msgstr "克隆失败(%(err)s);请手动删除这些副本:%(path)s"
#: vrtManager/instance.py:2654
#: vrtManager/instance.py:2660
msgid "Shut the VM down before cloning it"
msgstr "请先关闭虚拟机再克隆"
#: vrtManager/instance.py:2681
#: vrtManager/instance.py:2687
#, python-format
msgid "Clone failed (%(err)s); remove these copies by hand: %(leftovers)s"
msgstr "克隆失败(%(err)s);请手动删除这些副本:%(leftovers)s"
#: vrtManager/instance.py:2692
#: vrtManager/instance.py:2698
msgid "Live clone needs libvirt 11.10 or later; shut the VM down to clone it"
msgstr "在线克隆需要 libvirt 11.10 或更高版本;请关闭虚拟机后再克隆"
#: vrtManager/instance.py:2695
#: vrtManager/instance.py:2701
msgid "A VM with a TPM is cloned only shut down"
msgstr "带 TPM 的虚拟机只能在关机时克隆"
#: vrtManager/instance.py:2698
#: vrtManager/instance.py:2704
#, python-format
msgid "Disk %(dev)s is not a local file; shut the VM down to clone it"
msgstr "磁盘 %(dev)s 不是本地文件;请关闭虚拟机后再克隆"
#: vrtManager/instance.py:2700
#: vrtManager/instance.py:2706
#, python-format
msgid "Disk %(dev)s is shareable; shut the VM down to clone it"
msgstr "磁盘 %(dev)s 是可共享的;请关闭虚拟机后再克隆"
#: vrtManager/instance.py:2705
#: vrtManager/instance.py:2711
#, python-format
msgid "Disk %(dev)s changes at the next start; shut the VM down to clone it"
msgstr "磁盘 %(dev)s 在下次启动时会改变;请关闭虚拟机后再克隆"
#: vrtManager/instance.py:2707
#: vrtManager/instance.py:2713
msgid "Another job is running on the VM; clone it when that ends"
msgstr "虚拟机上有另一个任务正在运行;请在其结束后再克隆"
#: vrtManager/instance.py:2733
#: vrtManager/instance.py:2739
#, python-format
msgid ""
"Storage pool %(pool)s has %(free).1f GiB free; the clone needs %(size).1f GiB"
@ -10889,111 +10903,111 @@ msgstr ""
"存储池 %(pool)s 可用 %(free).1f GiB;克隆需要 %(size).1f GiB(复制的磁盘,再加其 %(percent)g%%,至少"
" %(minimum)g GiB)"
#: vrtManager/instance.py:2750
#: vrtManager/instance.py:2756
#, python-format
msgid "Volume %(name)s already exists in storage pool %(pool)s"
msgstr "卷 %(name)s 已存在于存储池 %(pool)s 中"
#: vrtManager/instance.py:2938
#: vrtManager/instance.py:2944
msgid "A network interface that is a host device is removed in the XML editor"
msgstr "作为主机设备的网络接口需在 XML 编辑器中删除"
#: vrtManager/instance.py:2954
#: vrtManager/instance.py:2960
#, python-format
msgid "No network interface with MAC %(old_mac)s"
msgstr "没有 MAC 为 %(old_mac)s 的网络接口"
#: vrtManager/instance.py:2957
#: vrtManager/instance.py:2963
msgid "A network interface that is a host device is changed in the XML editor"
msgstr "作为主机设备的网络接口需在 XML 编辑器中修改"
#: vrtManager/instance.py:3051
#: vrtManager/instance.py:3057
msgid ""
"A VM changes its PCI devices while it runs, or is shut off without a saved "
"state"
msgstr "虚拟机只能在运行时或无保存的状态的关机时更改其 PCI 设备"
#: vrtManager/instance.py:3072
#: vrtManager/instance.py:3078
#, python-format
msgid "%(err)s; whether the VM has %(device)s now is not known"
msgstr "%(err)s;虚拟机现在是否有 %(device)s 未知"
#: vrtManager/instance.py:3074
#: vrtManager/instance.py:3080
#, python-format
msgid "%(err)s; %(device)s: the VM is not running, its next start has it"
msgstr "%(err)s;%(device)s:虚拟机未运行,下次启动时有它"
#: vrtManager/instance.py:3075
#: vrtManager/instance.py:3081
#, python-format
msgid ""
"%(err)s; %(device)s: the VM is not running, its next start does not have it"
msgstr "%(err)s;%(device)s:虚拟机未运行,下次启动时没有它"
#: vrtManager/instance.py:3076
#: vrtManager/instance.py:3082
#, python-format
msgid "%(err)s; %(device)s: the running VM has it, its next start has it"
msgstr "%(err)s;%(device)s:运行中的虚拟机有它,下次启动时有它"
#: vrtManager/instance.py:3077
#: vrtManager/instance.py:3083
#, python-format
msgid ""
"%(err)s; %(device)s: the running VM has it, its next start does not have it"
msgstr "%(err)s;%(device)s:运行中的虚拟机有它,下次启动时没有它"
#: vrtManager/instance.py:3078
#: vrtManager/instance.py:3084
#, python-format
msgid ""
"%(err)s; %(device)s: the running VM does not have it, its next start has it"
msgstr "%(err)s;%(device)s:运行中的虚拟机没有它,下次启动时有它"
#: vrtManager/instance.py:3080
#: vrtManager/instance.py:3086
#, python-format
msgid ""
"%(err)s; %(device)s: the running VM does not have it, its next start does not"
" have it"
msgstr "%(err)s;%(device)s:运行中的虚拟机没有它,下次启动时没有它"
#: vrtManager/instance.py:3114
#: vrtManager/instance.py:3120
#, python-format
msgid "The VM has no PCI device %(address)s"
msgstr "虚拟机没有 PCI 设备 %(address)s"
#: vrtManager/instance.py:3135
#: vrtManager/instance.py:3141
msgid "The VM has no USB controller"
msgstr "虚拟机没有 USB 控制器"
#: vrtManager/instance.py:3169
#: vrtManager/instance.py:3175
msgid "The VM has no such USB device"
msgstr "虚拟机没有此 USB 设备"
#: vrtManager/instance.py:3183
#: vrtManager/instance.py:3189
#, python-format
msgid "The VM has no network interface %(mac)s"
msgstr "虚拟机没有网络接口 %(mac)s"
#: vrtManager/instance.py:3215
#: vrtManager/instance.py:3221
msgid "The VM has its own RNG device: change it in the XML editor"
msgstr "虚拟机有自己的 RNG 设备:请在 XML 编辑器中修改"
#: vrtManager/instance.py:3242
#: vrtManager/instance.py:3248
msgid "The VM has its own TPM: change it in the XML editor"
msgstr "虚拟机有自己的 TPM:请在 XML 编辑器中修改"
#: vrtManager/instance.py:3261
#: vrtManager/instance.py:3267
#, python-format
msgid "Unknown crash action %(action)s"
msgstr "未知的崩溃操作 %(action)s"
#: vrtManager/instance.py:3288
#: vrtManager/instance.py:3294
#, python-format
msgid "Network interface %(mac)s is not in the definition"
msgstr "网络接口 %(mac)s 不在定义中"
#: vrtManager/instance.py:3379
#: vrtManager/instance.py:3385
msgid "The guest agent did not answer in time; nothing was changed"
msgstr "客户机代理未及时响应;未做任何更改"
#: vrtManager/instance.py:3382
#: vrtManager/instance.py:3388
msgid "The VM runs Windows: its guest agent sets no root password or SSH key"
msgstr "该虚拟机运行 Windows:其客户机代理不能设置 root 密码或 SSH 密钥"

View file

@ -38,6 +38,7 @@ from libvirt import (
VIR_STORAGE_VOL_FILE,
VIR_MIGRATE_AUTO_CONVERGE,
VIR_MIGRATE_COMPRESSED,
VIR_MIGRATE_TLS,
VIR_MIGRATE_LIVE,
VIR_MIGRATE_NON_SHARED_DISK,
VIR_MIGRATE_OFFLINE,
@ -159,7 +160,7 @@ class wvmInstances(wvmConnect):
return sorted(missing), sorted(unlike)
def moveto(self, conn, name, live, unsafe, offline, autoconverge=False, compress=False, uri=None,
pools=None, on_copy=None, running_only=False):
pools=None, on_copy=None, running_only=False, tls=False):
"""Migrates the VM of conn (a wvmInstance on the source) here.
The mode follows the VM's state, read once: a running VM migrates
@ -173,7 +174,9 @@ class wvmInstances(wvmConnect):
libvirt copies into those pools during the migration (disk_copies);
the other disks must be on storage both hosts share. on_copy is
called with the copies ({pool, dest}: a pool here and its path) before
libvirt makes them. Returns the mode and options used, for the log,
libvirt makes them. tls: QEMU sends the memory and disks over TLS (the
hosts' certificates in /etc/pki/qemu); a shut-off VM's definition alone
sends none. Returns the mode and options used, for the log,
and each copied disk's path and the path of its copy here."""
state = conn.get_status()
if running_only and state != 1:
@ -253,6 +256,9 @@ class wvmInstances(wvmConnect):
# the TPM state is a file of the source host: a live migration carries it
tpm_state = etree.fromstring(definitions[0]).xpath("devices/tpm/backend[@type='emulator']")
if tls and (state != 5 or copies or tpm_state):
flags |= VIR_MIGRATE_TLS
mode.append("TLS")
if copies or (state == 5 and tpm_state):
if copies and on_copy is not None:
on_copy([{"pool": copy["pool"].name(), "dest": copy["dest"]} for copy in copies])

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>"