Every migration entry point in qemu_driver is supposed to call qemuMigrationParamsFromFlags to transform flags and parameters into qemuMigrationParams structure and pass the result to qemuMigration* APIs. Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> --- src/qemu/qemu_driver.c | 64 +++++++++++++++++++++++++++++++-------- src/qemu/qemu_migration.c | 23 ++++++-------- src/qemu/qemu_migration.h | 2 ++ 3 files changed, 62 insertions(+), 27 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d8a641f77d..5271e01d92 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12126,6 +12126,7 @@ qemuDomainMigratePrepareTunnel(virConnectPtr dconn, virQEMUDriverPtr driver = dconn->privateData; virDomainDefPtr def = NULL; char *origname = NULL; + qemuMigrationParamsPtr migParams = NULL; int ret = -1; virCheckFlags(QEMU_MIGRATION_FLAGS, -1); @@ -12136,6 +12137,10 @@ qemuDomainMigratePrepareTunnel(virConnectPtr dconn, goto cleanup; } + if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags, + QEMU_MIGRATION_DESTINATION))) + goto cleanup; + if (virLockManagerPluginUsesState(driver->lockManager)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Cannot use migrate v2 protocol with lock manager %s"), @@ -12151,9 +12156,10 @@ qemuDomainMigratePrepareTunnel(virConnectPtr dconn, ret = qemuMigrationDstPrepareTunnel(driver, dconn, NULL, 0, NULL, NULL, /* No cookies in v2 */ - st, &def, origname, flags); + st, &def, origname, migParams, flags); cleanup: + qemuMigrationParamsFree(migParams); VIR_FREE(origname); virDomainDefFree(def); return ret; @@ -12178,6 +12184,7 @@ qemuDomainMigratePrepare2(virConnectPtr dconn, virDomainDefPtr def = NULL; char *origname = NULL; qemuMigrationCompressionPtr compression = NULL; + qemuMigrationParamsPtr migParams = NULL; int ret = -1; virCheckFlags(QEMU_MIGRATION_FLAGS, -1); @@ -12195,6 +12202,10 @@ qemuDomainMigratePrepare2(virConnectPtr dconn, if (!(compression = qemuMigrationAnyCompressionParse(NULL, 0, flags))) goto cleanup; + if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags, + QEMU_MIGRATION_DESTINATION))) + goto cleanup; + if (virLockManagerPluginUsesState(driver->lockManager)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Cannot use migrate v2 protocol with lock manager %s"), @@ -12216,9 +12227,10 @@ qemuDomainMigratePrepare2(virConnectPtr dconn, NULL, 0, NULL, NULL, /* No cookies */ uri_in, uri_out, &def, origname, NULL, 0, NULL, 0, - compression, flags); + compression, migParams, flags); cleanup: + qemuMigrationParamsFree(migParams); VIR_FREE(compression); VIR_FREE(origname); virDomainDefFree(def); @@ -12252,10 +12264,11 @@ qemuDomainMigratePerform(virDomainPtr dom, goto cleanup; } - if (!(migParams = qemuMigrationParamsNew())) + if (!(compression = qemuMigrationAnyCompressionParse(NULL, 0, flags))) goto cleanup; - if (!(compression = qemuMigrationAnyCompressionParse(NULL, 0, flags))) + if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags, + QEMU_MIGRATION_SOURCE))) goto cleanup; if (!(vm = qemuDomObjFromDomain(dom))) @@ -12430,6 +12443,7 @@ qemuDomainMigratePrepare3(virConnectPtr dconn, virDomainDefPtr def = NULL; char *origname = NULL; qemuMigrationCompressionPtr compression = NULL; + qemuMigrationParamsPtr migParams = NULL; int ret = -1; virCheckFlags(QEMU_MIGRATION_FLAGS, -1); @@ -12447,6 +12461,10 @@ qemuDomainMigratePrepare3(virConnectPtr dconn, if (!(compression = qemuMigrationAnyCompressionParse(NULL, 0, flags))) goto cleanup; + if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags, + QEMU_MIGRATION_DESTINATION))) + goto cleanup; + if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname))) goto cleanup; @@ -12458,9 +12476,10 @@ qemuDomainMigratePrepare3(virConnectPtr dconn, cookieout, cookieoutlen, uri_in, uri_out, &def, origname, NULL, 0, NULL, 0, - compression, flags); + compression, migParams, flags); cleanup: + qemuMigrationParamsFree(migParams); VIR_FREE(compression); VIR_FREE(origname); virDomainDefFree(def); @@ -12490,6 +12509,7 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn, const char **migrate_disks = NULL; char *origname = NULL; qemuMigrationCompressionPtr compression = NULL; + qemuMigrationParamsPtr migParams = NULL; int ret = -1; virCheckFlagsGoto(QEMU_MIGRATION_FLAGS, cleanup); @@ -12523,6 +12543,10 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn, if (!(compression = qemuMigrationAnyCompressionParse(params, nparams, flags))) goto cleanup; + if (!(migParams = qemuMigrationParamsFromFlags(params, nparams, flags, + QEMU_MIGRATION_DESTINATION))) + goto cleanup; + if (flags & VIR_MIGRATE_TUNNELLED) { /* this is a logical error; we never should have gotten here with * VIR_MIGRATE_TUNNELLED set @@ -12545,9 +12569,10 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn, uri_in, uri_out, &def, origname, listenAddress, nmigrate_disks, migrate_disks, nbdPort, - compression, flags); + compression, migParams, flags); cleanup: + qemuMigrationParamsFree(migParams); VIR_FREE(compression); VIR_FREE(migrate_disks); VIR_FREE(origname); @@ -12572,6 +12597,7 @@ qemuDomainMigratePrepareTunnel3(virConnectPtr dconn, virQEMUDriverPtr driver = dconn->privateData; virDomainDefPtr def = NULL; char *origname = NULL; + qemuMigrationParamsPtr migParams = NULL; int ret = -1; virCheckFlags(QEMU_MIGRATION_FLAGS, -1); @@ -12582,6 +12608,10 @@ qemuDomainMigratePrepareTunnel3(virConnectPtr dconn, goto cleanup; } + if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags, + QEMU_MIGRATION_DESTINATION))) + goto cleanup; + if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname))) goto cleanup; @@ -12591,9 +12621,10 @@ qemuDomainMigratePrepareTunnel3(virConnectPtr dconn, ret = qemuMigrationDstPrepareTunnel(driver, dconn, cookiein, cookieinlen, cookieout, cookieoutlen, - st, &def, origname, flags); + st, &def, origname, migParams, flags); cleanup: + qemuMigrationParamsFree(migParams); VIR_FREE(origname); virDomainDefFree(def); return ret; @@ -12615,6 +12646,7 @@ qemuDomainMigratePrepareTunnel3Params(virConnectPtr dconn, const char *dom_xml = NULL; const char *dname = NULL; char *origname = NULL; + qemuMigrationParamsPtr migParams = NULL; int ret = -1; virCheckFlags(QEMU_MIGRATION_FLAGS, -1); @@ -12635,6 +12667,10 @@ qemuDomainMigratePrepareTunnel3Params(virConnectPtr dconn, goto cleanup; } + if (!(migParams = qemuMigrationParamsFromFlags(params, nparams, flags, + QEMU_MIGRATION_DESTINATION))) + goto cleanup; + if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname))) goto cleanup; @@ -12644,9 +12680,10 @@ qemuDomainMigratePrepareTunnel3Params(virConnectPtr dconn, ret = qemuMigrationDstPrepareTunnel(driver, dconn, cookiein, cookieinlen, cookieout, cookieoutlen, - st, &def, origname, flags); + st, &def, origname, migParams, flags); cleanup: + qemuMigrationParamsFree(migParams); VIR_FREE(origname); virDomainDefFree(def); return ret; @@ -12674,10 +12711,11 @@ qemuDomainMigratePerform3(virDomainPtr dom, virCheckFlags(QEMU_MIGRATION_FLAGS, -1); - if (!(migParams = qemuMigrationParamsNew())) + if (!(compression = qemuMigrationAnyCompressionParse(NULL, 0, flags))) goto cleanup; - if (!(compression = qemuMigrationAnyCompressionParse(NULL, 0, flags))) + if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags, + QEMU_MIGRATION_SOURCE))) goto cleanup; if (!(vm = qemuDomObjFromDomain(dom))) @@ -12765,11 +12803,11 @@ qemuDomainMigratePerform3Params(virDomainPtr dom, if (nmigrate_disks < 0) goto cleanup; - if (!(migParams = qemuMigrationParamsFromFlags(params, nparams, flags, - QEMU_MIGRATION_SOURCE))) + if (!(compression = qemuMigrationAnyCompressionParse(params, nparams, flags))) goto cleanup; - if (!(compression = qemuMigrationAnyCompressionParse(params, nparams, flags))) + if (!(migParams = qemuMigrationParamsFromFlags(params, nparams, flags, + QEMU_MIGRATION_SOURCE))) goto cleanup; if (!(vm = qemuDomObjFromDomain(dom))) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index a6b2597461..ceab035acf 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2167,6 +2167,7 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver, const char **migrate_disks, int nbdPort, qemuMigrationCompressionPtr compression, + qemuMigrationParamsPtr migParams, unsigned long flags) { virDomainObjPtr vm = NULL; @@ -2187,7 +2188,6 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver, int rv; char *tlsAlias = NULL; char *secAlias = NULL; - qemuMigrationParamsPtr migParams = NULL; virNWFilterReadLockFilterUpdates(); @@ -2237,9 +2237,6 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver, if (!qemuMigrationSrcIsAllowedHostdev(*def)) goto cleanup; - if (!(migParams = qemuMigrationParamsNew())) - goto cleanup; - /* Let migration hook filter domain XML */ if (virHookPresent(VIR_HOOK_DRIVER_QEMU)) { char *xml; @@ -2506,7 +2503,6 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver, virDomainObjRemoveTransientDef(vm); qemuDomainRemoveInactiveJob(driver, vm); } - qemuMigrationParamsFree(migParams); virDomainObjEndAPI(&vm); qemuDomainEventQueue(driver, event); qemuMigrationCookieFree(mig); @@ -2546,6 +2542,7 @@ qemuMigrationDstPrepareTunnel(virQEMUDriverPtr driver, virStreamPtr st, virDomainDefPtr *def, const char *origname, + qemuMigrationParamsPtr migParams, unsigned long flags) { qemuMigrationCompressionPtr compression = NULL; @@ -2569,7 +2566,7 @@ qemuMigrationDstPrepareTunnel(virQEMUDriverPtr driver, ret = qemuMigrationDstPrepareAny(driver, dconn, cookiein, cookieinlen, cookieout, cookieoutlen, def, origname, st, NULL, 0, false, NULL, 0, NULL, 0, - compression, flags); + compression, migParams, flags); VIR_FREE(compression); return ret; } @@ -2614,6 +2611,7 @@ qemuMigrationDstPrepareDirect(virQEMUDriverPtr driver, const char **migrate_disks, int nbdPort, qemuMigrationCompressionPtr compression, + qemuMigrationParamsPtr migParams, unsigned long flags) { unsigned short port = 0; @@ -2737,7 +2735,7 @@ qemuMigrationDstPrepareDirect(virQEMUDriverPtr driver, NULL, uri ? uri->scheme : "tcp", port, autoPort, listenAddress, nmigrate_disks, migrate_disks, nbdPort, - compression, flags); + compression, migParams, flags); cleanup: virURIFree(uri); VIR_FREE(hostname); @@ -3791,7 +3789,8 @@ qemuMigrationSrcPerformPeer2Peer2(virQEMUDriverPtr driver, const char *dconnuri, unsigned long flags, const char *dname, - unsigned long resource) + unsigned long resource, + qemuMigrationParamsPtr migParams) { virDomainPtr ddomain = NULL; char *uri_out = NULL; @@ -3803,7 +3802,6 @@ qemuMigrationSrcPerformPeer2Peer2(virQEMUDriverPtr driver, virStreamPtr st = NULL; unsigned long destflags; qemuMigrationCompressionPtr compression = NULL; - qemuMigrationParamsPtr migParams = NULL; VIR_DEBUG("driver=%p, sconn=%p, dconn=%p, vm=%p, dconnuri=%s, " "flags=0x%lx, dname=%s, resource=%lu", @@ -3825,9 +3823,6 @@ qemuMigrationSrcPerformPeer2Peer2(virQEMUDriverPtr driver, destflags = flags & ~(VIR_MIGRATE_ABORT_ON_ERROR | VIR_MIGRATE_AUTO_CONVERGE); - if (!(migParams = qemuMigrationParamsNew())) - goto cleanup; - if (!(compression = qemuMigrationAnyCompressionParse(NULL, 0, flags))) goto cleanup; @@ -3929,7 +3924,6 @@ qemuMigrationSrcPerformPeer2Peer2(virQEMUDriverPtr driver, virSetError(orig_err); virFreeError(orig_err); } - qemuMigrationParamsFree(migParams); VIR_FREE(uri_out); VIR_FREE(cookie); VIR_FREE(compression); @@ -4445,7 +4439,8 @@ qemuMigrationSrcPerformPeer2Peer(virQEMUDriverPtr driver, useParams, flags); } else { ret = qemuMigrationSrcPerformPeer2Peer2(driver, sconn, dconn, vm, - dconnuri, flags, dname, resource); + dconnuri, flags, dname, resource, + migParams); } cleanup: diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index c753a57028..af8f2cfeb4 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -149,6 +149,7 @@ qemuMigrationDstPrepareTunnel(virQEMUDriverPtr driver, virStreamPtr st, virDomainDefPtr *def, const char *origname, + qemuMigrationParamsPtr migParams, unsigned long flags); int @@ -167,6 +168,7 @@ qemuMigrationDstPrepareDirect(virQEMUDriverPtr driver, const char **migrate_disks, int nbdPort, qemuMigrationCompressionPtr compression, + qemuMigrationParamsPtr migParams, unsigned long flags); int -- 2.17.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list