From: Kevin Wolf <kwolf@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: Re: [Qemu-devel] [PATCH 2/5] scsi-disk: report resized disk via sense codes
Date: Tue, 17 Jul 2012 13:14:12 +0200 [thread overview]
Message-ID: <50054904.4040301@redhat.com> (raw)
In-Reply-To: <1342448756-7582-3-git-send-email-pbonzini@redhat.com>
Am 16.07.2012 16:25, schrieb Paolo Bonzini:
> Linux will not use these, but a very similar mechanism will be used to
> report the condition via virtio-scsi events.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> hw/scsi-bus.c | 5 +++++
> hw/scsi-disk.c | 15 +++++++++++----
> hw/scsi.h | 2 ++
> 3 files changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c
> index 8b961f2..2547c50 100644
> --- a/hw/scsi-bus.c
> +++ b/hw/scsi-bus.c
> @@ -1161,6 +1161,11 @@ const struct SCSISense sense_code_LUN_FAILURE = {
> .key = ABORTED_COMMAND, .asc = 0x3e, .ascq = 0x01
> };
>
> +/* Unit attention, Capacity data has changed */
> +const struct SCSISense sense_code_CAPACITY_CHANGED = {
> + .key = UNIT_ATTENTION, .asc = 0x2a, .ascq = 0x09
> +};
> +
> /* Unit attention, Power on, reset or bus device reset occurred */
> const struct SCSISense sense_code_RESET = {
> .key = UNIT_ATTENTION, .asc = 0x29, .ascq = 0x00
> diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
> index 42bae3b..0905446 100644
> --- a/hw/scsi-disk.c
> +++ b/hw/scsi-disk.c
> @@ -1863,6 +1863,13 @@ static void scsi_destroy(SCSIDevice *dev)
> blockdev_mark_auto_del(s->qdev.conf.bs);
> }
>
> +static void scsi_disk_resize_cb(void *opaque)
> +{
> + SCSIDiskState *s = opaque;
> +
> + scsi_device_set_ua(&s->qdev, SENSE_CODE(CAPACITY_CHANGED));
> +}
> +
> static void scsi_cd_change_media_cb(void *opaque, bool load)
> {
> SCSIDiskState *s = opaque;
> @@ -1904,11 +1911,13 @@ static bool scsi_cd_is_medium_locked(void *opaque)
> return ((SCSIDiskState *)opaque)->tray_locked;
> }
>
> -static const BlockDevOps scsi_cd_block_ops = {
> +static const BlockDevOps scsi_disk_block_ops = {
> .change_media_cb = scsi_cd_change_media_cb,
> .eject_request_cb = scsi_cd_eject_request_cb,
> .is_tray_open = scsi_cd_is_tray_open,
> .is_medium_locked = scsi_cd_is_medium_locked,
> +
> + .resize_cb = scsi_disk_resize_cb,
> };
>
> static void scsi_disk_unit_attention_reported(SCSIDevice *dev)
> @@ -1956,9 +1965,7 @@ static int scsi_initfn(SCSIDevice *dev)
> return -1;
> }
>
> - if (s->features & (1 << SCSI_DISK_F_REMOVABLE)) {
> - bdrv_set_dev_ops(s->qdev.conf.bs, &scsi_cd_block_ops, s);
> - }
> + bdrv_set_dev_ops(s->qdev.conf.bs, &scsi_disk_block_ops, s);
Are you aware of this code?
bool bdrv_dev_has_removable_media(BlockDriverState *bs)
{
return !bs->dev || (bs->dev_ops && bs->dev_ops->change_media_cb);
}
This means that now all SCSI disks have removable media from the
monitor's point of view.
Kevin
next prev parent reply other threads:[~2012-07-17 11:14 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-16 14:25 [PATCH 0/5] virtio-scsi: support block_resize Paolo Bonzini
2012-07-16 14:25 ` [Qemu-devel] " Paolo Bonzini
2012-07-16 14:25 ` [PATCH 1/5] scsi-disk: removable hard disks support START/STOP Paolo Bonzini
2012-07-16 14:25 ` [Qemu-devel] " Paolo Bonzini
2012-07-23 16:44 ` Blue Swirl
2012-07-23 16:50 ` Paolo Bonzini
2012-07-16 14:25 ` [PATCH 2/5] scsi-disk: report resized disk via sense codes Paolo Bonzini
2012-07-16 14:25 ` [Qemu-devel] " Paolo Bonzini
2012-07-17 11:14 ` Kevin Wolf [this message]
2012-07-17 11:15 ` Paolo Bonzini
2012-07-16 14:25 ` [PATCH 3/5] scsi: establish precedence levels for unit attention Paolo Bonzini
2012-07-16 14:25 ` [Qemu-devel] " Paolo Bonzini
2012-07-16 14:25 ` [PATCH 4/5] scsi: report parameter changes to HBA drivers Paolo Bonzini
2012-07-16 14:25 ` [Qemu-devel] " Paolo Bonzini
2012-07-16 14:25 ` [PATCH 5/5] virtio-scsi: report parameter change events Paolo Bonzini
2012-07-16 14:25 ` [Qemu-devel] " 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=50054904.4040301@redhat.com \
--to=kwolf@redhat.com \
--cc=kvm@vger.kernel.org \
--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.