From: Kevin Wolf <kwolf@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 6/8] block: add eject request callback
Date: Fri, 28 Oct 2011 19:21:36 +0200 [thread overview]
Message-ID: <4EAAE4A0.7090507@redhat.com> (raw)
In-Reply-To: <1319540020-32484-7-git-send-email-pbonzini@redhat.com>
Am 25.10.2011 12:53, schrieb Paolo Bonzini:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> block.c | 7 +++++++
> block.h | 7 +++++++
> blockdev.c | 8 +++++---
> 3 files changed, 19 insertions(+), 3 deletions(-)
>
> diff --git a/block.c b/block.c
> index 9873b57..53e21ba 100644
> --- a/block.c
> +++ b/block.c
> @@ -821,6 +821,13 @@ bool bdrv_dev_has_removable_media(BlockDriverState *bs)
> return !bs->dev || (bs->dev_ops && bs->dev_ops->change_media_cb);
> }
>
> +void bdrv_dev_eject_request(BlockDriverState *bs, bool force)
> +{
> + if (bs->dev_ops && bs->dev_ops->eject_request_cb) {
> + bs->dev_ops->eject_request_cb(bs->dev_opaque, force);
> + }
> +}
> +
> bool bdrv_dev_is_tray_open(BlockDriverState *bs)
> {
> if (bs->dev_ops && bs->dev_ops->is_tray_open) {
> diff --git a/block.h b/block.h
> index e77988e..d3c3d62 100644
> --- a/block.h
> +++ b/block.h
> @@ -39,6 +39,12 @@ typedef struct BlockDevOps {
> */
> void (*change_media_cb)(void *opaque, bool load);
> /*
> + * Runs when an eject request is issued from the monitor, the tray
> + * is closed, and the medium is locked.
> + * Device models with removable media must implement this callback.
> + */
> + void (*eject_request_cb)(void *opaque, bool force);
> + /*
> * Is the virtual tray open?
> * Device models implement this only when the device has a tray.
> */
> @@ -116,6 +122,7 @@ void bdrv_detach_dev(BlockDriverState *bs, void *dev);
> void *bdrv_get_attached_dev(BlockDriverState *bs);
> void bdrv_set_dev_ops(BlockDriverState *bs, const BlockDevOps *ops,
> void *opaque);
> +void bdrv_dev_eject_request(BlockDriverState *bs, bool force);
> bool bdrv_dev_has_removable_media(BlockDriverState *bs);
> bool bdrv_dev_is_tray_open(BlockDriverState *bs);
> bool bdrv_dev_is_medium_locked(BlockDriverState *bs);
> diff --git a/blockdev.c b/blockdev.c
> index 0827bf7..4cf333a 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -635,9 +635,11 @@ static int eject_device(Monitor *mon, BlockDriverState *bs, int force)
> qerror_report(QERR_DEVICE_NOT_REMOVABLE, bdrv_get_device_name(bs));
> return -1;
> }
> - if (!force && !bdrv_dev_is_tray_open(bs)
> - && bdrv_dev_is_medium_locked(bs)) {
> - qerror_report(QERR_DEVICE_LOCKED, bdrv_get_device_name(bs));
> + if (bdrv_dev_is_medium_locked(bs) && !bdrv_dev_is_tray_open(bs)) {
> + bdrv_dev_eject_request(bs, force);
> + if (!force) {
> + qerror_report(QERR_DEVICE_LOCKED, bdrv_get_device_name(bs));
> + }
> return -1;
> }
> bdrv_close(bs);
Now force doesn't force any more. It avoids the error message, but
doesn't forcefully close the BlockDriverState any more. Intentional? If
so, why is it a good idea?
Kevin
next prev parent reply other threads:[~2011-10-28 17:18 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-25 10:53 [Qemu-devel] [PATCH 0/5] My remaining block/SCSI patches for 1.0 Paolo Bonzini
2011-10-25 10:53 ` [Qemu-devel] [PATCH 1/8] scsi: do not call transfer_data after canceling a request Paolo Bonzini
2011-10-25 10:53 ` [Qemu-devel] [PATCH 2/8] scsi-disk: bump SCSIRequest reference count until aio completion runs Paolo Bonzini
2011-10-25 10:53 ` [Qemu-devel] [PATCH 3/8] scsi-generic: " Paolo Bonzini
2011-10-25 10:53 ` [Qemu-devel] [PATCH 4/8] scsi: push request restart to SCSIDevice Paolo Bonzini
2011-10-25 10:53 ` [Qemu-devel] [PATCH 5/8] scsi-disk: add scsi-block for device passthrough Paolo Bonzini
2011-10-28 17:04 ` Kevin Wolf
2011-10-25 10:53 ` [Qemu-devel] [PATCH 6/8] block: add eject request callback Paolo Bonzini
2011-10-28 17:21 ` Kevin Wolf [this message]
2011-10-29 7:46 ` Paolo Bonzini
2011-11-07 13:21 ` Markus Armbruster
2011-11-07 13:36 ` Paolo Bonzini
2011-11-07 13:49 ` Kevin Wolf
2011-11-07 13:56 ` Paolo Bonzini
2011-11-07 14:12 ` Kevin Wolf
2011-11-07 15:23 ` Markus Armbruster
2011-11-07 16:14 ` Paolo Bonzini
2011-11-07 16:50 ` [Qemu-devel] [PATCH 6/8 v2] " Paolo Bonzini
2011-11-08 13:18 ` Kevin Wolf
2011-10-25 10:53 ` [Qemu-devel] [PATCH 7/8] atapi: implement eject requests Paolo Bonzini
2011-10-25 10:53 ` [Qemu-devel] [PATCH 8/8] scsi-disk: " Paolo Bonzini
2011-10-27 11:45 ` [Qemu-devel] ping Re: [PATCH 0/5] My remaining block/SCSI patches for 1.0 Paolo Bonzini
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=4EAAE4A0.7090507@redhat.com \
--to=kwolf@redhat.com \
--cc=armbru@redhat.com \
--cc=pbonzini@redhat.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.