From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48236) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxGld-00014U-4u for qemu-devel@nongnu.org; Wed, 18 Jun 2014 10:23:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WxGlW-0008L1-ME for qemu-devel@nongnu.org; Wed, 18 Jun 2014 10:23:13 -0400 Message-ID: <53A1A0C8.9040103@suse.de> Date: Wed, 18 Jun 2014 16:23:04 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1403093631-7384-1-git-send-email-ming.lei@canonical.com> In-Reply-To: <1403093631-7384-1-git-send-email-ming.lei@canonical.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] virtio-scsi: fix object check failure List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ming Lei , qemu-devel@nongnu.org Cc: Peter Maydell , "Michael S. Tsirkin" , qemu-stable@nongnu.org, Anthony Liguori , Paolo Bonzini 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() >=20 > Cc: qemu-stable@nongnu.org > Cc: Anthony Liguori > Cc: "Michael S. Tsirkin" > Cc: Paolo Bonzini > Signed-off-by: Ming Lei > --- > hw/scsi/virtio-scsi.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > 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, S= CSIDevice *dev, > =20 > static void virtio_scsi_handle_event(VirtIODevice *vdev, VirtQueue *vq= ) > { > - VirtIOSCSI *s =3D VIRTIO_SCSI(vdev); > + VirtIOSCSI *s =3D (VirtIOSCSI *)vdev; > =20 > 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); >=20 --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg