qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, eblake@redhat.com, mreitz@redhat.com,
	jsnow@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v3 07/10] block: Accept device model name for eject
Date: Tue, 20 Sep 2016 13:38:46 +0200	[thread overview]
Message-ID: <1474371529-24466-8-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1474371529-24466-1-git-send-email-kwolf@redhat.com>

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 <kwolf@redhat.com>
---
 blockdev.c            | 10 +++++++---
 docs/qmp-commands.txt |  8 +++++---
 hmp.c                 |  2 +-
 qapi/block.json       |  9 +++++++--
 4 files changed, 20 insertions(+), 9 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/docs/qmp-commands.txt b/docs/qmp-commands.txt
index e77bf2f..9024ef2 100644
--- a/docs/qmp-commands.txt
+++ b/docs/qmp-commands.txt
@@ -72,12 +72,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.
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:
-- 
1.8.3.1

  parent reply	other threads:[~2016-09-20 11:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-20 11:38 [Qemu-devel] [PATCH v3 00/10] block: Accept qdev IDs in device level QMP commands Kevin Wolf
2016-09-20 11:38 ` [Qemu-devel] [PATCH v3 01/10] block: Add blk_by_dev() Kevin Wolf
2016-09-20 11:38 ` [Qemu-devel] [PATCH v3 02/10] qdev-monitor: Factor out find_device_state() Kevin Wolf
2016-09-20 11:38 ` [Qemu-devel] [PATCH v3 03/10] qdev-monitor: Add blk_by_qdev_id() Kevin Wolf
2016-09-20 11:38 ` [Qemu-devel] [PATCH v3 04/10] block: Accept device model name for blockdev-open/close-tray Kevin Wolf
2016-09-20 17:55   ` Eric Blake
2016-09-20 11:38 ` [Qemu-devel] [PATCH v3 05/10] block: Accept device model name for x-blockdev-insert-medium Kevin Wolf
2016-09-20 11:38 ` [Qemu-devel] [PATCH v3 06/10] block: Accept device model name for x-blockdev-remove-medium Kevin Wolf
2016-09-20 11:38 ` Kevin Wolf [this message]
2016-09-20 11:38 ` [Qemu-devel] [PATCH v3 08/10] block: Accept device model name for blockdev-change-medium Kevin Wolf
2016-09-20 11:38 ` [Qemu-devel] [PATCH v3 09/10] block: Accept device model name for block_set_io_throttle Kevin Wolf
2016-09-20 11:38 ` [Qemu-devel] [PATCH v3 10/10] qemu-iotests/118: Test media change with qdev name Kevin Wolf
2016-09-20 18:01 ` [Qemu-devel] [PATCH v3 00/10] block: Accept qdev IDs in device level QMP commands Eric Blake
2016-09-21 11:02   ` Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1474371529-24466-8-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=eblake@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).