From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40094) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1biPAR-0007sx-QV for qemu-devel@nongnu.org; Fri, 09 Sep 2016 13:00:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1biPAN-0006eF-GX for qemu-devel@nongnu.org; Fri, 09 Sep 2016 13:00:42 -0400 References: <1473426607-10516-1-git-send-email-maxime.coquelin@redhat.com> <1473426607-10516-2-git-send-email-maxime.coquelin@redhat.com> From: Marcel Apfelbaum Message-ID: <9c7c648b-17f7-0273-2066-fd39f4ddf67b@redhat.com> Date: Fri, 9 Sep 2016 20:00:31 +0300 MIME-Version: 1.0 In-Reply-To: <1473426607-10516-2-git-send-email-maxime.coquelin@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 1/2] virtio: Add function to check whether backend supports VIRTIO_1 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Maxime Coquelin , mst@redhat.com, qemu-devel@nongnu.org, cornelia.huck@de.ibm.com Cc: vkaplans@redhat.com, qemu-stable@nongnu.org On 09/09/2016 04:10 PM, Maxime Coquelin wrote: > This patch adds virtio_test_backend_virtio_1() function to > check whether backend supports VIRTIO_F_VERSION_1 before the > negociation takes place. > > Cc: Cornelia Huck > Cc: Marcel Apfelbaum > Cc: Michael S. Tsirkin > Cc: qemu-stable@nongnu.org > Signed-off-by: Maxime Coquelin > --- > hw/virtio/virtio.c | 13 +++++++++++++ > include/hw/virtio/virtio.h | 1 + > 2 files changed, 14 insertions(+) > > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c > index 74c085c..8b30b69 100644 > --- a/hw/virtio/virtio.c > +++ b/hw/virtio/virtio.c > @@ -1481,6 +1481,19 @@ void virtio_vmstate_save(QEMUFile *f, void *opaque, size_t size) > virtio_save(VIRTIO_DEVICE(opaque), f); > } > > +bool virtio_test_backend_virtio_1(VirtIODevice *vdev, Error **errp) > +{ > + VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev); > + uint64_t feature; > + I would set "feature = 0" even if doesn't really matter. Anyway: Reviewed-by: Marcel Apfelbaum Thanks, Marcel > + virtio_add_feature(&feature, VIRTIO_F_VERSION_1); > + > + assert(k->get_features != NULL); > + feature = k->get_features(vdev, feature, errp); > + > + return virtio_has_feature(feature, VIRTIO_F_VERSION_1); > +} > + > static int virtio_set_features_nocheck(VirtIODevice *vdev, uint64_t val) > { > VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev); > diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h > index d2490c1..3a31754 100644 > --- a/include/hw/virtio/virtio.h > +++ b/include/hw/virtio/virtio.h > @@ -235,6 +235,7 @@ int virtio_set_status(VirtIODevice *vdev, uint8_t val); > void virtio_reset(void *opaque); > void virtio_update_irq(VirtIODevice *vdev); > int virtio_set_features(VirtIODevice *vdev, uint64_t val); > +bool virtio_test_backend_virtio_1(VirtIODevice *vdev, Error **errp); > > /* Base devices. */ > typedef struct VirtIOBlkConf VirtIOBlkConf; >