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

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