]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuProcessLaunch: Tighten rules for external devices wrt incoming migration
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 27 Jan 2023 12:59:08 +0000 (13:59 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 6 Feb 2023 15:33:26 +0000 (16:33 +0100)
When starting a guest, helper processes are started first. But
they need a bit of special handling. Just consider a regular cold
boot and an incoming migration. For instance, in case of swtpm
with its state on a shared volume, we want to set label on the
state for the cold boot case, but don't want to touch the label
in case of incoming migration (because the source very
specifically did not restore it either).

Until now, these two cases were differentiated by testing
@incoming against NULL. And while that makes sense for other
aspects of domain startup, for external devices we need a bit
more, because a restore from a save file is also 'incoming
migration'.

Now, there is a difference between regular migration and restore
from a save file. In the former case we do not want to set
seclabels in the save state. BUT, in the latter case we do need
to set them, because the code that saves the machine restored
seclabels.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2161557
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_process.c

index 05503edab50270eb8dc5b61cc080edd897f26b5c..e96b7689a3ebb441939c59c0245531d93833c659 100644 (file)
@@ -7621,6 +7621,7 @@ qemuProcessLaunch(virConnectPtr conn,
     size_t nnicindexes = 0;
     g_autofree int *nicindexes = NULL;
     unsigned long long maxMemLock = 0;
+    bool incomingMigrationExtDevices = false;
 
     VIR_DEBUG("conn=%p driver=%p vm=%p name=%s id=%d asyncJob=%d "
               "incoming.uri=%s "
@@ -7675,7 +7676,13 @@ qemuProcessLaunch(virConnectPtr conn,
     if (qemuDomainSchedCoreStart(cfg, vm) < 0)
         goto cleanup;
 
-    if (qemuExtDevicesStart(driver, vm, incoming != NULL) < 0)
+    /* For external devices the rules of incoming migration are a bit stricter,
+     * than plain @incoming != NULL. They need to differentiate between
+     * incoming migration and restore from a save file.  */
+    incomingMigrationExtDevices = incoming &&
+        vmop == VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_IN_START;
+
+    if (qemuExtDevicesStart(driver, vm, incomingMigrationExtDevices) < 0)
         goto cleanup;
 
     if (!(cmd = qemuBuildCommandLine(vm,