Message ID | 1473426607-10516-2-git-send-email-maxime.coquelin@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
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 <cornelia.huck@de.ibm.com> > Cc: Marcel Apfelbaum <marcel@redhat.com> > Cc: Michael S. Tsirkin <mst@redhat.com> > Cc: qemu-stable@nongnu.org > Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com> > --- > 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 <marcel@redhat.com> 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; >
On Fri, Sep 09, 2016 at 08:00:31PM +0300, Marcel Apfelbaum wrote: > 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 <cornelia.huck@de.ibm.com> > > Cc: Marcel Apfelbaum <marcel@redhat.com> > > Cc: Michael S. Tsirkin <mst@redhat.com> > > Cc: qemu-stable@nongnu.org > > Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com> > > --- > > 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 <marcel@redhat.com> > > Thanks, > Marcel why wouldn't it matter? Looks like an uninitialized variable to me. > > + 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; > >
On 09/09/2016 07:47 PM, Michael S. Tsirkin wrote: > On Fri, Sep 09, 2016 at 08:00:31PM +0300, Marcel Apfelbaum wrote: >> 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 <cornelia.huck@de.ibm.com> >>> Cc: Marcel Apfelbaum <marcel@redhat.com> >>> Cc: Michael S. Tsirkin <mst@redhat.com> >>> Cc: qemu-stable@nongnu.org >>> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com> >>> --- >>> 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 <marcel@redhat.com> >> >> Thanks, >> Marcel > > why wouldn't it matter? Looks like an uninitialized variable to me. Oh yes, you are right, it should be initialized. Just wait confirmation from Michael on the RFC before sending a v3. Thanks, Maxime > >>> + 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; >>>
On 09/09/2016 08:47 PM, Michael S. Tsirkin wrote: > On Fri, Sep 09, 2016 at 08:00:31PM +0300, Marcel Apfelbaum wrote: >> 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 <cornelia.huck@de.ibm.com> >>> Cc: Marcel Apfelbaum <marcel@redhat.com> >>> Cc: Michael S. Tsirkin <mst@redhat.com> >>> Cc: qemu-stable@nongnu.org >>> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com> >>> --- >>> 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 <marcel@redhat.com> >> >> Thanks, >> Marcel > > why wouldn't it matter? Looks like an uninitialized variable to me. because it adds a flag, then it checks only if this specific flag is negotiated, but uninitialized variables are never a good idea. 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; >>>
On Fri, 9 Sep 2016 15:10:06 +0200 Maxime Coquelin <maxime.coquelin@redhat.com> wrote: > This patch adds virtio_test_backend_virtio_1() function to > check whether backend supports VIRTIO_F_VERSION_1 before the > negociation takes place. s/negociation/negotiation/ > > Cc: Cornelia Huck <cornelia.huck@de.ibm.com> > Cc: Marcel Apfelbaum <marcel@redhat.com> > Cc: Michael S. Tsirkin <mst@redhat.com> > Cc: qemu-stable@nongnu.org > Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com> > --- > 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; As others had requested, I'd prefer setting this to 0 as well. With that changed: Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
On 09/12/2016 02:28 PM, Cornelia Huck wrote: > On Fri, 9 Sep 2016 15:10:06 +0200 > Maxime Coquelin <maxime.coquelin@redhat.com> wrote: > >> This patch adds virtio_test_backend_virtio_1() function to >> check whether backend supports VIRTIO_F_VERSION_1 before the >> negociation takes place. > > s/negociation/negotiation/ > >> >> Cc: Cornelia Huck <cornelia.huck@de.ibm.com> >> Cc: Marcel Apfelbaum <marcel@redhat.com> >> Cc: Michael S. Tsirkin <mst@redhat.com> >> Cc: qemu-stable@nongnu.org >> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com> >> --- >> 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; > > As others had requested, I'd prefer setting this to 0 as well. > > With that changed: > > Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Thanks Cornelia, Note that if everyone agree to have patch adding pre_plugged, this series will not be needed anymore. Regards, Maxime
On Mon, Sep 12, 2016 at 06:42:46PM +0200, Maxime Coquelin wrote: > > > On 09/12/2016 02:28 PM, Cornelia Huck wrote: > > On Fri, 9 Sep 2016 15:10:06 +0200 > > Maxime Coquelin <maxime.coquelin@redhat.com> wrote: > > > > > This patch adds virtio_test_backend_virtio_1() function to > > > check whether backend supports VIRTIO_F_VERSION_1 before the > > > negociation takes place. > > > > s/negociation/negotiation/ > > > > > > > > Cc: Cornelia Huck <cornelia.huck@de.ibm.com> > > > Cc: Marcel Apfelbaum <marcel@redhat.com> > > > Cc: Michael S. Tsirkin <mst@redhat.com> > > > Cc: qemu-stable@nongnu.org > > > Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com> > > > --- > > > 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; > > > > As others had requested, I'd prefer setting this to 0 as well. > > > > With that changed: > > > > Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> > Thanks Cornelia, > Note that if everyone agree to have patch adding pre_plugged, > this series will not be needed anymore. > > Regards, > Maxime Yes - that one needs testing for ccw and mmio.
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; + + 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;
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 <cornelia.huck@de.ibm.com> Cc: Marcel Apfelbaum <marcel@redhat.com> Cc: Michael S. Tsirkin <mst@redhat.com> Cc: qemu-stable@nongnu.org Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com> --- hw/virtio/virtio.c | 13 +++++++++++++ include/hw/virtio/virtio.h | 1 + 2 files changed, 14 insertions(+)