virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: thuth@linux.vnet.ibm.com, qemu-devel@nongnu.org,
	virtualization@lists.linux-foundation.org
Subject: Re: [PATCH RFC v6 18/20] virtio: support revision-specific features
Date: Sun, 28 Dec 2014 10:32:06 +0200	[thread overview]
Message-ID: <20141228083206.GA6802@redhat.com> (raw)
In-Reply-To: <1418304322-7546-19-git-send-email-cornelia.huck@de.ibm.com>

On Thu, Dec 11, 2014 at 02:25:20PM +0100, Cornelia Huck wrote:
> Devices may support different sets of feature bits depending on which
> revision they're operating at. Let's give the transport a way to
> re-query the device about its features when the revision has been
> changed.
> 
> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>

So now we have both get_features and get_features_rev, and
it's never clear which revision does host_features refer to.
IMHO that's just too messy.
Let's add get_legacy_features and host_legacy_features instead?


> ---
>  hw/s390x/virtio-ccw.c          |   12 ++++++++++--
>  hw/virtio/virtio-bus.c         |   14 ++++++++++++--
>  include/hw/virtio/virtio-bus.h |    3 +++
>  include/hw/virtio/virtio.h     |    3 +++
>  4 files changed, 28 insertions(+), 4 deletions(-)
> 
> diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
> index a55e851..8b6b2ab 100644
> --- a/hw/s390x/virtio-ccw.c
> +++ b/hw/s390x/virtio-ccw.c
> @@ -699,6 +699,10 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw)
>          }
>          ret = 0;
>          dev->revision = revinfo.revision;
> +        /* Re-evaluate which features the device wants to offer. */
> +        dev->host_features =
> +            virtio_bus_get_vdev_features_rev(&dev->bus, dev->host_features,
> +                                             dev->revision >= 1 ? 1 : 0);
>          break;
>      default:
>          ret = -ENOSYS;
> @@ -712,6 +716,9 @@ static void virtio_sch_disable_cb(SubchDev *sch)
>      VirtioCcwDevice *dev = sch->driver_data;
>  
>      dev->revision = -1;
> +    /* Reset the device's features to legacy. */
> +    dev->host_features =
> +        virtio_bus_get_vdev_features_rev(&dev->bus, dev->host_features, 0);
>  }
>  
>  static int virtio_ccw_device_init(VirtioCcwDevice *dev, VirtIODevice *vdev)
> @@ -853,8 +860,9 @@ static int virtio_ccw_device_init(VirtioCcwDevice *dev, VirtIODevice *vdev)
>      virtio_add_feature(&dev->host_features, VIRTIO_F_NOTIFY_ON_EMPTY);
>      virtio_add_feature(&dev->host_features, VIRTIO_F_BAD_FEATURE);
>  
> -    dev->host_features = virtio_bus_get_vdev_features(&dev->bus,
> -                                                      dev->host_features);
> +    /* All devices start in legacy mode. */
> +    dev->host_features =
> +        virtio_bus_get_vdev_features_rev(&dev->bus, dev->host_features, 0);
>  
>      css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid,
>                            parent->hotplugged, 1);
> diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c
> index 32e3fab..a30826c 100644
> --- a/hw/virtio/virtio-bus.c
> +++ b/hw/virtio/virtio-bus.c
> @@ -97,18 +97,28 @@ size_t virtio_bus_get_vdev_config_len(VirtioBusState *bus)
>  }
>  
>  /* Get the features of the plugged device. */
> -uint64_t virtio_bus_get_vdev_features(VirtioBusState *bus,
> -                                      uint64_t requested_features)
> +uint64_t virtio_bus_get_vdev_features_rev(VirtioBusState *bus,
> +                                          uint64_t requested_features,
> +                                          unsigned int revision)
>  {
>      VirtIODevice *vdev = virtio_bus_get_device(bus);
>      VirtioDeviceClass *k;
>  
>      assert(vdev != NULL);
>      k = VIRTIO_DEVICE_GET_CLASS(vdev);
> +    if (revision > 0 && k->get_features_rev) {
> +        return k->get_features_rev(vdev, requested_features, revision);
> +    }
>      assert(k->get_features != NULL);
>      return k->get_features(vdev, requested_features);
>  }
>  
> +uint64_t virtio_bus_get_vdev_features(VirtioBusState *bus,
> +                                      uint64_t requested_features)
> +{
> +    return virtio_bus_get_vdev_features_rev(bus, requested_features, 0);
> +}
> +
>  /* Get bad features of the plugged device. */
>  uint64_t virtio_bus_get_vdev_bad_features(VirtioBusState *bus)
>  {
> diff --git a/include/hw/virtio/virtio-bus.h b/include/hw/virtio/virtio-bus.h
> index 0a4dde1..f0916ef 100644
> --- a/include/hw/virtio/virtio-bus.h
> +++ b/include/hw/virtio/virtio-bus.h
> @@ -84,6 +84,9 @@ size_t virtio_bus_get_vdev_config_len(VirtioBusState *bus);
>  /* Get the features of the plugged device. */
>  uint64_t virtio_bus_get_vdev_features(VirtioBusState *bus,
>                                        uint64_t requested_features);
> +uint64_t virtio_bus_get_vdev_features_rev(VirtioBusState *bus,
> +                                          uint64_t requested_features,
> +                                          unsigned int revision);
>  /* Get bad features of the plugged device. */
>  uint64_t virtio_bus_get_vdev_bad_features(VirtioBusState *bus);
>  /* Get config of the plugged device. */
> diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
> index 068211e..1338540 100644
> --- a/include/hw/virtio/virtio.h
> +++ b/include/hw/virtio/virtio.h
> @@ -147,6 +147,9 @@ typedef struct VirtioDeviceClass {
>      DeviceRealize realize;
>      DeviceUnrealize unrealize;
>      uint64_t (*get_features)(VirtIODevice *vdev, uint64_t requested_features);
> +    uint64_t (*get_features_rev)(VirtIODevice *vdev,
> +                                 uint64_t requested_features,
> +                                 unsigned int revision);
>      uint64_t (*bad_features)(VirtIODevice *vdev);
>      void (*set_features)(VirtIODevice *vdev, uint64_t val);
>      int (*validate_features)(VirtIODevice *vdev);
> -- 
> 1.7.9.5

  reply	other threads:[~2014-12-28  8:32 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-11 13:25 [PATCH RFC v6 00/20] qemu: towards virtio-1 host support Cornelia Huck
2014-12-11 13:25 ` [PATCH RFC v6 01/20] linux-headers/virtio_config: Update with VIRTIO_F_VERSION_1 Cornelia Huck
2014-12-11 13:25 ` [PATCH RFC v6 02/20] virtio: cull virtio_bus_set_vdev_features Cornelia Huck
2015-01-22  1:24   ` [Qemu-devel] " David Gibson
2014-12-11 13:25 ` [PATCH RFC v6 03/20] virtio: feature bit manipulation helpers Cornelia Huck
2014-12-11 14:29   ` Thomas Huth
2015-01-22  1:25   ` [Qemu-devel] " David Gibson
2014-12-11 13:25 ` [PATCH RFC v6 04/20] virtio: add feature checking helpers Cornelia Huck
2014-12-11 14:46   ` Thomas Huth
     [not found]   ` <20141211154623.4a73fef9@oc7435384737.ibm.com>
2014-12-11 17:05     ` Michael S. Tsirkin
2014-12-12  8:37       ` Cornelia Huck
2014-12-12 10:07     ` Cornelia Huck
2015-01-22  1:28   ` [Qemu-devel] " David Gibson
2014-12-11 13:25 ` [PATCH RFC v6 05/20] virtio: support more feature bits Cornelia Huck
2014-12-12 10:06   ` Thomas Huth
2014-12-12 10:17     ` Cornelia Huck
2015-01-22  1:40       ` [Qemu-devel] " David Gibson
2015-01-22  1:43   ` David Gibson
2015-01-28 15:59     ` Cornelia Huck
2015-01-29  0:11       ` David Gibson
2015-01-29  9:24         ` Thomas Huth
2015-01-29 10:01           ` David Gibson
2015-01-29 10:54             ` Michael S. Tsirkin
2014-12-11 13:25 ` [PATCH RFC v6 06/20] virtio: endianness checks for virtio 1.0 devices Cornelia Huck
2015-01-20 10:29   ` Stefan Hajnoczi
2015-01-22  1:54   ` [Qemu-devel] " David Gibson
     [not found]   ` <20150122015409.GH27371@voom.fritz.box>
2015-01-23 16:09     ` Greg Kurz
2014-12-11 13:25 ` [PATCH RFC v6 07/20] virtio: allow virtio-1 queue layout Cornelia Huck
2015-01-22  2:06   ` [Qemu-devel] " David Gibson
     [not found]   ` <20150122020609.GI27371@voom.fritz.box>
2015-01-28 16:07     ` Cornelia Huck
2015-01-29  0:14       ` David Gibson
2014-12-11 13:25 ` [PATCH RFC v6 08/20] dataplane: allow virtio-1 devices Cornelia Huck
2015-01-20 10:43   ` Stefan Hajnoczi
2015-01-20 12:56     ` Cornelia Huck
2015-01-20 14:47       ` Stefan Hajnoczi
2015-01-22  2:12   ` [Qemu-devel] " David Gibson
2014-12-11 13:25 ` [PATCH RFC v6 09/20] s390x/css: Add a callback for when subchannel gets disabled Cornelia Huck
2015-01-20 10:50   ` Stefan Hajnoczi
2014-12-11 13:25 ` [PATCH RFC v6 10/20] s390x/virtio-ccw: add virtio set-revision call Cornelia Huck
2015-01-20 11:00   ` Stefan Hajnoczi
2015-01-20 11:08   ` Stefan Hajnoczi
2015-01-21 11:23     ` Cornelia Huck
2015-01-21 11:51       ` [Qemu-devel] " Thomas Huth
2015-01-21 12:39         ` Cornelia Huck
2014-12-11 13:25 ` [PATCH RFC v6 11/20] s390x/virtio-ccw: support virtio-1 set_vq format Cornelia Huck
2015-01-20 11:06   ` Stefan Hajnoczi
2014-12-11 13:25 ` [PATCH RFC v6 12/20] virtio: disallow late feature changes for virtio-1 Cornelia Huck
2014-12-12 10:55   ` Thomas Huth
2014-12-12 11:18     ` Cornelia Huck
2014-12-12 11:25       ` Thomas Huth
2015-01-20 11:14         ` Stefan Hajnoczi
2015-01-22  2:15   ` [Qemu-devel] " David Gibson
2014-12-11 13:25 ` [PATCH RFC v6 13/20] virtio: allow to fail setting status Cornelia Huck
2014-12-30 12:25   ` Michael S. Tsirkin
2015-01-07 16:13     ` Cornelia Huck
2015-01-07 19:08       ` Michael S. Tsirkin
2015-01-08  7:20         ` Cornelia Huck
2015-01-08  8:09           ` Michael S. Tsirkin
2014-12-11 13:25 ` [PATCH RFC v6 14/20] s390x/virtio-ccw: enable virtio 1.0 Cornelia Huck
2015-01-20 11:15   ` Stefan Hajnoczi
2014-12-11 13:25 ` [PATCH RFC v6 15/20] virtio-net: no writeable mac for virtio-1 Cornelia Huck
2015-01-20 11:19   ` Stefan Hajnoczi
2015-01-22 16:31     ` Cornelia Huck
2014-12-11 13:25 ` [PATCH RFC v6 16/20] virtio-net: support longer header Cornelia Huck
2015-01-20 13:18   ` Stefan Hajnoczi
2015-01-21 16:06     ` Cornelia Huck
2014-12-11 13:25 ` [PATCH RFC v6 17/20] virtio-net: enable virtio 1.0 Cornelia Huck
2014-12-16 13:10   ` Michael S. Tsirkin
2014-12-18 16:57     ` Cornelia Huck
2014-12-11 13:25 ` [PATCH RFC v6 18/20] virtio: support revision-specific features Cornelia Huck
2014-12-28  8:32   ` Michael S. Tsirkin [this message]
2015-01-07 16:22     ` Cornelia Huck
2015-01-07 19:10       ` Michael S. Tsirkin
2015-01-30 14:08         ` Cornelia Huck
2015-02-01 21:29           ` Michael S. Tsirkin
2015-02-02 14:10             ` Cornelia Huck
2014-12-11 13:25 ` [PATCH RFC v6 19/20] virtio-blk: revision specific feature bits Cornelia Huck
2014-12-28 10:24   ` Michael S. Tsirkin
2015-01-07 16:29     ` Cornelia Huck
     [not found]     ` <20150107172949.11f374bf.cornelia.huck@de.ibm.com>
2015-01-07 19:11       ` Michael S. Tsirkin
2015-01-30 14:10         ` Cornelia Huck
2014-12-11 13:25 ` [PATCH RFC v6 20/20] vhost: 64 bit features Cornelia Huck

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=20141228083206.GA6802@redhat.com \
    --to=mst@redhat.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@linux.vnet.ibm.com \
    --cc=virtualization@lists.linux-foundation.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).