[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-stable] [Qemu-devel] [PATCH] virtio-scsi: fix object check fai
From: |
Andreas Färber |
Subject: |
Re: [Qemu-stable] [Qemu-devel] [PATCH] virtio-scsi: fix object check failure |
Date: |
Wed, 18 Jun 2014 16:23:04 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 |
Am 18.06.2014 14:13, schrieb Ming Lei:
> In case of vhost-scsi, the object type of VirtIODevice isn't
> VirtIOSCSI, so use the cast trick to fix the problem like
> in virtio_scsi_handle_cmd()
>
> Cc: address@hidden
> Cc: Anthony Liguori <address@hidden>
> Cc: "Michael S. Tsirkin" <address@hidden>
> Cc: Paolo Bonzini <address@hidden>
> Signed-off-by: Ming Lei <address@hidden>
> ---
> hw/scsi/virtio-scsi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
> index b0d7517..13700f5 100644
> --- a/hw/scsi/virtio-scsi.c
> +++ b/hw/scsi/virtio-scsi.c
> @@ -538,7 +538,7 @@ static void virtio_scsi_push_event(VirtIOSCSI *s,
> SCSIDevice *dev,
>
> static void virtio_scsi_handle_event(VirtIODevice *vdev, VirtQueue *vq)
> {
> - VirtIOSCSI *s = VIRTIO_SCSI(vdev);
> + VirtIOSCSI *s = (VirtIOSCSI *)vdev;
>
> if (s->events_dropped) {
If s is not of type VirtIOSCSI as you indicate, then you shouldn't be
accessing its fields here either. You're basically disabling the safety
mechanism to avoid just that.
If you see a direct cast used elsewhere, it is most likely for
performance reasons, not for correctness.
Regards,
Andreas
> virtio_scsi_push_event(s, NULL, VIRTIO_SCSI_T_NO_EVENT, 0);
>
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-stable] [Qemu-devel] [PATCH] virtio-scsi: fix object check failure,
Andreas Färber <=