qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] virtio-scsi: fix object check failure


From: Ming Lei
Subject: Re: [Qemu-devel] [PATCH] virtio-scsi: fix object check failure
Date: Wed, 18 Jun 2014 22:43:39 +0800

On Wed, Jun 18, 2014 at 10:23 PM, Andreas Färber <address@hidden> wrote:
> 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.

Yes, you are right, and the correct approach should let VirtIOSCSI
as parent of VHostSCSI, so how about attached patch?

>
> If you see a direct cast used elsewhere, it is most likely for
> performance reasons, not for correctness.

The other two places aren't for performance reason, and it is
designed as so.


Thanks,
--
Ming Lei

Attachment: 0001-virtio-scsi-fix-object-check-failure.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]