[libvirt RFCv11 22/33] qemu: add parameter to qemuMigrationDstRun to skip waiting

Claudio Fontana cfontana at suse.de
Tue Jun 7 09:19:25 UTC 2022


The distinction on whether to wait for the migration completion
or not was made on the async job type,

but with the future addition of multifd migration from files,
we need a way to avoid waiting, so we can prepare multifd
migration parameters before starting the transfers.

Adapt all callers.

Signed-off-by: Claudio Fontana <cfontana at suse.de>
---
 src/qemu/qemu_driver.c    |  8 ++++----
 src/qemu/qemu_migration.c | 18 ++++++++++--------
 src/qemu/qemu_migration.h |  3 ++-
 src/qemu/qemu_process.c   |  3 ++-
 src/qemu/qemu_process.h   |  5 +++--
 src/qemu/qemu_saveimage.c |  4 +++-
 src/qemu/qemu_saveimage.h |  1 +
 src/qemu/qemu_snapshot.c  |  4 ++--
 8 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d403ff6bf2..3d2b5d78e6 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1639,7 +1639,7 @@ static virDomainPtr qemuDomainCreateXML(virConnectPtr conn,
     }
 
     if (qemuProcessStart(conn, driver, vm, NULL, VIR_ASYNC_JOB_START,
-                         NULL, -1, NULL, NULL,
+                         NULL, -1, NULL, false, NULL,
                          VIR_NETDEV_VPORT_PROFILE_OP_CREATE,
                          start_flags) < 0) {
         virDomainAuditStart(vm, "booted", false);
@@ -5940,7 +5940,7 @@ qemuDomainRestoreInternal(virConnectPtr conn,
         goto cleanup;
 
     ret = qemuSaveImageStartVM(conn, driver, vm, &saveFd.fd, data, path,
-                               false, reset_nvram, VIR_ASYNC_JOB_START);
+                               false, reset_nvram, true, VIR_ASYNC_JOB_START);
 
     qemuProcessEndJob(vm);
 
@@ -6261,7 +6261,7 @@ qemuDomainObjRestore(virConnectPtr conn,
     virDomainObjAssignDef(vm, &def, true, NULL);
 
     ret = qemuSaveImageStartVM(conn, driver, vm, &saveFd.fd, data, path,
-                               start_paused, reset_nvram, asyncJob);
+                               start_paused, reset_nvram, true, asyncJob);
 
  cleanup:
     virQEMUSaveDataFree(data);
@@ -6515,7 +6515,7 @@ qemuDomainObjStart(virConnectPtr conn,
     }
 
     ret = qemuProcessStart(conn, driver, vm, NULL, asyncJob,
-                           NULL, -1, NULL, NULL,
+                           NULL, -1, NULL, false, NULL,
                            VIR_NETDEV_VPORT_PROFILE_OP_CREATE, start_flags);
     virDomainAuditStart(vm, "booted", ret >= 0);
     if (ret >= 0) {
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index fa6cddcc59..439dd7478d 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2122,7 +2122,8 @@ int
 qemuMigrationDstRun(virQEMUDriver *driver,
                     virDomainObj *vm,
                     const char *uri,
-                    virDomainAsyncJob asyncJob)
+                    virDomainAsyncJob asyncJob,
+                    bool wait)
 {
     qemuDomainObjPrivate *priv = vm->privateData;
     int rv;
@@ -2143,14 +2144,15 @@ qemuMigrationDstRun(virQEMUDriver *driver,
     if (rv < 0)
         return -1;
 
-    if (asyncJob == VIR_ASYNC_JOB_MIGRATION_IN) {
-        /* qemuMigrationDstWaitForCompletion is called from the Finish phase */
-        return 0;
+    if (wait) {
+        /*
+         * the Migration Finish phase, as well as the multifd load from files,
+         * need to call qemuMigrationDstWaitForCompletion separately, not here.
+         */
+        if (qemuMigrationDstWaitForCompletion(driver, vm, asyncJob, false) < 0)
+            return -1;
     }
 
-    if (qemuMigrationDstWaitForCompletion(driver, vm, asyncJob, false) < 0)
-        return -1;
-
     return 0;
 }
 
@@ -3024,7 +3026,7 @@ qemuMigrationDstPrepareAny(virQEMUDriver *driver,
     }
 
     if (qemuMigrationDstRun(driver, vm, incoming->uri,
-                            VIR_ASYNC_JOB_MIGRATION_IN) < 0)
+                            VIR_ASYNC_JOB_MIGRATION_IN, false) < 0)
         goto stopjob;
 
     if (qemuProcessFinishStartup(driver, vm, VIR_ASYNC_JOB_MIGRATION_IN,
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
index ddc8e65489..c3c48c19c0 100644
--- a/src/qemu/qemu_migration.h
+++ b/src/qemu/qemu_migration.h
@@ -255,7 +255,8 @@ int
 qemuMigrationDstRun(virQEMUDriver *driver,
                     virDomainObj *vm,
                     const char *uri,
-                    virDomainAsyncJob asyncJob);
+                    virDomainAsyncJob asyncJob,
+                    bool wait);
 
 void
 qemuMigrationAnyPostcopyFailed(virQEMUDriver *driver,
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 1593ca7933..40870b8f7a 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -7742,6 +7742,7 @@ qemuProcessStart(virConnectPtr conn,
                  const char *migrateFrom,
                  int migrateFd,
                  const char *migratePath,
+                 bool wait_incoming,
                  virDomainMomentObj *snapshot,
                  virNetDevVPortProfileOp vmop,
                  unsigned int flags)
@@ -7804,7 +7805,7 @@ qemuProcessStart(virConnectPtr conn,
     relabel = true;
 
     if (incoming) {
-        if (qemuMigrationDstRun(driver, vm, incoming->uri, asyncJob) < 0)
+        if (qemuMigrationDstRun(driver, vm, incoming->uri, asyncJob, wait_incoming) < 0)
             goto stop;
     } else {
         /* Refresh state of devices from QEMU. During migration this happens
diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h
index 9866d2bf35..aad34ae0d8 100644
--- a/src/qemu/qemu_process.h
+++ b/src/qemu/qemu_process.h
@@ -86,8 +86,9 @@ int qemuProcessStart(virConnectPtr conn,
                      virCPUDef *updatedCPU,
                      virDomainAsyncJob asyncJob,
                      const char *migrateFrom,
-                     int stdin_fd,
-                     const char *stdin_path,
+                     int fd,
+                     const char *migratePath,
+                     bool wait_incoming,
                      virDomainMomentObj *snapshot,
                      virNetDevVPortProfileOp vmop,
                      unsigned int flags);
diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c
index 8abb919459..9c86e20f30 100644
--- a/src/qemu/qemu_saveimage.c
+++ b/src/qemu/qemu_saveimage.c
@@ -780,6 +780,7 @@ qemuSaveImageStartVM(virConnectPtr conn,
                      const char *path,
                      bool start_paused,
                      bool reset_nvram,
+                     bool wait_incoming,
                      virDomainAsyncJob asyncJob)
 {
     qemuDomainObjPrivate *priv = vm->privateData;
@@ -834,7 +835,8 @@ qemuSaveImageStartVM(virConnectPtr conn,
         priv->disableSlirp = true;
 
     if (qemuProcessStart(conn, driver, vm, cookie ? cookie->cpu : NULL,
-                         asyncJob, "stdio", *fd, path, NULL,
+                         asyncJob, "stdio", *fd, path, wait_incoming,
+                         NULL,
                          VIR_NETDEV_VPORT_PROFILE_OP_RESTORE,
                          start_flags) == 0)
         started = true;
diff --git a/src/qemu/qemu_saveimage.h b/src/qemu/qemu_saveimage.h
index 2af873dea9..91ea8dcbf2 100644
--- a/src/qemu/qemu_saveimage.h
+++ b/src/qemu/qemu_saveimage.h
@@ -97,6 +97,7 @@ qemuSaveImageStartVM(virConnectPtr conn,
                      const char *path,
                      bool start_paused,
                      bool reset_nvram,
+                     bool wait_incoming,
                      virDomainAsyncJob asyncJob)
     ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5) ATTRIBUTE_NONNULL(6);
 
diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c
index 3437c3e0cb..dec653c6d3 100644
--- a/src/qemu/qemu_snapshot.c
+++ b/src/qemu/qemu_snapshot.c
@@ -2092,7 +2092,7 @@ qemuSnapshotRevertActive(virDomainObj *vm,
 
     rc = qemuProcessStart(snapshot->domain->conn, driver, vm,
                           cookie ? cookie->cpu : NULL,
-                          VIR_ASYNC_JOB_START, NULL, -1, NULL, snap,
+                          VIR_ASYNC_JOB_START, NULL, -1, NULL, false, snap,
                           VIR_NETDEV_VPORT_PROFILE_OP_CREATE,
                           start_flags);
     virDomainAuditStart(vm, "from-snapshot", rc >= 0);
@@ -2215,7 +2215,7 @@ qemuSnapshotRevertInactive(virDomainObj *vm,
         start_flags |= paused ? VIR_QEMU_PROCESS_START_PAUSED : 0;
 
         rc = qemuProcessStart(snapshot->domain->conn, driver, vm, NULL,
-                              VIR_ASYNC_JOB_START, NULL, -1, NULL, NULL,
+                              VIR_ASYNC_JOB_START, NULL, -1, NULL, false, NULL,
                               VIR_NETDEV_VPORT_PROFILE_OP_CREATE,
                               start_flags);
         virDomainAuditStart(vm, "from-snapshot", rc >= 0);
-- 
2.26.2



More information about the libvir-list mailing list