From 60b62c9d02e5e19e4cfa6eaeb6652339d4c4ede5 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Tue, 14 Mar 2017 14:03:39 +0100 Subject: QMP: Forward-port __com.redhat_drive_del from RHEL-6 RH-Author: Markus Armbruster 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 RH-Acked-by: Stefan Hajnoczi RH-Acked-by: Luiz Capitulino From: Markus Armbruster 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 Rebase notes (2.9.0): - documentation moved from docs/qmp-commands.txt to qapi/block.json - replace qmp_x_blockdev_del with qmp_blockdev_del (due to 79b7a77) Rebase notes (2.8.0): - qmp-commands.hx replaced by docs/qmp-commands.txt (commit bd6092e) - Changed qmp_x_blockdev_del arguments (upstream) Rebase notes (2.4.0): - use traditional cmd for qmp - remove user_print Merged patches (2.9.0): - 4831182 QMP: Fix forward port of __com.redhat_drive_del Merged patches (2.7.0): - 85786e0 Fix crash with __com.redhat_drive_del (cherry picked from commit b7a0cafd6494cd3855fe10934314b6b1d2df5d2d) --- blockdev.c | 28 ++++++++++++++++------------ qapi/block.json | 23 +++++++++++++++++++++++ 2 files changed, 39 insertions(+), 12 deletions(-) diff --git a/blockdev.c b/blockdev.c index 02cd69b..d5e8ee3 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2854,32 +2854,27 @@ BlockDirtyBitmapSha256 *qmp_x_debug_block_dirty_bitmap_sha256(const char *node, return ret; } -void hmp_drive_del(Monitor *mon, const QDict *qdict) +void qmp___com_redhat_drive_del(const char *id, Error **errp) { - const char *id = qdict_get_str(qdict, "id"); BlockBackend *blk; BlockDriverState *bs; AioContext *aio_context; - Error *local_err = NULL; bs = bdrv_find_node(id); if (bs) { - qmp_blockdev_del(id, &local_err); - if (local_err) { - error_report_err(local_err); - } + qmp_blockdev_del(id, errp); return; } blk = blk_by_name(id); if (!blk) { - error_report("Device '%s' not found", id); + error_setg(errp, "Device '%s' not found", id); return; } if (!blk_legacy_dinfo(blk)) { - error_report("Deleting device added with blockdev-add" - " is not supported"); + error_setg(errp, "Deleting device added with blockdev-add" + " is not supported"); return; } @@ -2888,8 +2883,7 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict) bs = blk_bs(blk); if (bs) { - if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_DRIVE_DEL, &local_err)) { - error_report_err(local_err); + if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_DRIVE_DEL, errp)) { aio_context_release(aio_context); return; } @@ -2914,6 +2908,16 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict) aio_context_release(aio_context); } +void hmp_drive_del(Monitor *mon, const QDict *qdict) +{ + Error *local_err = NULL; + + qmp___com_redhat_drive_del(qdict_get_str(qdict, "id"), &local_err); + if (local_err) { + error_report_err(local_err); + } +} + void qmp_block_resize(bool has_device, const char *device, bool has_node_name, const char *node_name, int64_t size, Error **errp) diff --git a/qapi/block.json b/qapi/block.json index 414b61b..03115d3 100644 --- a/qapi/block.json +++ b/qapi/block.json @@ -189,6 +189,29 @@ '*force': 'bool' } } ## +# @__com.redhat_drive_del: +# +# Remove host block device. +# +# 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). +# +# @id: the device's ID +# +# Example: +# +# -> { "execute": "__com.redhat_drive_del", "arguments": { "id": "block1" } } +# <- { "return": {} } +# +## +{ 'command': '__com.redhat_drive_del', + 'data': { 'id': 'str' } } + +## # @nbd-server-start: # # Start an NBD server listening on the given host and port. Block -- 1.8.3.1