On Thu, Apr 14, 2016 at 13:33:48 +0300, Nikolay Shirokovskiy wrote: > Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx> > --- > include/libvirt/libvirt-domain.h | 9 ++ > src/qemu/qemu_driver.c | 60 +++++++++++--- > src/qemu/qemu_migration.c | 173 +++++++++++++++++++++++++++++++++------ > src/qemu/qemu_migration.h | 27 ++++++ > src/qemu/qemu_monitor.c | 2 +- > src/qemu/qemu_monitor.h | 1 + > 6 files changed, 234 insertions(+), 38 deletions(-) ... > diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c > index eaabe58..44e8aa0 100644 > --- a/src/qemu/qemu_driver.c > +++ b/src/qemu/qemu_driver.c ... > @@ -12551,22 +12573,32 @@ qemuDomainMigratePerform3(virDomainPtr dom, > { > virQEMUDriverPtr driver = dom->conn->privateData; > virDomainObjPtr vm; > + qemuMigrationCompressionPtr compression = NULL; > + int ret = -1; > > virCheckFlags(QEMU_MIGRATION_FLAGS, -1); > > if (!(vm = qemuDomObjFromDomain(dom))) > return -1; s/return -1/goto cleanup/ > > + if (!(compression = qemuMigrationCompressionParse(NULL, 0, flags))) > + return -1; > + And move this if statement before qemuDomObjFromDomain(), otherwise you'd need to call virDomainObjEndAPI() here in case of error, which would be rather ugly. > if (virDomainMigratePerform3EnsureACL(dom->conn, vm->def) < 0) { > virDomainObjEndAPI(&vm); > - return -1; > + goto cleanup; > } > > - return qemuMigrationPerform(driver, dom->conn, vm, xmlin, > - dconnuri, uri, NULL, NULL, 0, NULL, 0, > - cookiein, cookieinlen, > - cookieout, cookieoutlen, > - flags, dname, resource, true); > + ret = qemuMigrationPerform(driver, dom->conn, vm, xmlin, > + dconnuri, uri, NULL, NULL, 0, NULL, 0, > + compression, > + cookiein, cookieinlen, > + cookieout, cookieoutlen, > + flags, dname, resource, true); > + > + cleanup: > + VIR_FREE(compression); > + return ret; > } > > static int ... > diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c > index e72c874..8fe0f0d 100644 > --- a/src/qemu/qemu_migration.c > +++ b/src/qemu/qemu_migration.c ... > @@ -6558,3 +6611,71 @@ qemuMigrationErrorReport(virQEMUDriverPtr driver, > virSetError(err); > virFreeError(err); > } > + > +/* don't ever pass NULL params with non zero nparams */ > +qemuMigrationCompressionPtr > +qemuMigrationCompressionParse(virTypedParameterPtr params, int nparams, > + unsigned long flags) > +{ > + size_t i; > + qemuMigrationCompressionPtr compression = NULL; > + > + if (VIR_ALLOC(compression) < 0) > + return NULL; > + > + for (i = 0; i < nparams; i++) { > + int method; > + > + if (STRNEQ(params[i].field, VIR_MIGRATE_PARAM_COMPRESSION)) > + continue; > + > + if ((method = qemuMigrationCompressMethodTypeFromString(params[i].value.s)) < 0) { This line is too long. ACK with the following squashed in: diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h index cc8f7de..d813280 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -791,8 +791,9 @@ typedef enum { * VIR_MIGRATE_PARAM_COMPRESSION: * * virDomainMigrate* params multiple field: name of the method used to - * compress migration traffic. The parameter may be specified multiple times - * if more than one method should be used. + * compress migration traffic. Supported compression methods: xbzrle, mt. + * The parameter may be specified multiple times if more than one method + * should be used. */ # define VIR_MIGRATE_PARAM_COMPRESSION "compression" diff --git i/src/qemu/qemu_driver.c w/src/qemu/qemu_driver.c index 44e8aa0..e795062 100644 --- i/src/qemu/qemu_driver.c +++ w/src/qemu/qemu_driver.c @@ -12578,12 +12578,12 @@ qemuDomainMigratePerform3(virDomainPtr dom, virCheckFlags(QEMU_MIGRATION_FLAGS, -1); - if (!(vm = qemuDomObjFromDomain(dom))) - return -1; - if (!(compression = qemuMigrationCompressionParse(NULL, 0, flags))) return -1; + if (!(vm = qemuDomObjFromDomain(dom))) + goto cleanup; + if (virDomainMigratePerform3EnsureACL(dom->conn, vm->def) < 0) { virDomainObjEndAPI(&vm); goto cleanup; diff --git i/src/qemu/qemu_migration.c w/src/qemu/qemu_migration.c index 35b5748..f30fbfb 100644 --- i/src/qemu/qemu_migration.c +++ w/src/qemu/qemu_migration.c @@ -3434,7 +3434,7 @@ qemuMigrationSetCompression(virQEMUDriverPtr driver, if (qemuMigrationSetOption(driver, vm, QEMU_MONITOR_MIGRATION_CAPS_COMPRESS, compression->methods & - (1ULL << QEMU_MIGRATION_COMPRESS_MULTITHREAD), + (1ULL << QEMU_MIGRATION_COMPRESS_MT), job) < 0) return -1; @@ -6612,9 +6612,11 @@ qemuMigrationErrorReport(virQEMUDriverPtr driver, virFreeError(err); } + /* don't ever pass NULL params with non zero nparams */ qemuMigrationCompressionPtr -qemuMigrationCompressionParse(virTypedParameterPtr params, int nparams, +qemuMigrationCompressionParse(virTypedParameterPtr params, + int nparams, unsigned long flags) { size_t i; @@ -6629,7 +6631,8 @@ qemuMigrationCompressionParse(virTypedParameterPtr params, int nparams, if (STRNEQ(params[i].field, VIR_MIGRATE_PARAM_COMPRESSION)) continue; - if ((method = qemuMigrationCompressMethodTypeFromString(params[i].value.s)) < 0) { + method = qemuMigrationCompressMethodTypeFromString(params[i].value.s); + if (method < 0) { virReportError(VIR_ERR_INVALID_ARG, _("Unsupported compression method '%s'"), params[i].value.s); @@ -6659,7 +6662,8 @@ qemuMigrationCompressionParse(virTypedParameterPtr params, int nparams, int qemuMigrationCompressionDump(qemuMigrationCompressionPtr compression, virTypedParameterPtr *params, - int *nparams, int *maxparams, + int *nparams, + int *maxparams, unsigned long *flags) { size_t i; @@ -6669,7 +6673,7 @@ qemuMigrationCompressionDump(qemuMigrationCompressionPtr compression, return 0; } - for (i = QEMU_MIGRATION_COMPRESS_XBZRLE; i < QEMU_MIGRATION_COMPRESS_LAST; ++i) { + for (i = 0; i < QEMU_MIGRATION_COMPRESS_LAST; ++i) { if ((compression->methods & (1ULL << i)) && virTypedParamsAddString(params, nparams, maxparams, VIR_MIGRATE_PARAM_COMPRESSION, diff --git i/src/qemu/qemu_migration.h w/src/qemu/qemu_migration.h index cb51ca5..ec5145b 100644 --- i/src/qemu/qemu_migration.h +++ w/src/qemu/qemu_migration.h @@ -81,7 +81,7 @@ VIR_ENUM_DECL(qemuMigrationJobPhase) typedef enum { QEMU_MIGRATION_COMPRESS_XBZRLE = 0, - QEMU_MIGRATION_COMPRESS_MULTITHREAD, + QEMU_MIGRATION_COMPRESS_MT, QEMU_MIGRATION_COMPRESS_LAST } qemuMigrationCompressMethod; @@ -92,11 +92,13 @@ struct _qemuMigrationCompression { }; qemuMigrationCompressionPtr -qemuMigrationCompressionParse(virTypedParameterPtr params, int nparams, +qemuMigrationCompressionParse(virTypedParameterPtr params, + int nparams, unsigned long flags); int qemuMigrationCompressionDump(qemuMigrationCompressionPtr compression, virTypedParameterPtr *params, - int *nparams, int *maxparams, + int *nparams, + int *maxparams, unsigned long *flags); int qemuMigrationJobStart(virQEMUDriverPtr driver, -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list