From c7afaa69cdd712d74d98e3cb37afd1b46aef7e42 Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Wed, 15 Jul 2020 22:33:07 +0200 Subject: [PATCH] qemu_monitor: Add API for checking CPU migratable property Signed-off-by: Jiri Denemark Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_monitor.c | 18 ++++++++++++++++++ src/qemu/qemu_monitor.h | 4 ++++ src/qemu/qemu_monitor_json.c | 27 +++++++++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 4 ++++ 4 files changed, 53 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 2c66397f8b..637361d24d 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4526,6 +4526,24 @@ qemuMonitorGetJobInfo(qemuMonitorPtr mon, } +/* qemuMonitorGetCPUMigratable: + * + * Get the migratable property of the CPU object. + * + * Returns -1 on error, + * 1 when the property is not supported, + * 0 on success (@migratable is set accordingly). + */ +int +qemuMonitorGetCPUMigratable(qemuMonitorPtr mon, + bool *migratable) +{ + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONGetCPUMigratable(mon, migratable); +} + + int qemuMonitorTransactionBitmapAdd(virJSONValuePtr actions, const char *node, diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 50a337715d..1c1b0c9b89 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1377,6 +1377,10 @@ int qemuMonitorGetJobInfo(qemuMonitorPtr mon, qemuMonitorJobInfoPtr **jobs, size_t *njobs); +int +qemuMonitorGetCPUMigratable(qemuMonitorPtr mon, + bool *migratable); + int qemuMonitorTransactionBitmapAdd(virJSONValuePtr actions, const char *node, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index d808c4b55b..83f169e31b 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -9388,3 +9388,30 @@ qemuMonitorJSONGetJobInfo(qemuMonitorPtr mon, return 0; } + + +int +qemuMonitorJSONGetCPUMigratable(qemuMonitorPtr mon, + bool *migratable) +{ + g_autoptr(virJSONValue) cmd = NULL; + g_autoptr(virJSONValue) reply = NULL; + + if (!(cmd = qemuMonitorJSONMakeCommand("qom-get", + "s:path", QOM_CPU_PATH, + "s:property", "migratable", + NULL))) + return -1; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + return -1; + + if (qemuMonitorJSONHasError(reply, "GenericError")) + return 1; + + if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_BOOLEAN) < 0) + return -1; + + return virJSONValueGetBoolean(virJSONValueObjectGet(reply, "return"), + migratable); +} diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 83c5e25ca5..84fea25983 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -690,3 +690,7 @@ int qemuMonitorJSONSetDBusVMStateIdList(qemuMonitorPtr mon, const char *vmstatepath, const char **list) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); + +int +qemuMonitorJSONGetCPUMigratable(qemuMonitorPtr mon, + bool *migratable);