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(a)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 a03ead960b..4dc106a621 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1630,7 +1630,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);
@@ -5926,7 +5926,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);
@@ -6247,7 +6247,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);
@@ -6507,7 +6507,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 019e7bd299..6250b707b3 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 fd4db43a42..7f3bfbdbbd 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -7793,6 +7793,7 @@ qemuProcessStart(virConnectPtr conn,
const char *migrateFrom,
int migrateFd,
const char *migratePath,
+ bool wait_incoming,
virDomainMomentObj *snapshot,
virNetDevVPortProfileOp vmop,
unsigned int flags)
@@ -7855,7 +7856,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 f81bfd930a..5a1d005cb0 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 92f619a5f1..c652293a02 100644
--- a/src/qemu/qemu_saveimage.c
+++ b/src/qemu/qemu_saveimage.c
@@ -823,6 +823,7 @@ qemuSaveImageStartVM(virConnectPtr conn,
const char *path,
bool start_paused,
bool reset_nvram,
+ bool wait_incoming,
virDomainAsyncJob asyncJob)
{
qemuDomainObjPrivate *priv = vm->privateData;
@@ -877,7 +878,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 21e335b530..952c5cd58a 100644
--- a/src/qemu/qemu_saveimage.h
+++ b/src/qemu/qemu_saveimage.h
@@ -99,6 +99,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 2e445e8296..626a5a14b9 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.35.3