From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 02/48] blockdev: Fix 'change' for slot devices
Date: Fri, 29 Jan 2016 18:37:08 +0100 [thread overview]
Message-ID: <1454089074-4819-3-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1454089074-4819-1-git-send-email-kwolf@redhat.com>
From: Max Reitz <mreitz@redhat.com>
'change' and related operations did not work when used on guest devices
featuring removable media but no actual tray, because
blk_dev_is_tray_open() always returned false for them and the
blockdev-{insert,remove}-medium commands required it to return true.
Fix this by making blockdev-{insert,remove}-medium work on tray-less
devices. Also, blockdev-{open,close}-tray are now explicitly no-ops when
invoked on such devices, and blk_dev_change_media_cb() is instead
called by blockdev-{insert,remove}-medium (for tray-less devices only).
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-stable <qemu-stable@nongnu.org>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
blockdev.c | 31 +++++++++++++++++++++++++++++--
qapi/block-core.json | 3 +--
2 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 07cfe25..1044a6a 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2304,6 +2304,11 @@ void qmp_blockdev_open_tray(const char *device, bool has_force, bool force,
return;
}
+ if (!blk_dev_has_tray(blk)) {
+ /* Ignore this command on tray-less devices */
+ return;
+ }
+
if (blk_dev_is_tray_open(blk)) {
return;
}
@@ -2334,6 +2339,11 @@ void qmp_blockdev_close_tray(const char *device, Error **errp)
return;
}
+ if (!blk_dev_has_tray(blk)) {
+ /* Ignore this command on tray-less devices */
+ return;
+ }
+
if (!blk_dev_is_tray_open(blk)) {
return;
}
@@ -2363,7 +2373,7 @@ void qmp_x_blockdev_remove_medium(const char *device, Error **errp)
return;
}
- if (has_device && !blk_dev_is_tray_open(blk)) {
+ if (has_device && blk_dev_has_tray(blk) && !blk_dev_is_tray_open(blk)) {
error_setg(errp, "Tray of device '%s' is not open", device);
return;
}
@@ -2388,6 +2398,14 @@ void qmp_x_blockdev_remove_medium(const char *device, Error **errp)
blk_remove_bs(blk);
+ if (!blk_dev_has_tray(blk)) {
+ /* For tray-less devices, blockdev-open-tray is a no-op (or may not be
+ * called at all); therefore, the medium needs to be ejected here.
+ * Do it after blk_remove_bs() so blk_is_inserted(blk) returns the @load
+ * value passed here (i.e. false). */
+ blk_dev_change_media_cb(blk, false);
+ }
+
out:
aio_context_release(aio_context);
}
@@ -2413,7 +2431,7 @@ static void qmp_blockdev_insert_anon_medium(const char *device,
return;
}
- if (has_device && !blk_dev_is_tray_open(blk)) {
+ if (has_device && blk_dev_has_tray(blk) && !blk_dev_is_tray_open(blk)) {
error_setg(errp, "Tray of device '%s' is not open", device);
return;
}
@@ -2426,6 +2444,15 @@ static void qmp_blockdev_insert_anon_medium(const char *device,
blk_insert_bs(blk, bs);
QTAILQ_INSERT_TAIL(&bdrv_states, bs, device_list);
+
+ if (!blk_dev_has_tray(blk)) {
+ /* For tray-less devices, blockdev-close-tray is a no-op (or may not be
+ * called at all); therefore, the medium needs to be pushed into the
+ * slot here.
+ * Do it after blk_insert_bs() so blk_is_inserted(blk) returns the @load
+ * value passed here (i.e. true). */
+ blk_dev_change_media_cb(blk, true);
+ }
}
void qmp_x_blockdev_insert_medium(const char *device, const char *node_name,
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 0a915ed..40239bf 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -2098,8 +2098,7 @@
# respond to the eject request
# - if the BlockBackend denoted by @device does not have a guest device attached
# to it
-# - if the guest device does not have an actual tray and is empty, for instance
-# for floppy disk drives
+# - if the guest device does not have an actual tray
#
# @device: block device name
#
--
1.8.3.1
next prev parent reply other threads:[~2016-01-29 17:38 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-29 17:37 [Qemu-devel] [PULL 00/48] Block patches Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 01/48] block: Add blk_dev_has_tray() Kevin Wolf
2016-01-29 17:37 ` Kevin Wolf [this message]
2016-01-29 17:37 ` [Qemu-devel] [PULL 03/48] Revert "hw/block/fdc: Implement tray status" Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 04/48] block/qapi: Emit tray_open only if there is a tray Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 05/48] vmdk: Fix converting to streamOptimized Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 06/48] iotests: Limit supported formats for 118 Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 07/48] nbd: client_close on error in nbd_co_client_start Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 08/48] iotests: Rename filter_nbd to _filter_nbd in 083 Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 09/48] iotests: Change coding style of " Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 10/48] iotests: Move _filter_nbd into common.filter Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 11/48] iotests: Make _filter_nbd drop log lines Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 12/48] iotests: Make _filter_nbd support more URL types Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 13/48] iotests: Make redirecting qemu's stderr optional Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 14/48] iotests: Add test for a nonexistent NBD export Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 15/48] block: Remove unused struct definition BlockFinishData Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 16/48] block: Release named dirty bitmaps in bdrv_close() Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 17/48] iotests: Add test for eject under NBD server Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 18/48] block: Add BB-BDS remove/insert notifiers Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 19/48] virtio-blk: Functions for op blocker management Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 20/48] virtio-scsi: Catch BDS-BB removal/insertion Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 21/48] nbd: Switch from close to eject notifier Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 22/48] block: Remove BDS close notifier Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 23/48] block: Use blk_remove_bs() in blk_delete() Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 24/48] blockdev: Use blk_remove_bs() in do_drive_del() Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 25/48] block: Make bdrv_close() static Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 26/48] block: Add list of all BlockDriverStates Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 27/48] blockdev: Keep track of monitor-owned BDS Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 28/48] block: Add blk_remove_all_bs() Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 29/48] block: Rewrite bdrv_close_all() Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 30/48] iotests: Add test for multiple BB on BDS tree Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 31/48] iotests: Add test for block jobs and BDS ejection Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 32/48] block: acquire in bdrv_query_image_info Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 33/48] block: Add "file" output parameter to block status query functions Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 34/48] qcow: Assign bs->file->bs to file in qcow_co_get_block_status Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 35/48] qcow2: Assign bs->file->bs to file in qcow2_co_get_block_status Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 36/48] raw: Assign bs to file in raw_co_get_block_status Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 37/48] iscsi: Assign bs to file in iscsi_co_get_block_status Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 38/48] parallels: Assign bs->file->bs to file in parallels_co_get_block_status Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 39/48] qed: Assign bs->file->bs to file in bdrv_qed_co_get_block_status Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 40/48] sheepdog: Assign bs to file in sd_co_get_block_status Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 41/48] vdi: Assign bs->file->bs to file in vdi_co_get_block_status Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 42/48] vpc: Assign bs->file->bs to file in vpc_co_get_block_status Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 43/48] vmdk: Fix calculation of block status's offset Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 44/48] vmdk: Return extent's file in bdrv_get_block_status Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 45/48] block: Use returned *file in bdrv_co_get_block_status Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 46/48] qemu-img: In "map", use the returned "file" from bdrv_get_block_status Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 47/48] qemu-img: Make MapEntry a QAPI struct Kevin Wolf
2016-01-29 17:37 ` [Qemu-devel] [PULL 48/48] iotests: Add "qemu-img map" test for VMDK extents Kevin Wolf
2016-01-29 17:59 ` [Qemu-devel] [PULL 00/48] Block patches Peter Maydell
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=1454089074-4819-3-git-send-email-kwolf@redhat.com \
--to=kwolf@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).