render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
a41c76
From 56a605626d81ee27ad220f3f949990cc46fca061 Mon Sep 17 00:00:00 2001
a41c76
Message-Id: <56a605626d81ee27ad220f3f949990cc46fca061@dist-git>
a41c76
From: Peter Krempa <pkrempa@redhat.com>
a41c76
Date: Mon, 16 Mar 2020 22:12:15 +0100
a41c76
Subject: [PATCH] qemu: monitor: Add handler for blockdev-reopen
a41c76
MIME-Version: 1.0
a41c76
Content-Type: text/plain; charset=UTF-8
a41c76
Content-Transfer-Encoding: 8bit
a41c76
a41c76
Introduce the monitor code for using blockdev-reopen.
a41c76
a41c76
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
a41c76
Reviewed-by: Eric Blake <eblake@redhat.com>
a41c76
(cherry picked from commit 9f436e067df2e4465228c8ba536dcf9f9445aabc)
a41c76
a41c76
https://bugzilla.redhat.com/show_bug.cgi?id=1799013
a41c76
Message-Id: <e74e172e1c5e73fcaeafb7fb3a09414a2fcbe9ad.1584391727.git.pkrempa@redhat.com>
a41c76
Reviewed-by: Ján Tomko <jtomko@redhat.com>
a41c76
---
a41c76
 src/qemu/qemu_monitor.c      | 13 +++++++++++++
a41c76
 src/qemu/qemu_monitor.h      |  3 +++
a41c76
 src/qemu/qemu_monitor_json.c | 21 +++++++++++++++++++++
a41c76
 src/qemu/qemu_monitor_json.h |  4 ++++
a41c76
 4 files changed, 41 insertions(+)
a41c76
a41c76
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
a41c76
index e3ee48613a..c4202d59af 100644
a41c76
--- a/src/qemu/qemu_monitor.c
a41c76
+++ b/src/qemu/qemu_monitor.c
a41c76
@@ -4407,6 +4407,19 @@ qemuMonitorBlockdevAdd(qemuMonitorPtr mon,
a41c76
 }
a41c76
 
a41c76
 
a41c76
+int
a41c76
+qemuMonitorBlockdevReopen(qemuMonitorPtr mon,
a41c76
+                          virJSONValuePtr *props)
a41c76
+{
a41c76
+    VIR_DEBUG("props=%p (node-name=%s)", *props,
a41c76
+              NULLSTR(virJSONValueObjectGetString(*props, "node-name")));
a41c76
+
a41c76
+    QEMU_CHECK_MONITOR(mon);
a41c76
+
a41c76
+    return qemuMonitorJSONBlockdevReopen(mon, props);
a41c76
+}
a41c76
+
a41c76
+
a41c76
 int
a41c76
 qemuMonitorBlockdevDel(qemuMonitorPtr mon,
a41c76
                        const char *nodename)
a41c76
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
a41c76
index 6a6b8efaee..481fc8e12e 100644
a41c76
--- a/src/qemu/qemu_monitor.h
a41c76
+++ b/src/qemu/qemu_monitor.h
a41c76
@@ -1325,6 +1325,9 @@ int qemuMonitorBlockdevCreate(qemuMonitorPtr mon,
a41c76
 int qemuMonitorBlockdevAdd(qemuMonitorPtr mon,
a41c76
                            virJSONValuePtr *props);
a41c76
 
a41c76
+int qemuMonitorBlockdevReopen(qemuMonitorPtr mon,
a41c76
+                              virJSONValuePtr *props);
a41c76
+
a41c76
 int qemuMonitorBlockdevDel(qemuMonitorPtr mon,
a41c76
                            const char *nodename);
a41c76
 
a41c76
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
a41c76
index 3827574ef6..0122b77259 100644
a41c76
--- a/src/qemu/qemu_monitor_json.c
a41c76
+++ b/src/qemu/qemu_monitor_json.c
a41c76
@@ -8830,6 +8830,27 @@ qemuMonitorJSONBlockdevAdd(qemuMonitorPtr mon,
a41c76
 }
a41c76
 
a41c76
 
a41c76
+int
a41c76
+qemuMonitorJSONBlockdevReopen(qemuMonitorPtr mon,
a41c76
+                              virJSONValuePtr *props)
a41c76
+{
a41c76
+    g_autoptr(virJSONValue) cmd = NULL;
a41c76
+    g_autoptr(virJSONValue) reply = NULL;
a41c76
+    virJSONValuePtr pr = g_steal_pointer(props);
a41c76
+
a41c76
+    if (!(cmd = qemuMonitorJSONMakeCommandInternal("blockdev-reopen", pr)))
a41c76
+        return -1;
a41c76
+
a41c76
+    if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
a41c76
+        return -1;
a41c76
+
a41c76
+    if (qemuMonitorJSONCheckError(cmd, reply) < 0)
a41c76
+        return -1;
a41c76
+
a41c76
+    return 0;
a41c76
+}
a41c76
+
a41c76
+
a41c76
 int
a41c76
 qemuMonitorJSONBlockdevDel(qemuMonitorPtr mon,
a41c76
                            const char *nodename)
a41c76
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
a41c76
index fd2e09025e..801babef97 100644
a41c76
--- a/src/qemu/qemu_monitor_json.h
a41c76
+++ b/src/qemu/qemu_monitor_json.h
a41c76
@@ -600,6 +600,10 @@ int qemuMonitorJSONBlockdevAdd(qemuMonitorPtr mon,
a41c76
                                virJSONValuePtr *props)
a41c76
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
a41c76
 
a41c76
+int qemuMonitorJSONBlockdevReopen(qemuMonitorPtr mon,
a41c76
+                                  virJSONValuePtr *props)
a41c76
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
a41c76
+
a41c76
 int qemuMonitorJSONBlockdevDel(qemuMonitorPtr mon,
a41c76
                                const char *nodename)
a41c76
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
a41c76
-- 
a41c76
2.25.1
a41c76