mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-12 22:51:29 +00:00
qemu: monitor: add migration parameters accessors
Signed-off-by: ShaoHe Feng <shaohe.feng@intel.com> Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
This commit is contained in:
parent
231b25db67
commit
8979c5ddb9
@ -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
|
int
|
||||||
qemuMonitorGetMigrationStats(qemuMonitorPtr mon,
|
qemuMonitorGetMigrationStats(qemuMonitorPtr mon,
|
||||||
qemuMonitorMigrationStatsPtr stats)
|
qemuMonitorMigrationStatsPtr stats)
|
||||||
|
@ -487,6 +487,23 @@ int qemuMonitorGetMigrationCacheSize(qemuMonitorPtr mon,
|
|||||||
int qemuMonitorSetMigrationCacheSize(qemuMonitorPtr mon,
|
int qemuMonitorSetMigrationCacheSize(qemuMonitorPtr mon,
|
||||||
unsigned long long cacheSize);
|
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 {
|
typedef enum {
|
||||||
QEMU_MONITOR_MIGRATION_STATUS_INACTIVE,
|
QEMU_MONITOR_MIGRATION_STATUS_INACTIVE,
|
||||||
QEMU_MONITOR_MIGRATION_STATUS_SETUP,
|
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
|
static int
|
||||||
qemuMonitorJSONGetMigrationStatsReply(virJSONValuePtr reply,
|
qemuMonitorJSONGetMigrationStatsReply(virJSONValuePtr reply,
|
||||||
qemuMonitorMigrationStatsPtr stats)
|
qemuMonitorMigrationStatsPtr stats)
|
||||||
|
@ -126,6 +126,11 @@ int qemuMonitorJSONGetMigrationCacheSize(qemuMonitorPtr mon,
|
|||||||
int qemuMonitorJSONSetMigrationCacheSize(qemuMonitorPtr mon,
|
int qemuMonitorJSONSetMigrationCacheSize(qemuMonitorPtr mon,
|
||||||
unsigned long long cacheSize);
|
unsigned long long cacheSize);
|
||||||
|
|
||||||
|
int qemuMonitorJSONGetMigrationCompression(qemuMonitorPtr mon,
|
||||||
|
qemuMonitorMigrationCompressionPtr compress);
|
||||||
|
int qemuMonitorJSONSetMigrationCompression(qemuMonitorPtr mon,
|
||||||
|
qemuMonitorMigrationCompressionPtr compress);
|
||||||
|
|
||||||
int qemuMonitorJSONGetMigrationStats(qemuMonitorPtr mon,
|
int qemuMonitorJSONGetMigrationStats(qemuMonitorPtr mon,
|
||||||
qemuMonitorMigrationStatsPtr stats);
|
qemuMonitorMigrationStatsPtr stats);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user