Any job which touches migration parameters will first store their original values (i.e., QEMU defaults) to qemuDomainJobObj to make it easier to reset them back once the job finishes. Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> --- src/qemu/qemu_domain.c | 3 +++ src/qemu/qemu_domain.h | 3 +++ src/qemu/qemu_migration.c | 9 ++++++++ src/qemu/qemu_migration_params.c | 38 ++++++++++++++++++++++++++++++++ src/qemu/qemu_migration_params.h | 5 +++++ 5 files changed, 58 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index a1bbe256f5..e44073f441 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -336,6 +336,8 @@ qemuDomainObjResetAsyncJob(qemuDomainObjPrivatePtr priv) job->dumpCompleted = false; VIR_FREE(job->error); VIR_FREE(job->current); + qemuMigrationParamsFree(job->migParams); + job->migParams = NULL; } void @@ -350,6 +352,7 @@ qemuDomainObjRestoreJob(virDomainObjPtr obj, job->asyncJob = priv->job.asyncJob; job->asyncOwner = priv->job.asyncOwner; job->phase = priv->job.phase; + VIR_STEAL_PTR(job->migParams, priv->job.migParams); qemuDomainObjResetJob(priv); qemuDomainObjResetAsyncJob(priv); diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 415b2ca093..1828b64284 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -34,6 +34,7 @@ # include "qemu_agent.h" # include "qemu_conf.h" # include "qemu_capabilities.h" +# include "qemu_migration_params.h" # include "virmdev.h" # include "virchrdev.h" # include "virobject.h" @@ -177,6 +178,8 @@ struct qemuDomainJobObj { bool postcopyEnabled; /* post-copy migration was enabled */ char *error; /* job event completion error */ bool dumpCompleted; /* dump completed */ + + qemuMigrationParamsPtr migParams; }; typedef void (*qemuDomainCleanupCallback)(virQEMUDriverPtr driver, diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 73024d66c0..7fd85bc6c5 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2451,6 +2451,9 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver, dataFD[1] = -1; /* 'st' owns the FD now & will close it */ } + if (qemuMigrationParamsCheck(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN) < 0) + goto stopjob; + if (qemuMigrationParamsSetCompression(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN, compression, migParams) < 0) goto stopjob; @@ -4600,6 +4603,9 @@ qemuMigrationSrcPerformJob(virQEMUDriverPtr driver, qemuMigrationSrcStoreDomainState(vm); + if (qemuMigrationParamsCheck(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT) < 0) + goto endjob; + if ((flags & (VIR_MIGRATE_TUNNELLED | VIR_MIGRATE_PEER2PEER))) { ret = qemuMigrationSrcPerformPeer2Peer(driver, conn, vm, xmlin, persist_xml, dconnuri, uri, graphicsuri, listenAddress, @@ -4703,6 +4709,9 @@ qemuMigrationSrcPerformPhase(virQEMUDriverPtr driver, virCloseCallbacksUnset(driver->closeCallbacks, vm, qemuMigrationSrcCleanup); + if (qemuMigrationParamsCheck(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT) < 0) + goto endjob; + ret = qemuMigrationSrcPerformNative(driver, vm, persist_xml, uri, cookiein, cookieinlen, cookieout, cookieoutlen, flags, resource, NULL, graphicsuri, diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c index 187c0c2258..4defc62ae5 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -428,6 +428,44 @@ qemuMigrationParamsResetTLS(virQEMUDriverPtr driver, } +/** + * qemuMigrationParamsCheck: + * + * Check supported migration parameters and keep their original values in + * qemuDomainJobObj so that we can properly reset them at the end of migration. + */ +int +qemuMigrationParamsCheck(virQEMUDriverPtr driver, + virDomainObjPtr vm, + int asyncJob) +{ + qemuDomainObjPrivatePtr priv = vm->privateData; + qemuMigrationParamsPtr origParams = NULL; + int ret = -1; + + if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) + return -1; + + if (!(origParams = qemuMigrationParamsNew())) + goto cleanup; + + if (qemuMonitorGetMigrationParams(priv->mon, &origParams->params) < 0) + goto cleanup; + + ret = 0; + + cleanup: + if (qemuDomainObjExitMonitor(driver, vm) < 0) + ret = -1; + + if (ret == 0) + VIR_STEAL_PTR(priv->job.migParams, origParams); + qemuMigrationParamsFree(origParams); + + return ret; +} + + /* * qemuMigrationParamsReset: * diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_params.h index f5e64dcc1d..a6125a6f3d 100644 --- a/src/qemu/qemu_migration_params.h +++ b/src/qemu/qemu_migration_params.h @@ -100,6 +100,11 @@ qemuMigrationParamsSetCompression(virQEMUDriverPtr driver, qemuMigrationCompressionPtr compression, qemuMigrationParamsPtr migParams); +int +qemuMigrationParamsCheck(virQEMUDriverPtr driver, + virDomainObjPtr vm, + int asyncJob); + void qemuMigrationParamsReset(virQEMUDriverPtr driver, virDomainObjPtr vm, -- 2.17.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list