cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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