There's no need to call this API explicitly in the migration code. We can pass the compression parameters to qemuMigrationParamsFromFlags and it can internally call qemuMigrationParamsSetCompression to apply them to the qemuMigrationParams structure. Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> --- src/qemu/qemu_driver.c | 30 ++++++++++++------------- src/qemu/qemu_migration.c | 38 ++++++++++---------------------- src/qemu/qemu_migration.h | 2 -- src/qemu/qemu_migration_params.c | 11 +++++---- src/qemu/qemu_migration_params.h | 8 ++----- 5 files changed, 36 insertions(+), 53 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 85755257aa..3b0c3a3ffb 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12142,7 +12142,7 @@ qemuDomainMigratePrepareTunnel(virConnectPtr dconn, goto cleanup; if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags, - QEMU_MIGRATION_DESTINATION))) + QEMU_MIGRATION_DESTINATION, compression))) goto cleanup; if (virLockManagerPluginUsesState(driver->lockManager)) { @@ -12160,7 +12160,7 @@ qemuDomainMigratePrepareTunnel(virConnectPtr dconn, ret = qemuMigrationDstPrepareTunnel(driver, dconn, NULL, 0, NULL, NULL, /* No cookies in v2 */ - st, &def, origname, compression, migParams, flags); + st, &def, origname, migParams, flags); cleanup: VIR_FREE(compression); @@ -12208,7 +12208,7 @@ qemuDomainMigratePrepare2(virConnectPtr dconn, goto cleanup; if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags, - QEMU_MIGRATION_DESTINATION))) + QEMU_MIGRATION_DESTINATION, compression))) goto cleanup; if (virLockManagerPluginUsesState(driver->lockManager)) { @@ -12232,7 +12232,7 @@ qemuDomainMigratePrepare2(virConnectPtr dconn, NULL, 0, NULL, NULL, /* No cookies */ uri_in, uri_out, &def, origname, NULL, 0, NULL, 0, - compression, migParams, flags); + migParams, flags); cleanup: qemuMigrationParamsFree(migParams); @@ -12273,7 +12273,7 @@ qemuDomainMigratePerform(virDomainPtr dom, goto cleanup; if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags, - QEMU_MIGRATION_SOURCE))) + QEMU_MIGRATION_SOURCE, compression))) goto cleanup; if (!(vm = qemuDomObjFromDomain(dom))) @@ -12467,7 +12467,7 @@ qemuDomainMigratePrepare3(virConnectPtr dconn, goto cleanup; if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags, - QEMU_MIGRATION_DESTINATION))) + QEMU_MIGRATION_DESTINATION, compression))) goto cleanup; if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname))) @@ -12481,7 +12481,7 @@ qemuDomainMigratePrepare3(virConnectPtr dconn, cookieout, cookieoutlen, uri_in, uri_out, &def, origname, NULL, 0, NULL, 0, - compression, migParams, flags); + migParams, flags); cleanup: qemuMigrationParamsFree(migParams); @@ -12549,7 +12549,7 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn, goto cleanup; if (!(migParams = qemuMigrationParamsFromFlags(params, nparams, flags, - QEMU_MIGRATION_DESTINATION))) + QEMU_MIGRATION_DESTINATION, compression))) goto cleanup; if (flags & VIR_MIGRATE_TUNNELLED) { @@ -12574,7 +12574,7 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn, uri_in, uri_out, &def, origname, listenAddress, nmigrate_disks, migrate_disks, nbdPort, - compression, migParams, flags); + migParams, flags); cleanup: qemuMigrationParamsFree(migParams); @@ -12618,7 +12618,7 @@ qemuDomainMigratePrepareTunnel3(virConnectPtr dconn, goto cleanup; if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags, - QEMU_MIGRATION_DESTINATION))) + QEMU_MIGRATION_DESTINATION, compression))) goto cleanup; if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname))) @@ -12630,7 +12630,7 @@ qemuDomainMigratePrepareTunnel3(virConnectPtr dconn, ret = qemuMigrationDstPrepareTunnel(driver, dconn, cookiein, cookieinlen, cookieout, cookieoutlen, - st, &def, origname, compression, migParams, flags); + st, &def, origname, migParams, flags); cleanup: VIR_FREE(compression); @@ -12682,7 +12682,7 @@ qemuDomainMigratePrepareTunnel3Params(virConnectPtr dconn, goto cleanup; if (!(migParams = qemuMigrationParamsFromFlags(params, nparams, flags, - QEMU_MIGRATION_DESTINATION))) + QEMU_MIGRATION_DESTINATION, compression))) goto cleanup; if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname))) @@ -12694,7 +12694,7 @@ qemuDomainMigratePrepareTunnel3Params(virConnectPtr dconn, ret = qemuMigrationDstPrepareTunnel(driver, dconn, cookiein, cookieinlen, cookieout, cookieoutlen, - st, &def, origname, compression, migParams, flags); + st, &def, origname, migParams, flags); cleanup: VIR_FREE(compression); @@ -12730,7 +12730,7 @@ qemuDomainMigratePerform3(virDomainPtr dom, goto cleanup; if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags, - QEMU_MIGRATION_SOURCE))) + QEMU_MIGRATION_SOURCE, compression))) goto cleanup; if (!(vm = qemuDomObjFromDomain(dom))) @@ -12822,7 +12822,7 @@ qemuDomainMigratePerform3Params(virDomainPtr dom, goto cleanup; if (!(migParams = qemuMigrationParamsFromFlags(params, nparams, flags, - QEMU_MIGRATION_SOURCE))) + QEMU_MIGRATION_SOURCE, compression))) goto cleanup; if (!(vm = qemuDomObjFromDomain(dom))) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index e338bd05f6..304eaf52c5 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2161,7 +2161,6 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver, size_t nmigrate_disks, const char **migrate_disks, int nbdPort, - qemuMigrationCompressionPtr compression, qemuMigrationParamsPtr migParams, unsigned long flags) { @@ -2375,9 +2374,6 @@ qemuMigrationDstPrepareAny(virQEMUDriverPtr driver, dataFD[1] = -1; /* 'st' owns the FD now & will close it */ } - if (qemuMigrationParamsSetCompression(vm, compression, migParams) < 0) - goto stopjob; - if (STREQ_NULLABLE(protocol, "rdma") && virProcessSetMaxMemLock(vm->pid, vm->def->mem.hard_limit << 10) < 0) { goto stopjob; @@ -2529,7 +2525,6 @@ qemuMigrationDstPrepareTunnel(virQEMUDriverPtr driver, virStreamPtr st, virDomainDefPtr *def, const char *origname, - qemuMigrationCompressionPtr compression, qemuMigrationParamsPtr migParams, unsigned long flags) { @@ -2548,7 +2543,7 @@ qemuMigrationDstPrepareTunnel(virQEMUDriverPtr driver, return qemuMigrationDstPrepareAny(driver, dconn, cookiein, cookieinlen, cookieout, cookieoutlen, def, origname, st, NULL, 0, false, NULL, 0, NULL, 0, - compression, migParams, flags); + migParams, flags); } @@ -2590,7 +2585,6 @@ qemuMigrationDstPrepareDirect(virQEMUDriverPtr driver, size_t nmigrate_disks, const char **migrate_disks, int nbdPort, - qemuMigrationCompressionPtr compression, qemuMigrationParamsPtr migParams, unsigned long flags) { @@ -2715,7 +2709,7 @@ qemuMigrationDstPrepareDirect(virQEMUDriverPtr driver, NULL, uri ? uri->scheme : "tcp", port, autoPort, listenAddress, nmigrate_disks, migrate_disks, nbdPort, - compression, migParams, flags); + migParams, flags); cleanup: virURIFree(uri); VIR_FREE(hostname); @@ -3242,7 +3236,6 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver, const char *graphicsuri, size_t nmigrate_disks, const char **migrate_disks, - qemuMigrationCompressionPtr compression, qemuMigrationParamsPtr migParams) { int ret = -1; @@ -3317,9 +3310,6 @@ qemuMigrationSrcRun(virQEMUDriverPtr driver, if (qemuMigrationSrcGraphicsRelocate(driver, vm, mig, graphicsuri) < 0) VIR_WARN("unable to provide data for graphics client relocation"); - if (qemuMigrationParamsSetCompression(vm, compression, migParams) < 0) - goto error; - if (qemuMigrationParamsCheck(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT, migParams) < 0) goto error; @@ -3609,7 +3599,6 @@ qemuMigrationSrcPerformNative(virQEMUDriverPtr driver, const char *graphicsuri, size_t nmigrate_disks, const char **migrate_disks, - qemuMigrationCompressionPtr compression, qemuMigrationParamsPtr migParams) { qemuDomainObjPrivatePtr priv = vm->privateData; @@ -3661,7 +3650,7 @@ qemuMigrationSrcPerformNative(virQEMUDriverPtr driver, ret = qemuMigrationSrcRun(driver, vm, persist_xml, cookiein, cookieinlen, cookieout, cookieoutlen, flags, resource, &spec, dconn, graphicsuri, nmigrate_disks, migrate_disks, - compression, migParams); + migParams); if (spec.destType == MIGRATION_DEST_FD) VIR_FORCE_CLOSE(spec.dest.fd.qemu); @@ -3688,7 +3677,6 @@ qemuMigrationSrcPerformTunnel(virQEMUDriverPtr driver, const char *graphicsuri, size_t nmigrate_disks, const char **migrate_disks, - qemuMigrationCompressionPtr compression, qemuMigrationParamsPtr migParams) { int ret = -1; @@ -3726,7 +3714,7 @@ qemuMigrationSrcPerformTunnel(virQEMUDriverPtr driver, ret = qemuMigrationSrcRun(driver, vm, persist_xml, cookiein, cookieinlen, cookieout, cookieoutlen, flags, resource, &spec, dconn, graphicsuri, nmigrate_disks, migrate_disks, - compression, migParams); + migParams); cleanup: VIR_FORCE_CLOSE(spec.dest.fd.qemu); @@ -3750,7 +3738,6 @@ qemuMigrationSrcPerformPeer2Peer2(virQEMUDriverPtr driver, unsigned long flags, const char *dname, unsigned long resource, - qemuMigrationCompressionPtr compression, qemuMigrationParamsPtr migParams) { virDomainPtr ddomain = NULL; @@ -3835,13 +3822,13 @@ qemuMigrationSrcPerformPeer2Peer2(virQEMUDriverPtr driver, ret = qemuMigrationSrcPerformTunnel(driver, vm, st, NULL, NULL, 0, NULL, NULL, flags, resource, dconn, - NULL, 0, NULL, compression, migParams); + NULL, 0, NULL, migParams); else ret = qemuMigrationSrcPerformNative(driver, vm, NULL, uri_out, cookie, cookielen, NULL, NULL, /* No out cookie with v2 migration */ flags, resource, dconn, NULL, 0, NULL, - compression, migParams); + migParams); /* Perform failed. Make sure Finish doesn't overwrite the error */ if (ret < 0) @@ -4080,14 +4067,14 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriverPtr driver, cookiein, cookieinlen, &cookieout, &cookieoutlen, flags, bandwidth, dconn, graphicsuri, - nmigrate_disks, migrate_disks, compression, + nmigrate_disks, migrate_disks, migParams); } else { ret = qemuMigrationSrcPerformNative(driver, vm, persist_xml, uri, cookiein, cookieinlen, &cookieout, &cookieoutlen, flags, bandwidth, dconn, graphicsuri, - nmigrate_disks, migrate_disks, compression, + nmigrate_disks, migrate_disks, migParams); } @@ -4396,7 +4383,7 @@ qemuMigrationSrcPerformPeer2Peer(virQEMUDriverPtr driver, } else { ret = qemuMigrationSrcPerformPeer2Peer2(driver, sconn, dconn, vm, dconnuri, flags, dname, resource, - compression, migParams); + migParams); } cleanup: @@ -4478,7 +4465,7 @@ qemuMigrationSrcPerformJob(virQEMUDriverPtr driver, ret = qemuMigrationSrcPerformNative(driver, vm, persist_xml, uri, cookiein, cookieinlen, cookieout, cookieoutlen, flags, resource, NULL, NULL, 0, NULL, - compression, migParams); + migParams); } if (ret < 0) goto endjob; @@ -4547,7 +4534,6 @@ qemuMigrationSrcPerformPhase(virQEMUDriverPtr driver, const char *graphicsuri, size_t nmigrate_disks, const char **migrate_disks, - qemuMigrationCompressionPtr compression, qemuMigrationParamsPtr migParams, const char *cookiein, int cookieinlen, @@ -4575,7 +4561,7 @@ qemuMigrationSrcPerformPhase(virQEMUDriverPtr driver, ret = qemuMigrationSrcPerformNative(driver, vm, persist_xml, uri, cookiein, cookieinlen, cookieout, cookieoutlen, flags, resource, NULL, graphicsuri, - nmigrate_disks, migrate_disks, compression, migParams); + nmigrate_disks, migrate_disks, migParams); if (ret < 0) { if (qemuMigrationSrcRestoreDomainState(driver, vm)) { @@ -4670,7 +4656,7 @@ qemuMigrationSrcPerform(virQEMUDriverPtr driver, return qemuMigrationSrcPerformPhase(driver, conn, vm, persist_xml, uri, graphicsuri, nmigrate_disks, migrate_disks, - compression, migParams, + migParams, cookiein, cookieinlen, cookieout, cookieoutlen, flags, resource); diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index 02b33d4a5d..b67184874b 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -130,7 +130,6 @@ qemuMigrationDstPrepareTunnel(virQEMUDriverPtr driver, virStreamPtr st, virDomainDefPtr *def, const char *origname, - qemuMigrationCompressionPtr compression, qemuMigrationParamsPtr migParams, unsigned long flags); @@ -149,7 +148,6 @@ qemuMigrationDstPrepareDirect(virQEMUDriverPtr driver, size_t nmigrate_disks, const char **migrate_disks, int nbdPort, - qemuMigrationCompressionPtr compression, qemuMigrationParamsPtr migParams, unsigned long flags); diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c index 1795bafe24..4f76cc6683 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -137,9 +137,8 @@ qemuMigrationParamsFree(qemuMigrationParamsPtr migParams) } while (0) -int -qemuMigrationParamsSetCompression(virDomainObjPtr vm ATTRIBUTE_UNUSED, - qemuMigrationCompressionPtr compression, +static int +qemuMigrationParamsSetCompression(qemuMigrationCompressionPtr compression, qemuMigrationParamsPtr migParams) { if (compression->methods & (1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE)) @@ -170,7 +169,8 @@ qemuMigrationParamsPtr qemuMigrationParamsFromFlags(virTypedParameterPtr params, int nparams, unsigned long flags, - qemuMigrationParty party) + qemuMigrationParty party, + qemuMigrationCompressionPtr compression) { qemuMigrationParamsPtr migParams; size_t i; @@ -201,6 +201,9 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr params, goto error; } + if (qemuMigrationParamsSetCompression(compression, migParams) < 0) + goto error; + return migParams; error: diff --git a/src/qemu/qemu_migration_params.h b/src/qemu/qemu_migration_params.h index b00075794a..399b5cde77 100644 --- a/src/qemu/qemu_migration_params.h +++ b/src/qemu/qemu_migration_params.h @@ -60,7 +60,8 @@ qemuMigrationParamsPtr qemuMigrationParamsFromFlags(virTypedParameterPtr params, int nparams, unsigned long flags, - qemuMigrationParty party); + qemuMigrationParty party, + qemuMigrationCompressionPtr compression); qemuMigrationCompressionPtr qemuMigrationAnyCompressionParse(virTypedParameterPtr params, @@ -96,11 +97,6 @@ int qemuMigrationParamsDisableTLS(virDomainObjPtr vm, qemuMigrationParamsPtr migParams); -int -qemuMigrationParamsSetCompression(virDomainObjPtr vm, - qemuMigrationCompressionPtr compression, - qemuMigrationParamsPtr migParams); - int qemuMigrationParamsCheck(virQEMUDriverPtr driver, virDomainObjPtr vm, -- 2.17.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list