From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WxI1A-0003iO-1J for qemu-devel@nongnu.org; Wed, 18 Jun 2014 11:43:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WxI14-00067D-Sh for qemu-devel@nongnu.org; Wed, 18 Jun 2014 11:43:19 -0400 Date: Wed, 18 Jun 2014 18:43:35 +0300 From: "Michael S. Tsirkin" Message-ID: <20140618154335.GA25619@redhat.com> References: <1403105553-5478-1-git-send-email-ming.lei@canonical.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1403105553-5478-1-git-send-email-ming.lei@canonical.com> Subject: Re: [Qemu-devel] [PATCH v1] virtio-scsi: fix object check failure List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ming Lei Cc: Peter Maydell , qemu-stable@nongnu.org, qemu-devel@nongnu.org, Anthony Liguori , Paolo Bonzini On Wed, Jun 18, 2014 at 11:32:33PM +0800, Ming Lei wrote: > 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(). > > Also 'events_dropped' need to be accessed in the path, in which path? > so > move it into VirtIOSCSICommon. > > 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 | 14 ++++++++------ > include/hw/virtio/virtio-scsi.h | 3 ++- > 2 files changed, 10 insertions(+), 7 deletions(-) > > diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c > index b0d7517..081c226 100644 > --- a/hw/scsi/virtio-scsi.c > +++ b/hw/scsi/virtio-scsi.c > @@ -461,7 +461,7 @@ static void virtio_scsi_reset(VirtIODevice *vdev) > > vs->sense_size = VIRTIO_SCSI_SENSE_SIZE; > vs->cdb_size = VIRTIO_SCSI_CDB_SIZE; > - s->events_dropped = false; > + vs->events_dropped = false; > } > > /* The device does not have anything to save beyond the virtio data. > @@ -499,7 +499,7 @@ static void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev, > } > > if (!req) { > - s->events_dropped = true; > + vs->events_dropped = true; > return; > } > > @@ -507,9 +507,9 @@ static void virtio_scsi_push_event(VirtIOSCSI *s, SCSIDevice *dev, > virtio_scsi_bad_req(); > } > > - if (s->events_dropped) { > + if (vs->events_dropped) { > event |= VIRTIO_SCSI_T_EVENTS_MISSED; > - s->events_dropped = false; > + vs->events_dropped = false; > } > > in_size = req->elem.in_sg[0].iov_len; > @@ -538,9 +538,11 @@ 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); > + /* use non-QOM casts in the data path */ > + VirtIOSCSI *s = (VirtIOSCSI *)vdev; > + VirtIOSCSICommon *vs = &s->parent_obj; > > - if (s->events_dropped) { > + if (vs->events_dropped) { > virtio_scsi_push_event(s, NULL, VIRTIO_SCSI_T_NO_EVENT, 0); > } > } > diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scsi.h > index 367afc6..e60a44a 100644 > --- a/include/hw/virtio/virtio-scsi.h > +++ b/include/hw/virtio/virtio-scsi.h > @@ -164,6 +164,8 @@ typedef struct VirtIOSCSICommon { > VirtQueue *ctrl_vq; > VirtQueue *event_vq; > VirtQueue **cmd_vqs; > + > + bool events_dropped; > } VirtIOSCSICommon; > > typedef struct { > @@ -171,7 +173,6 @@ typedef struct { > > SCSIBus bus; > int resetting; > - bool events_dropped; > } VirtIOSCSI; > > #define DEFINE_VIRTIO_SCSI_PROPERTIES(_state, _conf_field) \ > -- > 1.7.9.5