[PATCH RFC v6 04/20] virtio: add feature checking helpers

Cornelia Huck
2014-12-12T08:37:36Z

On Thu, 11 Dec 2014 19:05:26 +0200
"Michael S. Tsirkin" <mst at redhat.com> wrote:

> On Thu, Dec 11, 2014 at 03:46:23PM +0100, Thomas Huth wrote:
> > On Thu, 11 Dec 2014 14:25:06 +0100
> > Cornelia Huck <cornelia.huck at de.ibm.com> wrote:
> >
> > > Add a helper function for checking whether a bit is set in the
guest
> > > features for a vdev as well as one that works on a feature bit
set.
> > >
> > > Convert code that open-coded this: It cleans up the code and
makes it
> > > easier to extend the guest feature bits.
> > >
> > > Signed-off-by: Cornelia Huck <cornelia.huck at de.ibm.com>
> > ...
> > > diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
> > > index ef48550..56c92fb 100644
> > > --- a/hw/scsi/virtio-scsi.c
> > > +++ b/hw/scsi/virtio-scsi.c
> > > @@ -144,7 +144,7 @@ static int
virtio_scsi_parse_req(VirtIOSCSIReq *req,
> > >       *
> > >       * TODO: always disable this workaround for virtio 1.0
devices.
> > >       */
> > > -    if ((vdev->guest_features & VIRTIO_F_ANY_LAYOUT) ==
0) {
> > > +    if (!virtio_has_feature(vdev, VIRTIO_F_ANY_LAYOUT)) {
> >
> > Wait ... this does not only look like a clean-up, but also like a
> > bug-fix to me, since it should have been "(1 <<
VIRTIO_F_ANY_LAYOUT)"
> > instead of "VIRTIO_F_ANY_LAYOUT" in the original code
instead?

I've clearly been looking at this stuff for too long, as I didn't even
notice this bug :)

> >
> > So in case this patch queue takes a little bit longer 'til it gets
> > upstream, do we might want to submit a separate patch for fixing this
> > issue first?
>
> Yes, please do.

OK, will send.