From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ban0W-0001wL-4N for qemu-devel@nongnu.org; Fri, 19 Aug 2016 12:51:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ban0U-0006Af-3z for qemu-devel@nongnu.org; Fri, 19 Aug 2016 12:50:59 -0400 From: Kevin Wolf Date: Fri, 19 Aug 2016 18:50:32 +0200 Message-Id: <1471625435-6190-8-git-send-email-kwolf@redhat.com> In-Reply-To: <1471625435-6190-1-git-send-email-kwolf@redhat.com> References: <1471625435-6190-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 07/10] block: Accept device model name for eject List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, mreitz@redhat.com, eblake@redhat.com, qemu-devel@nongnu.org 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 --- blockdev.c | 10 +++++++--- hmp.c | 2 +- qapi/block.json | 7 ++++++- qmp-commands.hx | 8 +++++--- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/blockdev.c b/blockdev.c index 77cf8db..7bed3f6 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2263,7 +2263,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; @@ -2272,14 +2274,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 ad33b44..fbd451a 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..8234cca 100644 --- a/qapi/block.json +++ b/qapi/block.json @@ -127,6 +127,8 @@ # # @device: The name of the device # +# @id: 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 6f10cdf..8822fd5 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,8 +95,10 @@ 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: -- 1.8.3.1