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 f3d5f3937d..0e8dd7748c 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);
@@ -5906,7 +5906,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);
@@ -6221,7 +6221,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);
@@ -6484,7 +6484,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 004e84556c..93cd446b23 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2139,7 +2139,8 @@ int
qemuMigrationDstRun(virQEMUDriver *driver,
virDomainObj *vm,
const char *uri,
- virDomainAsyncJob asyncJob)
+ virDomainAsyncJob asyncJob,
+ bool wait)
{
qemuDomainObjPrivate *priv = vm->privateData;
int rv;
@@ -2160,14 +2161,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;
}
@@ -3041,7 +3043,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 b0b00eb0a2..0a1e7985fb 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -7788,6 +7788,7 @@ qemuProcessStart(virConnectPtr conn,
const char *migrateFrom,
int migrateFd,
const char *migratePath,
+ bool wait_incoming,
virDomainMomentObj *snapshot,
virNetDevVPortProfileOp vmop,
unsigned int flags)
@@ -7850,7 +7851,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 485e3163b7..83dea78718 100644
--- a/src/qemu/qemu_saveimage.c
+++ b/src/qemu/qemu_saveimage.c
@@ -781,6 +781,7 @@ qemuSaveImageStartVM(virConnectPtr conn,
const char *path,
bool start_paused,
bool reset_nvram,
+ bool wait_incoming,
virDomainAsyncJob asyncJob)
{
qemuDomainObjPrivate *priv = vm->privateData;
@@ -835,7 +836,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 356fc7561e..412624b968 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