From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, mreitz@redhat.com, eblake@redhat.com,
qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 08/10] block: Accept device model name for blockdev-change-medium
Date: Fri, 19 Aug 2016 18:50:33 +0200 [thread overview]
Message-ID: <1471625435-6190-9-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1471625435-6190-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 blockdev-change-medium to accept a qdev device name.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
blockdev.c | 18 +++++++++++-------
hmp.c | 5 +++--
qapi/block-core.json | 5 ++++-
qmp-commands.hx | 6 ++++--
qmp.c | 4 ++--
5 files changed, 24 insertions(+), 14 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 7bed3f6..6f81b07 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2536,7 +2536,9 @@ void qmp_x_blockdev_insert_medium(bool has_device, const char *device,
qmp_blockdev_insert_anon_medium(blk, bs, errp);
}
-void qmp_blockdev_change_medium(const char *device, const char *filename,
+void qmp_blockdev_change_medium(bool has_device, const char *device,
+ bool has_id, const char *id,
+ const char *filename,
bool has_format, const char *format,
bool has_read_only,
BlockdevChangeReadOnlyMode read_only,
@@ -2549,10 +2551,10 @@ void qmp_blockdev_change_medium(const char *device, const char *filename,
QDict *options = NULL;
Error *err = NULL;
- blk = blk_by_name(device);
+ blk = qmp_get_blk(has_device ? device : NULL,
+ has_id ? id : NULL,
+ errp);
if (!blk) {
- error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
- "Device '%s' not found", device);
goto fail;
}
@@ -2600,7 +2602,9 @@ void qmp_blockdev_change_medium(const char *device, const char *filename,
goto fail;
}
- rc = do_open_tray(device, NULL, false, &err);
+ rc = do_open_tray(has_device ? device : NULL,
+ has_id ? id : NULL,
+ false, &err);
if (rc && rc != -ENOSYS) {
error_propagate(errp, err);
goto fail;
@@ -2608,7 +2612,7 @@ void qmp_blockdev_change_medium(const char *device, const char *filename,
error_free(err);
err = NULL;
- qmp_x_blockdev_remove_medium(true, device, false, NULL, errp);
+ qmp_x_blockdev_remove_medium(has_device, device, has_id, id, errp);
if (err) {
error_propagate(errp, err);
goto fail;
@@ -2622,7 +2626,7 @@ void qmp_blockdev_change_medium(const char *device, const char *filename,
blk_apply_root_state(blk, medium_bs);
- qmp_blockdev_close_tray(true, device, false, NULL, errp);
+ qmp_blockdev_close_tray(has_device, device, has_id, id, errp);
fail:
/* If the medium has been inserted, the device has its own reference, so
diff --git a/hmp.c b/hmp.c
index fbd451a..dbe426a 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1422,8 +1422,9 @@ void hmp_change(Monitor *mon, const QDict *qdict)
}
}
- qmp_blockdev_change_medium(device, target, !!arg, arg,
- !!read_only, read_only_mode, &err);
+ qmp_blockdev_change_medium(true, device, false, NULL, target,
+ !!arg, arg, !!read_only, read_only_mode,
+ &err);
if (err &&
error_get_class(err) == ERROR_CLASS_DEVICE_ENCRYPTED) {
error_free(err);
diff --git a/qapi/block-core.json b/qapi/block-core.json
index c3177f4..9a19a50 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -2425,6 +2425,8 @@
#
# @device: block device name
#
+# @id: the name or QOM path of the guest device (since: 2.8)
+#
# @filename: filename of the new image to be loaded
#
# @format: #optional, format to open the new image with (defaults to
@@ -2436,7 +2438,8 @@
# Since: 2.5
##
{ 'command': 'blockdev-change-medium',
- 'data': { 'device': 'str',
+ 'data': { '*device': 'str',
+ '*id': 'str',
'filename': 'str',
'*format': 'str',
'*read-only-mode': 'BlockdevChangeReadOnlyMode' } }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 8822fd5..b11e4e4 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -4573,7 +4573,7 @@ EQMP
{
.name = "blockdev-change-medium",
- .args_type = "device:B,filename:F,format:s?,read-only-mode:s?",
+ .args_type = "device:B?,id:s?,filename:F,format:s?,read-only-mode:s?",
.mhandler.cmd_new = qmp_marshal_blockdev_change_medium,
},
@@ -4586,7 +4586,9 @@ and loading a new image file which is inserted as the new medium.
Arguments:
-- "device": device name (json-string)
+- "device": block device name (deprecated, use @id instead)
+ (json-string, optional)
+- "id": the name or QOM path of the guest device (json-string, optional)
- "filename": filename of the new image (json-string)
- "format": format of the new image (json-string, optional)
- "read-only-mode": new read-only mode (json-string, optional)
diff --git a/qmp.c b/qmp.c
index b6d531e..f8be3e4 100644
--- a/qmp.c
+++ b/qmp.c
@@ -446,8 +446,8 @@ void qmp_change(const char *device, const char *target,
if (strcmp(device, "vnc") == 0) {
qmp_change_vnc(target, has_arg, arg, errp);
} else {
- qmp_blockdev_change_medium(device, target, has_arg, arg, false, 0,
- errp);
+ qmp_blockdev_change_medium(true, device, false, NULL, target,
+ has_arg, arg, false, 0, errp);
}
}
--
1.8.3.1
next prev parent reply other threads:[~2016-08-19 16:51 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-19 16:50 [Qemu-devel] [PATCH 00/10] block: Accept qdev IDs in device level QMP commands Kevin Wolf
2016-08-19 16:50 ` [Qemu-devel] [PATCH 01/10] block: Add blk_by_dev() Kevin Wolf
2016-08-19 16:50 ` [Qemu-devel] [PATCH 02/10] qdev-monitor: Factor out find_device_state() Kevin Wolf
2016-08-19 16:50 ` [Qemu-devel] [PATCH 03/10] qdev-monitor: Add blk_by_qdev_id() Kevin Wolf
2016-08-19 16:50 ` [Qemu-devel] [PATCH 04/10] block: Accept device model name for blockdev-open/close-tray Kevin Wolf
2016-09-14 20:49 ` Eric Blake
2016-09-15 8:35 ` Kevin Wolf
2016-09-15 15:51 ` Eric Blake
2016-09-19 15:10 ` Kevin Wolf
2016-08-19 16:50 ` [Qemu-devel] [PATCH 05/10] block: Accept device model name for x-blockdev-insert-medium Kevin Wolf
2016-09-14 20:57 ` Eric Blake
2016-09-15 8:37 ` Kevin Wolf
2016-09-15 15:53 ` Eric Blake
2016-08-19 16:50 ` [Qemu-devel] [PATCH 06/10] block: Accept device model name for x-blockdev-remove-medium Kevin Wolf
2016-09-14 21:01 ` Eric Blake
2016-08-19 16:50 ` [Qemu-devel] [PATCH 07/10] block: Accept device model name for eject Kevin Wolf
2016-09-14 21:09 ` Eric Blake
2016-08-19 16:50 ` Kevin Wolf [this message]
2016-09-14 22:06 ` [Qemu-devel] [PATCH 08/10] block: Accept device model name for blockdev-change-medium Eric Blake
2016-08-19 16:50 ` [Qemu-devel] [PATCH 09/10] block: Accept device model name for block_set_io_throttle Kevin Wolf
2016-09-14 22:07 ` Eric Blake
2016-08-19 16:50 ` [Qemu-devel] [PATCH 10/10] qemu-iotests/118: Test media change with qdev name Kevin Wolf
2016-09-14 22:13 ` Eric Blake
2016-09-15 8:47 ` Kevin Wolf
2016-09-15 16:16 ` Sascha Silbe
2016-09-15 16:23 ` Eric Blake
2016-09-15 16:28 ` Sascha Silbe
2016-09-15 16:33 ` Eric Blake
2016-09-15 17:57 ` Sascha Silbe
2016-09-05 15:55 ` [Qemu-devel] [PATCH 00/10] block: Accept qdev IDs in device level QMP commands Kevin Wolf
2016-09-14 13:03 ` [Qemu-devel] [Qemu-block] " Kevin Wolf
2016-09-14 21:52 ` John Snow
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=1471625435-6190-9-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=eblake@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).