render / rpms / libvirt

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