Blame SOURCES/0011-QMP-Forward-port-__com.redhat_drive_del-from-RHEL-6.patch

9bac43
From 60b62c9d02e5e19e4cfa6eaeb6652339d4c4ede5 Mon Sep 17 00:00:00 2001
9bac43
From: Markus Armbruster <armbru@redhat.com>
9bac43
Date: Tue, 14 Mar 2017 14:03:39 +0100
9bac43
Subject: QMP: Forward-port __com.redhat_drive_del from RHEL-6
9bac43
9bac43
RH-Author: Markus Armbruster <armbru@redhat.com>
9bac43
Message-id: <1387262799-10350-3-git-send-email-armbru@redhat.com>
9bac43
Patchwork-id: 56292
9bac43
O-Subject: [PATCH v2 2/6] QMP: Forward-port __com.redhat_drive_del from RHEL-6
9bac43
Bugzilla: 889051
9bac43
RH-Acked-by: Fam Zheng <famz@redhat.com>
9bac43
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9bac43
RH-Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
9bac43
9bac43
From: Markus Armbruster <armbru@redhat.com>
9bac43
9bac43
Upstream has drive_del, but only in HMP.  The backport to RHEL-6 added
9bac43
it to QMP as well.  Since the QMP command is a downstream extension,
9bac43
it needs the __com.redhat_ prefix.  Since RHEL-6 doesn't have separate
9bac43
definition of QMP and HMP commands, both the QMP and the HMP command
9bac43
got the prefix.
9bac43
9bac43
RHEL-7 inherits HMP command drive_del from upstream.  Add QMP command
9bac43
__com.redhat_drive_del for RHEL-6 compatibility.
9bac43
9bac43
If we needed similar compatibility for the HMP command, we'd have to
9bac43
add __com.redhat_drive_del as alias for drive_del.  But we don't.
9bac43
9bac43
Code copied from RHEL-6's qemu-monitor.hx as of
9bac43
qemu-kvm-0.12.1.2-2.418.el6.  It has a "drive_del" without the prefix
9bac43
in the documentation.  Fixed here.  Hardly worth fixing in RHEL-6 now.
9bac43
9bac43
Signed-off-by: Markus Armbruster <armbru@redhat.com>
9bac43
9bac43
Rebase notes (2.9.0):
9bac43
- documentation moved from docs/qmp-commands.txt to qapi/block.json
9bac43
- replace qmp_x_blockdev_del with qmp_blockdev_del (due to 79b7a77)
9bac43
9bac43
Rebase notes (2.8.0):
9bac43
- qmp-commands.hx replaced by docs/qmp-commands.txt (commit bd6092e)
9bac43
- Changed qmp_x_blockdev_del arguments (upstream)
9bac43
9bac43
Rebase notes (2.4.0):
9bac43
- use traditional cmd for qmp
9bac43
- remove user_print
9bac43
9bac43
Merged patches (2.9.0):
9bac43
- 4831182 QMP: Fix forward port of __com.redhat_drive_del
9bac43
9bac43
Merged patches (2.7.0):
9bac43
- 85786e0 Fix crash with __com.redhat_drive_del
9bac43
9bac43
(cherry picked from commit b7a0cafd6494cd3855fe10934314b6b1d2df5d2d)
9bac43
---
9bac43
 blockdev.c      | 28 ++++++++++++++++------------
9bac43
 qapi/block.json | 23 +++++++++++++++++++++++
9bac43
 2 files changed, 39 insertions(+), 12 deletions(-)
9bac43
9bac43
diff --git a/blockdev.c b/blockdev.c
9bac43
index 02cd69b..d5e8ee3 100644
9bac43
--- a/blockdev.c
9bac43
+++ b/blockdev.c
9bac43
@@ -2854,32 +2854,27 @@ BlockDirtyBitmapSha256 *qmp_x_debug_block_dirty_bitmap_sha256(const char *node,
9bac43
     return ret;
9bac43
 }
9bac43
 
9bac43
-void hmp_drive_del(Monitor *mon, const QDict *qdict)
9bac43
+void qmp___com_redhat_drive_del(const char *id, Error **errp)
9bac43
 {
9bac43
-    const char *id = qdict_get_str(qdict, "id");
9bac43
     BlockBackend *blk;
9bac43
     BlockDriverState *bs;
9bac43
     AioContext *aio_context;
9bac43
-    Error *local_err = NULL;
9bac43
 
9bac43
     bs = bdrv_find_node(id);
9bac43
     if (bs) {
9bac43
-        qmp_blockdev_del(id, &local_err);
9bac43
-        if (local_err) {
9bac43
-            error_report_err(local_err);
9bac43
-        }
9bac43
+        qmp_blockdev_del(id, errp);
9bac43
         return;
9bac43
     }
9bac43
 
9bac43
     blk = blk_by_name(id);
9bac43
     if (!blk) {
9bac43
-        error_report("Device '%s' not found", id);
9bac43
+        error_setg(errp, "Device '%s' not found", id);
9bac43
         return;
9bac43
     }
9bac43
 
9bac43
     if (!blk_legacy_dinfo(blk)) {
9bac43
-        error_report("Deleting device added with blockdev-add"
9bac43
-                     " is not supported");
9bac43
+        error_setg(errp, "Deleting device added with blockdev-add"
9bac43
+                         " is not supported");
9bac43
         return;
9bac43
     }
9bac43
 
9bac43
@@ -2888,8 +2883,7 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict)
9bac43
 
9bac43
     bs = blk_bs(blk);
9bac43
     if (bs) {
9bac43
-        if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_DRIVE_DEL, &local_err)) {
9bac43
-            error_report_err(local_err);
9bac43
+        if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_DRIVE_DEL, errp)) {
9bac43
             aio_context_release(aio_context);
9bac43
             return;
9bac43
         }
9bac43
@@ -2914,6 +2908,16 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict)
9bac43
     aio_context_release(aio_context);
9bac43
 }
9bac43
 
9bac43
+void hmp_drive_del(Monitor *mon, const QDict *qdict)
9bac43
+{
9bac43
+    Error *local_err = NULL;
9bac43
+
9bac43
+    qmp___com_redhat_drive_del(qdict_get_str(qdict, "id"), &local_err);
9bac43
+    if (local_err) {
9bac43
+        error_report_err(local_err);
9bac43
+    }
9bac43
+}
9bac43
+
9bac43
 void qmp_block_resize(bool has_device, const char *device,
9bac43
                       bool has_node_name, const char *node_name,
9bac43
                       int64_t size, Error **errp)
9bac43
diff --git a/qapi/block.json b/qapi/block.json
9bac43
index 414b61b..03115d3 100644
9bac43
--- a/qapi/block.json
9bac43
+++ b/qapi/block.json
9bac43
@@ -189,6 +189,29 @@
9bac43
             '*force': 'bool' } }
9bac43
 
9bac43
 ##
9bac43
+# @__com.redhat_drive_del:
9bac43
+#
9bac43
+# Remove host block device.
9bac43
+#
9bac43
+# Remove host block device.  The result is that guest generated IO is no longer
9bac43
+# submitted against the host device underlying the disk.  Once a drive has
9bac43
+# been deleted, the QEMU Block layer returns -EIO which results in IO
9bac43
+# errors in the guest for applications that are reading/writing to the device.
9bac43
+# These errors are always reported to the guest, regardless of the drive's error
9bac43
+# actions (drive options rerror, werror).
9bac43
+# 
9bac43
+# @id: the device's ID
9bac43
+#
9bac43
+# Example:
9bac43
+#
9bac43
+# -> { "execute": "__com.redhat_drive_del", "arguments": { "id": "block1" } }
9bac43
+# <- { "return": {} }
9bac43
+#
9bac43
+##
9bac43
+{ 'command': '__com.redhat_drive_del',
9bac43
+  'data': { 'id': 'str' } }
9bac43
+
9bac43
+##
9bac43
 # @nbd-server-start:
9bac43
 #
9bac43
 # Start an NBD server listening on the given host and port.  Block
9bac43
-- 
9bac43
1.8.3.1
9bac43