提交 8979c5dd 编写于 作者: S ShaoHe Feng 提交者: Jiri Denemark

qemu: monitor: add migration parameters accessors

Signed-off-by: NShaoHe Feng <shaohe.feng@intel.com>
Signed-off-by: NNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
上级 231b25db
......@@ -2176,6 +2176,28 @@ qemuMonitorSetMigrationCacheSize(qemuMonitorPtr mon,
}
int
qemuMonitorGetMigrationCompression(qemuMonitorPtr mon,
qemuMonitorMigrationCompressionPtr compress)
{
QEMU_CHECK_MONITOR_JSON(mon);
return qemuMonitorJSONGetMigrationCompression(mon, compress);
}
int
qemuMonitorSetMigrationCompression(qemuMonitorPtr mon,
qemuMonitorMigrationCompressionPtr compress)
{
VIR_DEBUG("level=%d threads=%d dthreads=%d",
compress->level, compress->threads, compress->dthreads);
QEMU_CHECK_MONITOR_JSON(mon);
return qemuMonitorJSONSetMigrationCompression(mon, compress);
}
int
qemuMonitorGetMigrationStats(qemuMonitorPtr mon,
qemuMonitorMigrationStatsPtr stats)
......
......@@ -487,6 +487,23 @@ int qemuMonitorGetMigrationCacheSize(qemuMonitorPtr mon,
int qemuMonitorSetMigrationCacheSize(qemuMonitorPtr mon,
unsigned long long cacheSize);
typedef struct _qemuMonitorMigrationCompression qemuMonitorMigrationCompression;
typedef qemuMonitorMigrationCompression *qemuMonitorMigrationCompressionPtr;
struct _qemuMonitorMigrationCompression {
bool level_set;
bool threads_set;
bool dthreads_set;
int level;
int threads;
int dthreads;
};
int qemuMonitorGetMigrationCompression(qemuMonitorPtr mon,
qemuMonitorMigrationCompressionPtr compress);
int qemuMonitorSetMigrationCompression(qemuMonitorPtr mon,
qemuMonitorMigrationCompressionPtr compress);
typedef enum {
QEMU_MONITOR_MIGRATION_STATUS_INACTIVE,
QEMU_MONITOR_MIGRATION_STATUS_SETUP,
......
......@@ -2521,6 +2521,116 @@ qemuMonitorJSONSetMigrationCacheSize(qemuMonitorPtr mon,
}
int
qemuMonitorJSONGetMigrationCompression(qemuMonitorPtr mon,
qemuMonitorMigrationCompressionPtr compress)
{
int ret = -1;
virJSONValuePtr result;
virJSONValuePtr cmd = NULL;
virJSONValuePtr reply = NULL;
if (!(cmd = qemuMonitorJSONMakeCommand("query-migrate-parameters", NULL)))
return -1;
if ((ret = qemuMonitorJSONCommand(mon, cmd, &reply)) < 0)
goto cleanup;
if ((ret = qemuMonitorJSONCheckError(cmd, reply)) < 0)
goto cleanup;
if (!(result = virJSONValueObjectGet(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-migrate-parameters reply was missing "
"'return' data"));
goto cleanup;
}
if (virJSONValueObjectGetNumberInt(result, "compress-level",
&compress->level) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed/missing compress-level "
"in migrate parameters"));
goto cleanup;
}
compress->level_set = true;
if (virJSONValueObjectGetNumberInt(result, "compress-threads",
&compress->threads) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed/missing compress-threads "
"in migrate parameters"));
goto cleanup;
}
compress->threads_set = true;
if (virJSONValueObjectGetNumberInt(result, "decompress-threads",
&compress->dthreads) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed/missing decompress-threads "
"in migrate parameters"));
goto cleanup;
}
compress->dthreads_set = true;
ret = 0;
cleanup:
virJSONValueFree(cmd);
virJSONValueFree(reply);
return ret;
}
int
qemuMonitorJSONSetMigrationCompression(qemuMonitorPtr mon,
qemuMonitorMigrationCompressionPtr compress)
{
int ret = -1;
virJSONValuePtr cmd = NULL;
virJSONValuePtr args = NULL;
virJSONValuePtr reply = NULL;
if (!(cmd = virJSONValueNewObject()))
goto cleanup;
if (virJSONValueObjectAppendString(cmd, "execute",
"migrate-set-parameters") < 0)
goto cleanup;
if (!(args = virJSONValueNewObject()))
goto cleanup;
if (compress->level_set &&
virJSONValueObjectAppendNumberInt(args, "compress-level",
compress->level) < 0)
goto cleanup;
if (compress->threads_set &&
virJSONValueObjectAppendNumberInt(args, "compress-threads",
compress->threads) < 0)
goto cleanup;
if (compress->dthreads_set &&
virJSONValueObjectAppendNumberInt(args, "decompress-threads",
compress->dthreads) < 0)
goto cleanup;
if (virJSONValueObjectAppend(cmd, "arguments", args) < 0)
goto cleanup;
args = NULL;
if ((ret = qemuMonitorJSONCommand(mon, cmd, &reply)) < 0)
goto cleanup;
ret = qemuMonitorJSONCheckError(cmd, reply);
cleanup:
virJSONValueFree(cmd);
virJSONValueFree(args);
virJSONValueFree(reply);
return ret;
}
static int
qemuMonitorJSONGetMigrationStatsReply(virJSONValuePtr reply,
qemuMonitorMigrationStatsPtr stats)
......
......@@ -126,6 +126,11 @@ int qemuMonitorJSONGetMigrationCacheSize(qemuMonitorPtr mon,
int qemuMonitorJSONSetMigrationCacheSize(qemuMonitorPtr mon,
unsigned long long cacheSize);
int qemuMonitorJSONGetMigrationCompression(qemuMonitorPtr mon,
qemuMonitorMigrationCompressionPtr compress);
int qemuMonitorJSONSetMigrationCompression(qemuMonitorPtr mon,
qemuMonitorMigrationCompressionPtr compress);
int qemuMonitorJSONGetMigrationStats(qemuMonitorPtr mon,
qemuMonitorMigrationStatsPtr stats);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册