From patchwork Mon Sep 19 16:54:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 671878 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sdCL03DFjz9sBX for ; Tue, 20 Sep 2016 03:19:20 +1000 (AEST) Received: from localhost ([::1]:57018 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bm2Du-0003ak-2T for incoming@patchwork.ozlabs.org; Mon, 19 Sep 2016 13:19:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43212) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bm1qm-00019U-Os for qemu-devel@nongnu.org; Mon, 19 Sep 2016 12:55:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bm1qi-0004Yz-I4 for qemu-devel@nongnu.org; Mon, 19 Sep 2016 12:55:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54642) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bm1qc-0004VG-9q; Mon, 19 Sep 2016 12:55:14 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B8041796EA; Mon, 19 Sep 2016 16:55:13 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-60.ams2.redhat.com [10.36.116.60]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8JGsxM5025063; Mon, 19 Sep 2016 12:55:12 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 19 Sep 2016 18:54:54 +0200 Message-Id: <1474304097-5790-8-git-send-email-kwolf@redhat.com> In-Reply-To: <1474304097-5790-1-git-send-email-kwolf@redhat.com> References: <1474304097-5790-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 19 Sep 2016 16:55:13 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 07/10] block: Accept device model name for eject X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, jsnow@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" In order to remove the necessity to use BlockBackend names in the external API, we want to allow qdev device names in all device related commands. This converts eject to accept a qdev device name. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- blockdev.c | 10 +++++++--- hmp.c | 2 +- qapi/block.json | 9 +++++++-- qmp-commands.hx | 10 ++++++---- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/blockdev.c b/blockdev.c index a007b22..3d92724 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2265,7 +2265,9 @@ exit: block_job_txn_unref(block_job_txn); } -void qmp_eject(const char *device, bool has_force, bool force, Error **errp) +void qmp_eject(bool has_device, const char *device, + bool has_id, const char *id, + bool has_force, bool force, Error **errp) { Error *local_err = NULL; int rc; @@ -2274,14 +2276,16 @@ void qmp_eject(const char *device, bool has_force, bool force, Error **errp) force = false; } - rc = do_open_tray(device, NULL, force, &local_err); + rc = do_open_tray(has_device ? device : NULL, + has_id ? id : NULL, + force, &local_err); if (rc && rc != -ENOSYS) { error_propagate(errp, local_err); return; } error_free(local_err); - qmp_x_blockdev_remove_medium(true, device, false, NULL, errp); + qmp_x_blockdev_remove_medium(has_device, device, has_id, id, errp); } void qmp_block_passwd(bool has_device, const char *device, diff --git a/hmp.c b/hmp.c index 0a16aef..09827b3 100644 --- a/hmp.c +++ b/hmp.c @@ -1376,7 +1376,7 @@ void hmp_eject(Monitor *mon, const QDict *qdict) const char *device = qdict_get_str(qdict, "device"); Error *err = NULL; - qmp_eject(device, true, force, &err); + qmp_eject(true, device, false, NULL, true, force, &err); hmp_handle_error(mon, &err); } diff --git a/qapi/block.json b/qapi/block.json index 8b08bd2..c896bd1 100644 --- a/qapi/block.json +++ b/qapi/block.json @@ -125,7 +125,9 @@ # # Ejects a device from a removable drive. # -# @device: The name of the device +# @device: #optional Block device name (deprecated, use @id instead) +# +# @id: #optional The name or QOM path of the guest device (since: 2.8) # # @force: @optional If true, eject regardless of whether the drive is locked. # If not specified, the default value is false. @@ -137,7 +139,10 @@ # # Since: 0.14.0 ## -{ 'command': 'eject', 'data': {'device': 'str', '*force': 'bool'} } +{ 'command': 'eject', + 'data': { '*device': 'str', + '*id': 'str', + '*force': 'bool' } } ## # @nbd-server-start: diff --git a/qmp-commands.hx b/qmp-commands.hx index 4d6d896..93904f8 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -83,7 +83,7 @@ EQMP { .name = "eject", - .args_type = "force:-f,device:B", + .args_type = "force:-f,device:B?,id:s?", .mhandler.cmd_new = qmp_marshal_eject, }, @@ -95,12 +95,14 @@ Eject a removable medium. Arguments: -- force: force ejection (json-bool, optional) -- device: device name (json-string) +- "force": force ejection (json-bool, optional) +- "device": block device name (deprecated, use @id instead) + (json-string, optional) +- "id": the name or QOM path of the guest device (json-string, optional) Example: --> { "execute": "eject", "arguments": { "device": "ide1-cd0" } } +-> { "execute": "eject", "arguments": { "id": "ide0-1-0" } } <- { "return": {} } Note: The "force" argument defaults to false.