From 9f436e067df2e4465228c8ba536dcf9f9445aabc Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 13 Feb 2020 09:00:37 +0100 Subject: [PATCH] qemu: monitor: Add handler for blockdev-reopen Introduce the monitor code for using blockdev-reopen. Signed-off-by: Peter Krempa Reviewed-by: Eric Blake --- src/qemu/qemu_monitor.c | 13 +++++++++++++ src/qemu/qemu_monitor.h | 3 +++ src/qemu/qemu_monitor_json.c | 21 +++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 4 ++++ 4 files changed, 41 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 017b818f73..4a5bd1d4ab 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4353,6 +4353,19 @@ qemuMonitorBlockdevAdd(qemuMonitorPtr mon, } +int +qemuMonitorBlockdevReopen(qemuMonitorPtr mon, + virJSONValuePtr *props) +{ + VIR_DEBUG("props=%p (node-name=%s)", *props, + NULLSTR(virJSONValueObjectGetString(*props, "node-name"))); + + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONBlockdevReopen(mon, props); +} + + int qemuMonitorBlockdevDel(qemuMonitorPtr mon, const char *nodename) diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index be4195e734..2437375327 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1322,6 +1322,9 @@ int qemuMonitorBlockdevCreate(qemuMonitorPtr mon, int qemuMonitorBlockdevAdd(qemuMonitorPtr mon, virJSONValuePtr *props); +int qemuMonitorBlockdevReopen(qemuMonitorPtr mon, + virJSONValuePtr *props); + int qemuMonitorBlockdevDel(qemuMonitorPtr mon, const char *nodename); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 8e1e81ee06..8ac8291d0a 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8815,6 +8815,27 @@ qemuMonitorJSONBlockdevAdd(qemuMonitorPtr mon, } +int +qemuMonitorJSONBlockdevReopen(qemuMonitorPtr mon, + virJSONValuePtr *props) +{ + g_autoptr(virJSONValue) cmd = NULL; + g_autoptr(virJSONValue) reply = NULL; + virJSONValuePtr pr = g_steal_pointer(props); + + if (!(cmd = qemuMonitorJSONMakeCommandInternal("blockdev-reopen", pr))) + return -1; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + return -1; + + if (qemuMonitorJSONCheckError(cmd, reply) < 0) + return -1; + + return 0; +} + + int qemuMonitorJSONBlockdevDel(qemuMonitorPtr mon, const char *nodename) diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index ed48600b82..5b3bb295eb 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -602,6 +602,10 @@ int qemuMonitorJSONBlockdevAdd(qemuMonitorPtr mon, virJSONValuePtr *props) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); +int qemuMonitorJSONBlockdevReopen(qemuMonitorPtr mon, + virJSONValuePtr *props) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); + int qemuMonitorJSONBlockdevDel(qemuMonitorPtr mon, const char *nodename) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);