From af6da2063b85befa76443464de02b6bb08f5e9b7 Mon Sep 17 00:00:00 2001
From: Markus Armbruster <armbru@redhat.com>
Date: Tue, 17 Dec 2013 06:46:35 +0100
Subject: QMP: Forward-port __com.redhat_drive_del from RHEL-6
RH-Author: Markus Armbruster <armbru@redhat.com>
Message-id: <1387262799-10350-3-git-send-email-armbru@redhat.com>
Patchwork-id: 56292
O-Subject: [PATCH v2 2/6] QMP: Forward-port __com.redhat_drive_del from RHEL-6
Bugzilla: 889051
RH-Acked-by: Fam Zheng <famz@redhat.com>
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
RH-Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
From: Markus Armbruster <armbru@redhat.com>
Upstream has drive_del, but only in HMP. The backport to RHEL-6 added
it to QMP as well. Since the QMP command is a downstream extension,
it needs the __com.redhat_ prefix. Since RHEL-6 doesn't have separate
definition of QMP and HMP commands, both the QMP and the HMP command
got the prefix.
RHEL-7 inherits HMP command drive_del from upstream. Add QMP command
__com.redhat_drive_del for RHEL-6 compatibility.
If we needed similar compatibility for the HMP command, we'd have to
add __com.redhat_drive_del as alias for drive_del. But we don't.
Code copied from RHEL-6's qemu-monitor.hx as of
qemu-kvm-0.12.1.2-2.418.el6. It has a "drive_del" without the prefix
in the documentation. Fixed here. Hardly worth fixing in RHEL-6 now.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
diff --git a/qmp-commands.hx b/qmp-commands.hx
index c091d59..514ef73 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -108,6 +108,37 @@ Note: The "force" argument defaults to false.
EQMP
{
+ .name = RFQDN_REDHAT "drive_del",
+ .args_type = "id:s",
+ .params = "device",
+ .help = "remove host block device",
+ .user_print = monitor_user_noop,
+ .mhandler.cmd_new = hmp_drive_del,
+ },
+
+SQMP
+__com.redhat_drive_del
+----------
+
+Remove host block device. The result is that guest generated IO is no longer
+submitted against the host device underlying the disk. Once a drive has
+been deleted, the QEMU Block layer returns -EIO which results in IO
+errors in the guest for applications that are reading/writing to the device.
+These errors are always reported to the guest, regardless of the drive's error
+actions (drive options rerror, werror).
+
+Arguments:
+
+- "id": the device's ID (json-string)
+
+Example:
+
+-> { "execute": "__com.redhat_drive_del", "arguments": { "id": "block1" } }
+<- { "return": {} }
+
+EQMP
+
+ {
.name = "change",
.args_type = "device:B,target:F,arg:s?",
.mhandler.cmd_new = qmp_marshal_input_change,