From: "Andreas Färber" <afaerber@suse.de>
To: Ming Lei <ming.lei@canonical.com>, qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
qemu-stable@nongnu.org, Anthony Liguori <aliguori@amazon.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] virtio-scsi: fix object check failure
Date: Wed, 18 Jun 2014 16:23:04 +0200 [thread overview]
Message-ID: <53A1A0C8.9040103@suse.de> (raw)
In-Reply-To: <1403093631-7384-1-git-send-email-ming.lei@canonical.com>
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: qemu-stable@nongnu.org
> Cc: Anthony Liguori <aliguori@amazon.com>
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Signed-off-by: Ming Lei <ming.lei@canonical.com>
> ---
> 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
next prev parent reply other threads:[~2014-06-18 14:23 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-18 12:13 [Qemu-devel] [PATCH] virtio-scsi: fix object check failure Ming Lei
2014-06-18 12:29 ` Paolo Bonzini
2014-06-18 14:18 ` Ming Lei
2014-06-18 15:02 ` Paolo Bonzini
2014-06-18 15:06 ` Paolo Bonzini
2014-06-18 15:11 ` Ming Lei
2014-07-25 23:10 ` Nicholas A. Bellinger
2014-07-26 3:52 ` Ming Lei
2014-06-18 14:23 ` Andreas Färber [this message]
2014-06-18 14:43 ` Ming Lei
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=53A1A0C8.9040103@suse.de \
--to=afaerber@suse.de \
--cc=aliguori@amazon.com \
--cc=ming.lei@canonical.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@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).