qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Anthony Liguori <aliguori@us.ibm.com>,
	qemu-devel@nongnu.org, Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 1/5] SCSI: Add disk reset handler
Date: Mon, 10 May 2010 15:19:46 -0500	[thread overview]
Message-ID: <4BE86A62.8090809@codemonkey.ws> (raw)
In-Reply-To: <b5a88f5396e341030153722f93795dd5786386c1.1272975660.git.jan.kiszka@siemens.com>

On 05/04/2010 07:20 AM, Jan Kiszka wrote:
> Ensure that pending requests of an SCSI disk are purged on system reset
> and also restore max_lba. The latter is no only present in the reset
> handler as that one is called after init as well.
>
> Signed-off-by: Jan Kiszka<jan.kiszka@siemens.com>
>    

Applied all (including v2 of 5/5).  Thanks.

Regards,

Anthony Liguori

> ---
>   hw/scsi-disk.c |   35 +++++++++++++++++++++++++++--------
>   1 files changed, 27 insertions(+), 8 deletions(-)
>
> diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
> index 77cb1da..b8d805f 100644
> --- a/hw/scsi-disk.c
> +++ b/hw/scsi-disk.c
> @@ -1010,22 +1010,45 @@ static int32_t scsi_send_command(SCSIDevice *d, uint32_t tag,
>       }
>   }
>
> -static void scsi_destroy(SCSIDevice *dev)
> +static void scsi_disk_purge_requests(SCSIDiskState *s)
>   {
> -    SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);
>       SCSIDiskReq *r;
>
>       while (!QTAILQ_EMPTY(&s->qdev.requests)) {
>           r = DO_UPCAST(SCSIDiskReq, req, QTAILQ_FIRST(&s->qdev.requests));
> +        if (r->req.aiocb) {
> +            bdrv_aio_cancel(r->req.aiocb);
> +        }
>           scsi_remove_request(r);
>       }
> +}
> +
> +static void scsi_disk_reset(DeviceState *dev)
> +{
> +    SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev.qdev, dev);
> +    uint64_t nb_sectors;
> +
> +    scsi_disk_purge_requests(s);
> +
> +    bdrv_get_geometry(s->bs,&nb_sectors);
> +    nb_sectors /= s->cluster_size;
> +    if (nb_sectors) {
> +        nb_sectors--;
> +    }
> +    s->max_lba = nb_sectors;
> +}
> +
> +static void scsi_destroy(SCSIDevice *dev)
> +{
> +    SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);
> +
> +    scsi_disk_purge_requests(s);
>       drive_uninit(s->qdev.conf.dinfo);
>   }
>
>   static int scsi_disk_initfn(SCSIDevice *dev)
>   {
>       SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev);
> -    uint64_t nb_sectors;
>
>       if (!s->qdev.conf.dinfo || !s->qdev.conf.dinfo->bdrv) {
>           error_report("scsi-disk: drive property not set");
> @@ -1046,11 +1069,6 @@ static int scsi_disk_initfn(SCSIDevice *dev)
>       s->cluster_size = s->qdev.blocksize / 512;
>
>       s->qdev.type = TYPE_DISK;
> -    bdrv_get_geometry(s->bs,&nb_sectors);
> -    nb_sectors /= s->cluster_size;
> -    if (nb_sectors)
> -        nb_sectors--;
> -    s->max_lba = nb_sectors;
>       qemu_add_vm_change_state_handler(scsi_dma_restart_cb, s);
>       return 0;
>   }
> @@ -1059,6 +1077,7 @@ static SCSIDeviceInfo scsi_disk_info = {
>       .qdev.name    = "scsi-disk",
>       .qdev.desc    = "virtual scsi disk or cdrom",
>       .qdev.size    = sizeof(SCSIDiskState),
> +    .qdev.reset   = scsi_disk_reset,
>       .init         = scsi_disk_initfn,
>       .destroy      = scsi_destroy,
>       .send_command = scsi_send_command,
>    

  reply	other threads:[~2010-05-10 20:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-04 12:20 [Qemu-devel] [PATCH 0/5] scsi: More reset and hotplug fixes Jan Kiszka
2010-05-04 12:20 ` [Qemu-devel] [PATCH 1/5] SCSI: Add disk reset handler Jan Kiszka
2010-05-10 20:19   ` Anthony Liguori [this message]
2010-05-04 12:21 ` [Qemu-devel] [PATCH 2/5] scsi-disk: Clear aiocb on read completion Jan Kiszka
2010-05-04 12:21 ` [Qemu-devel] [PATCH 3/5] lsi: Purge message queue on reset Jan Kiszka
2010-05-04 12:21 ` [Qemu-devel] [PATCH 4/5] lsi: Adjust some register reset values Jan Kiszka
2010-05-04 12:21 ` [Qemu-devel] [PATCH 5/5] lsi: Handle removal of selected devices Jan Kiszka
2010-05-05 14:02   ` [Qemu-devel] [PATCH v2 " Jan Kiszka
2010-05-04 13:31 ` [Qemu-devel] Re: [PATCH 0/5] scsi: More reset and hotplug fixes Gerd Hoffmann

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=4BE86A62.8090809@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=aliguori@us.ibm.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kraxel@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 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).