提交 8a83181c 编写于 作者: J Jiri Denemark

qemu: Drop qemuMigrationCompression structure

By merging qemuMigrationAnyCompressionParse into
qemuMigrationParamsSetCompression we can drop the useless intermediate
qemuMigrationCompression structure and parse compression related typed
parameters and flags directly into qemuMigrationParams.
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 dbf399ca
...@@ -12104,7 +12104,6 @@ qemuDomainMigratePrepareTunnel(virConnectPtr dconn, ...@@ -12104,7 +12104,6 @@ qemuDomainMigratePrepareTunnel(virConnectPtr dconn,
virQEMUDriverPtr driver = dconn->privateData; virQEMUDriverPtr driver = dconn->privateData;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
char *origname = NULL; char *origname = NULL;
qemuMigrationCompressionPtr compression = NULL;
qemuMigrationParamsPtr migParams = NULL; qemuMigrationParamsPtr migParams = NULL;
int ret = -1; int ret = -1;
...@@ -12116,11 +12115,8 @@ qemuDomainMigratePrepareTunnel(virConnectPtr dconn, ...@@ -12116,11 +12115,8 @@ qemuDomainMigratePrepareTunnel(virConnectPtr dconn,
goto cleanup; goto cleanup;
} }
if (!(compression = qemuMigrationAnyCompressionParse(NULL, 0, flags)))
goto cleanup;
if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags, if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags,
QEMU_MIGRATION_DESTINATION, compression))) QEMU_MIGRATION_DESTINATION)))
goto cleanup; goto cleanup;
if (virLockManagerPluginUsesState(driver->lockManager)) { if (virLockManagerPluginUsesState(driver->lockManager)) {
...@@ -12141,7 +12137,6 @@ qemuDomainMigratePrepareTunnel(virConnectPtr dconn, ...@@ -12141,7 +12137,6 @@ qemuDomainMigratePrepareTunnel(virConnectPtr dconn,
st, &def, origname, migParams, flags); st, &def, origname, migParams, flags);
cleanup: cleanup:
VIR_FREE(compression);
qemuMigrationParamsFree(migParams); qemuMigrationParamsFree(migParams);
VIR_FREE(origname); VIR_FREE(origname);
virDomainDefFree(def); virDomainDefFree(def);
...@@ -12166,7 +12161,6 @@ qemuDomainMigratePrepare2(virConnectPtr dconn, ...@@ -12166,7 +12161,6 @@ qemuDomainMigratePrepare2(virConnectPtr dconn,
virQEMUDriverPtr driver = dconn->privateData; virQEMUDriverPtr driver = dconn->privateData;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
char *origname = NULL; char *origname = NULL;
qemuMigrationCompressionPtr compression = NULL;
qemuMigrationParamsPtr migParams = NULL; qemuMigrationParamsPtr migParams = NULL;
int ret = -1; int ret = -1;
...@@ -12182,11 +12176,8 @@ qemuDomainMigratePrepare2(virConnectPtr dconn, ...@@ -12182,11 +12176,8 @@ qemuDomainMigratePrepare2(virConnectPtr dconn,
goto cleanup; goto cleanup;
} }
if (!(compression = qemuMigrationAnyCompressionParse(NULL, 0, flags)))
goto cleanup;
if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags, if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags,
QEMU_MIGRATION_DESTINATION, compression))) QEMU_MIGRATION_DESTINATION)))
goto cleanup; goto cleanup;
if (virLockManagerPluginUsesState(driver->lockManager)) { if (virLockManagerPluginUsesState(driver->lockManager)) {
...@@ -12214,7 +12205,6 @@ qemuDomainMigratePrepare2(virConnectPtr dconn, ...@@ -12214,7 +12205,6 @@ qemuDomainMigratePrepare2(virConnectPtr dconn,
cleanup: cleanup:
qemuMigrationParamsFree(migParams); qemuMigrationParamsFree(migParams);
VIR_FREE(compression);
VIR_FREE(origname); VIR_FREE(origname);
virDomainDefFree(def); virDomainDefFree(def);
return ret; return ret;
...@@ -12235,7 +12225,6 @@ qemuDomainMigratePerform(virDomainPtr dom, ...@@ -12235,7 +12225,6 @@ qemuDomainMigratePerform(virDomainPtr dom,
virDomainObjPtr vm; virDomainObjPtr vm;
int ret = -1; int ret = -1;
const char *dconnuri = NULL; const char *dconnuri = NULL;
qemuMigrationCompressionPtr compression = NULL;
qemuMigrationParamsPtr migParams = NULL; qemuMigrationParamsPtr migParams = NULL;
virCheckFlags(QEMU_MIGRATION_FLAGS, -1); virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
...@@ -12247,11 +12236,8 @@ qemuDomainMigratePerform(virDomainPtr dom, ...@@ -12247,11 +12236,8 @@ qemuDomainMigratePerform(virDomainPtr dom,
goto cleanup; goto cleanup;
} }
if (!(compression = qemuMigrationAnyCompressionParse(NULL, 0, flags)))
goto cleanup;
if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags, if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags,
QEMU_MIGRATION_SOURCE, compression))) QEMU_MIGRATION_SOURCE)))
goto cleanup; goto cleanup;
if (!(vm = qemuDomObjFromDomain(dom))) if (!(vm = qemuDomObjFromDomain(dom)))
...@@ -12281,7 +12267,6 @@ qemuDomainMigratePerform(virDomainPtr dom, ...@@ -12281,7 +12267,6 @@ qemuDomainMigratePerform(virDomainPtr dom,
cleanup: cleanup:
qemuMigrationParamsFree(migParams); qemuMigrationParamsFree(migParams);
VIR_FREE(compression);
return ret; return ret;
} }
...@@ -12425,7 +12410,6 @@ qemuDomainMigratePrepare3(virConnectPtr dconn, ...@@ -12425,7 +12410,6 @@ qemuDomainMigratePrepare3(virConnectPtr dconn,
virQEMUDriverPtr driver = dconn->privateData; virQEMUDriverPtr driver = dconn->privateData;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
char *origname = NULL; char *origname = NULL;
qemuMigrationCompressionPtr compression = NULL;
qemuMigrationParamsPtr migParams = NULL; qemuMigrationParamsPtr migParams = NULL;
int ret = -1; int ret = -1;
...@@ -12441,11 +12425,8 @@ qemuDomainMigratePrepare3(virConnectPtr dconn, ...@@ -12441,11 +12425,8 @@ qemuDomainMigratePrepare3(virConnectPtr dconn,
goto cleanup; goto cleanup;
} }
if (!(compression = qemuMigrationAnyCompressionParse(NULL, 0, flags)))
goto cleanup;
if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags, if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags,
QEMU_MIGRATION_DESTINATION, compression))) QEMU_MIGRATION_DESTINATION)))
goto cleanup; goto cleanup;
if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname))) if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname)))
...@@ -12463,7 +12444,6 @@ qemuDomainMigratePrepare3(virConnectPtr dconn, ...@@ -12463,7 +12444,6 @@ qemuDomainMigratePrepare3(virConnectPtr dconn,
cleanup: cleanup:
qemuMigrationParamsFree(migParams); qemuMigrationParamsFree(migParams);
VIR_FREE(compression);
VIR_FREE(origname); VIR_FREE(origname);
virDomainDefFree(def); virDomainDefFree(def);
return ret; return ret;
...@@ -12491,7 +12471,6 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn, ...@@ -12491,7 +12471,6 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn,
int nmigrate_disks; int nmigrate_disks;
const char **migrate_disks = NULL; const char **migrate_disks = NULL;
char *origname = NULL; char *origname = NULL;
qemuMigrationCompressionPtr compression = NULL;
qemuMigrationParamsPtr migParams = NULL; qemuMigrationParamsPtr migParams = NULL;
int ret = -1; int ret = -1;
...@@ -12523,11 +12502,8 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn, ...@@ -12523,11 +12502,8 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn,
if (nmigrate_disks < 0) if (nmigrate_disks < 0)
goto cleanup; goto cleanup;
if (!(compression = qemuMigrationAnyCompressionParse(params, nparams, flags)))
goto cleanup;
if (!(migParams = qemuMigrationParamsFromFlags(params, nparams, flags, if (!(migParams = qemuMigrationParamsFromFlags(params, nparams, flags,
QEMU_MIGRATION_DESTINATION, compression))) QEMU_MIGRATION_DESTINATION)))
goto cleanup; goto cleanup;
if (flags & VIR_MIGRATE_TUNNELLED) { if (flags & VIR_MIGRATE_TUNNELLED) {
...@@ -12556,7 +12532,6 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn, ...@@ -12556,7 +12532,6 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn,
cleanup: cleanup:
qemuMigrationParamsFree(migParams); qemuMigrationParamsFree(migParams);
VIR_FREE(compression);
VIR_FREE(migrate_disks); VIR_FREE(migrate_disks);
VIR_FREE(origname); VIR_FREE(origname);
virDomainDefFree(def); virDomainDefFree(def);
...@@ -12580,7 +12555,6 @@ qemuDomainMigratePrepareTunnel3(virConnectPtr dconn, ...@@ -12580,7 +12555,6 @@ qemuDomainMigratePrepareTunnel3(virConnectPtr dconn,
virQEMUDriverPtr driver = dconn->privateData; virQEMUDriverPtr driver = dconn->privateData;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
char *origname = NULL; char *origname = NULL;
qemuMigrationCompressionPtr compression = NULL;
qemuMigrationParamsPtr migParams = NULL; qemuMigrationParamsPtr migParams = NULL;
int ret = -1; int ret = -1;
...@@ -12592,11 +12566,8 @@ qemuDomainMigratePrepareTunnel3(virConnectPtr dconn, ...@@ -12592,11 +12566,8 @@ qemuDomainMigratePrepareTunnel3(virConnectPtr dconn,
goto cleanup; goto cleanup;
} }
if (!(compression = qemuMigrationAnyCompressionParse(NULL, 0, flags)))
goto cleanup;
if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags, if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags,
QEMU_MIGRATION_DESTINATION, compression))) QEMU_MIGRATION_DESTINATION)))
goto cleanup; goto cleanup;
if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname))) if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname)))
...@@ -12611,7 +12582,6 @@ qemuDomainMigratePrepareTunnel3(virConnectPtr dconn, ...@@ -12611,7 +12582,6 @@ qemuDomainMigratePrepareTunnel3(virConnectPtr dconn,
st, &def, origname, migParams, flags); st, &def, origname, migParams, flags);
cleanup: cleanup:
VIR_FREE(compression);
qemuMigrationParamsFree(migParams); qemuMigrationParamsFree(migParams);
VIR_FREE(origname); VIR_FREE(origname);
virDomainDefFree(def); virDomainDefFree(def);
...@@ -12634,7 +12604,6 @@ qemuDomainMigratePrepareTunnel3Params(virConnectPtr dconn, ...@@ -12634,7 +12604,6 @@ qemuDomainMigratePrepareTunnel3Params(virConnectPtr dconn,
const char *dom_xml = NULL; const char *dom_xml = NULL;
const char *dname = NULL; const char *dname = NULL;
char *origname = NULL; char *origname = NULL;
qemuMigrationCompressionPtr compression = NULL;
qemuMigrationParamsPtr migParams = NULL; qemuMigrationParamsPtr migParams = NULL;
int ret = -1; int ret = -1;
...@@ -12656,11 +12625,8 @@ qemuDomainMigratePrepareTunnel3Params(virConnectPtr dconn, ...@@ -12656,11 +12625,8 @@ qemuDomainMigratePrepareTunnel3Params(virConnectPtr dconn,
goto cleanup; goto cleanup;
} }
if (!(compression = qemuMigrationAnyCompressionParse(NULL, 0, flags)))
goto cleanup;
if (!(migParams = qemuMigrationParamsFromFlags(params, nparams, flags, if (!(migParams = qemuMigrationParamsFromFlags(params, nparams, flags,
QEMU_MIGRATION_DESTINATION, compression))) QEMU_MIGRATION_DESTINATION)))
goto cleanup; goto cleanup;
if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname))) if (!(def = qemuMigrationAnyPrepareDef(driver, dom_xml, dname, &origname)))
...@@ -12675,7 +12641,6 @@ qemuDomainMigratePrepareTunnel3Params(virConnectPtr dconn, ...@@ -12675,7 +12641,6 @@ qemuDomainMigratePrepareTunnel3Params(virConnectPtr dconn,
st, &def, origname, migParams, flags); st, &def, origname, migParams, flags);
cleanup: cleanup:
VIR_FREE(compression);
qemuMigrationParamsFree(migParams); qemuMigrationParamsFree(migParams);
VIR_FREE(origname); VIR_FREE(origname);
virDomainDefFree(def); virDomainDefFree(def);
...@@ -12698,17 +12663,13 @@ qemuDomainMigratePerform3(virDomainPtr dom, ...@@ -12698,17 +12663,13 @@ qemuDomainMigratePerform3(virDomainPtr dom,
{ {
virQEMUDriverPtr driver = dom->conn->privateData; virQEMUDriverPtr driver = dom->conn->privateData;
virDomainObjPtr vm; virDomainObjPtr vm;
qemuMigrationCompressionPtr compression = NULL;
qemuMigrationParamsPtr migParams = NULL; qemuMigrationParamsPtr migParams = NULL;
int ret = -1; int ret = -1;
virCheckFlags(QEMU_MIGRATION_FLAGS, -1); virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
if (!(compression = qemuMigrationAnyCompressionParse(NULL, 0, flags)))
goto cleanup;
if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags, if (!(migParams = qemuMigrationParamsFromFlags(NULL, 0, flags,
QEMU_MIGRATION_SOURCE, compression))) QEMU_MIGRATION_SOURCE)))
goto cleanup; goto cleanup;
if (!(vm = qemuDomObjFromDomain(dom))) if (!(vm = qemuDomObjFromDomain(dom)))
...@@ -12728,7 +12689,6 @@ qemuDomainMigratePerform3(virDomainPtr dom, ...@@ -12728,7 +12689,6 @@ qemuDomainMigratePerform3(virDomainPtr dom,
cleanup: cleanup:
qemuMigrationParamsFree(migParams); qemuMigrationParamsFree(migParams);
VIR_FREE(compression);
return ret; return ret;
} }
...@@ -12755,7 +12715,6 @@ qemuDomainMigratePerform3Params(virDomainPtr dom, ...@@ -12755,7 +12715,6 @@ qemuDomainMigratePerform3Params(virDomainPtr dom,
const char **migrate_disks = NULL; const char **migrate_disks = NULL;
unsigned long long bandwidth = 0; unsigned long long bandwidth = 0;
int nbdPort = 0; int nbdPort = 0;
qemuMigrationCompressionPtr compression = NULL;
qemuMigrationParamsPtr migParams = NULL; qemuMigrationParamsPtr migParams = NULL;
int ret = -1; int ret = -1;
...@@ -12796,11 +12755,8 @@ qemuDomainMigratePerform3Params(virDomainPtr dom, ...@@ -12796,11 +12755,8 @@ qemuDomainMigratePerform3Params(virDomainPtr dom,
if (nmigrate_disks < 0) if (nmigrate_disks < 0)
goto cleanup; goto cleanup;
if (!(compression = qemuMigrationAnyCompressionParse(params, nparams, flags)))
goto cleanup;
if (!(migParams = qemuMigrationParamsFromFlags(params, nparams, flags, if (!(migParams = qemuMigrationParamsFromFlags(params, nparams, flags,
QEMU_MIGRATION_SOURCE, compression))) QEMU_MIGRATION_SOURCE)))
goto cleanup; goto cleanup;
if (!(vm = qemuDomObjFromDomain(dom))) if (!(vm = qemuDomObjFromDomain(dom)))
...@@ -12818,7 +12774,6 @@ qemuDomainMigratePerform3Params(virDomainPtr dom, ...@@ -12818,7 +12774,6 @@ qemuDomainMigratePerform3Params(virDomainPtr dom,
cookiein, cookieinlen, cookieout, cookieoutlen, cookiein, cookieinlen, cookieout, cookieoutlen,
flags, dname, bandwidth, true); flags, dname, bandwidth, true);
cleanup: cleanup:
VIR_FREE(compression);
qemuMigrationParamsFree(migParams); qemuMigrationParamsFree(migParams);
VIR_FREE(migrate_disks); VIR_FREE(migrate_disks);
return ret; return ret;
......
...@@ -139,32 +139,85 @@ qemuMigrationParamsFree(qemuMigrationParamsPtr migParams) ...@@ -139,32 +139,85 @@ qemuMigrationParamsFree(qemuMigrationParamsPtr migParams)
static int static int
qemuMigrationParamsSetCompression(qemuMigrationCompressionPtr compression, qemuMigrationParamsSetCompression(virTypedParameterPtr params,
int nparams,
unsigned long flags,
qemuMigrationParamsPtr migParams) qemuMigrationParamsPtr migParams)
{ {
if (compression->methods & (1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE)) size_t i;
ignore_value(virBitmapSetBit(migParams->caps, int method;
QEMU_MONITOR_MIGRATION_CAPS_XBZRLE)); qemuMonitorMigrationCaps cap;
if (compression->methods & (1ULL << QEMU_MIGRATION_COMPRESS_MT)) for (i = 0; i < nparams; i++) {
ignore_value(virBitmapSetBit(migParams->caps, if (STRNEQ(params[i].field, VIR_MIGRATE_PARAM_COMPRESSION))
QEMU_MONITOR_MIGRATION_CAPS_COMPRESS)); continue;
migParams->compMethods = compression->methods; method = qemuMigrationCompressMethodTypeFromString(params[i].value.s);
if (method < 0) {
virReportError(VIR_ERR_INVALID_ARG,
_("Unsupported compression method '%s'"),
params[i].value.s);
goto error;
}
if (migParams->compMethods & (1ULL << method)) {
virReportError(VIR_ERR_INVALID_ARG,
_("Compression method '%s' is specified twice"),
params[i].value.s);
goto error;
}
migParams->params.compressLevel_set = compression->level_set; migParams->compMethods |= 1ULL << method;
migParams->params.compressLevel = compression->level;
migParams->params.compressThreads_set = compression->threads_set; switch ((qemuMigrationCompressMethod) method) {
migParams->params.compressThreads = compression->threads; case QEMU_MIGRATION_COMPRESS_XBZRLE:
cap = QEMU_MONITOR_MIGRATION_CAPS_XBZRLE;
break;
migParams->params.decompressThreads_set = compression->dthreads_set; case QEMU_MIGRATION_COMPRESS_MT:
migParams->params.decompressThreads = compression->dthreads; cap = QEMU_MONITOR_MIGRATION_CAPS_COMPRESS;
break;
migParams->params.xbzrleCacheSize_set = compression->xbzrle_cache_set; case QEMU_MIGRATION_COMPRESS_LAST:
migParams->params.xbzrleCacheSize = compression->xbzrle_cache; default:
continue;
}
ignore_value(virBitmapSetBit(migParams->caps, cap));
}
if (params) {
GET(virTypedParamsGetInt, COMPRESSION_MT_LEVEL, compressLevel);
GET(virTypedParamsGetInt, COMPRESSION_MT_THREADS, compressThreads);
GET(virTypedParamsGetInt, COMPRESSION_MT_DTHREADS, decompressThreads);
GET(virTypedParamsGetULLong, COMPRESSION_XBZRLE_CACHE, xbzrleCacheSize);
}
if ((migParams->params.compressLevel_set ||
migParams->params.compressThreads_set ||
migParams->params.decompressThreads_set) &&
!(migParams->compMethods & (1ULL << QEMU_MIGRATION_COMPRESS_MT))) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Turn multithread compression on to tune it"));
goto error;
}
if (migParams->params.xbzrleCacheSize_set &&
!(migParams->compMethods & (1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE))) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Turn xbzrle compression on to tune it"));
goto error;
}
if (!migParams->compMethods && (flags & VIR_MIGRATE_COMPRESSED)) {
migParams->compMethods = 1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE;
ignore_value(virBitmapSetBit(migParams->caps,
QEMU_MONITOR_MIGRATION_CAPS_XBZRLE));
}
return 0; return 0;
error:
return -1;
} }
...@@ -172,8 +225,7 @@ qemuMigrationParamsPtr ...@@ -172,8 +225,7 @@ qemuMigrationParamsPtr
qemuMigrationParamsFromFlags(virTypedParameterPtr params, qemuMigrationParamsFromFlags(virTypedParameterPtr params,
int nparams, int nparams,
unsigned long flags, unsigned long flags,
qemuMigrationParty party, qemuMigrationParty party)
qemuMigrationCompressionPtr compression)
{ {
qemuMigrationParamsPtr migParams; qemuMigrationParamsPtr migParams;
size_t i; size_t i;
...@@ -207,7 +259,7 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr params, ...@@ -207,7 +259,7 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr params,
goto error; goto error;
} }
if (qemuMigrationParamsSetCompression(compression, migParams) < 0) if (qemuMigrationParamsSetCompression(params, nparams, flags, migParams) < 0)
goto error; goto error;
return migParams; return migParams;
...@@ -220,89 +272,6 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr params, ...@@ -220,89 +272,6 @@ qemuMigrationParamsFromFlags(virTypedParameterPtr params,
#undef GET #undef GET
qemuMigrationCompressionPtr
qemuMigrationAnyCompressionParse(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;
method = qemuMigrationCompressMethodTypeFromString(params[i].value.s);
if (method < 0) {
virReportError(VIR_ERR_INVALID_ARG,
_("Unsupported compression method '%s'"),
params[i].value.s);
goto error;
}
if (compression->methods & (1ULL << method)) {
virReportError(VIR_ERR_INVALID_ARG,
_("Compression method '%s' is specified twice"),
params[i].value.s);
goto error;
}
compression->methods |= 1ULL << method;
}
#define GET_PARAM(PARAM, TYPE, VALUE) \
do { \
int rc; \
const char *par = VIR_MIGRATE_PARAM_COMPRESSION_ ## PARAM; \
\
if ((rc = virTypedParamsGet ## TYPE(params, nparams, \
par, &compression->VALUE)) < 0) \
goto error; \
\
if (rc == 1) \
compression->VALUE ## _set = true; \
} while (0)
if (params) {
GET_PARAM(MT_LEVEL, Int, level);
GET_PARAM(MT_THREADS, Int, threads);
GET_PARAM(MT_DTHREADS, Int, dthreads);
GET_PARAM(XBZRLE_CACHE, ULLong, xbzrle_cache);
}
#undef GET_PARAM
if ((compression->level_set ||
compression->threads_set ||
compression->dthreads_set) &&
!(compression->methods & (1ULL << QEMU_MIGRATION_COMPRESS_MT))) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Turn multithread compression on to tune it"));
goto error;
}
if (compression->xbzrle_cache_set &&
!(compression->methods & (1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE))) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("Turn xbzrle compression on to tune it"));
goto error;
}
if (!compression->methods && (flags & VIR_MIGRATE_COMPRESSED))
compression->methods = 1ULL << QEMU_MIGRATION_COMPRESS_XBZRLE;
return compression;
error:
VIR_FREE(compression);
return NULL;
}
int int
qemuMigrationParamsDump(qemuMigrationParamsPtr migParams, qemuMigrationParamsDump(qemuMigrationParamsPtr migParams,
virTypedParameterPtr *params, virTypedParameterPtr *params,
......
...@@ -28,25 +28,6 @@ ...@@ -28,25 +28,6 @@
# include "qemu_conf.h" # include "qemu_conf.h"
typedef struct _qemuMigrationCompression qemuMigrationCompression;
typedef qemuMigrationCompression *qemuMigrationCompressionPtr;
struct _qemuMigrationCompression {
unsigned long long methods;
bool level_set;
int level;
bool threads_set;
int threads;
bool dthreads_set;
int dthreads;
bool xbzrle_cache_set;
unsigned long long xbzrle_cache;
};
typedef struct _qemuMigrationParams qemuMigrationParams; typedef struct _qemuMigrationParams qemuMigrationParams;
typedef qemuMigrationParams *qemuMigrationParamsPtr; typedef qemuMigrationParams *qemuMigrationParamsPtr;
...@@ -60,13 +41,8 @@ qemuMigrationParamsPtr ...@@ -60,13 +41,8 @@ qemuMigrationParamsPtr
qemuMigrationParamsFromFlags(virTypedParameterPtr params, qemuMigrationParamsFromFlags(virTypedParameterPtr params,
int nparams, int nparams,
unsigned long flags, unsigned long flags,
qemuMigrationParty party, qemuMigrationParty party);
qemuMigrationCompressionPtr compression);
qemuMigrationCompressionPtr
qemuMigrationAnyCompressionParse(virTypedParameterPtr params,
int nparams,
unsigned long flags);
int int
qemuMigrationParamsDump(qemuMigrationParamsPtr migParams, qemuMigrationParamsDump(qemuMigrationParamsPtr migParams,
virTypedParameterPtr *params, virTypedParameterPtr *params,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册