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

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