qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: amit.shah@redhat.com, uobergfe@redhat.com, owasserm@redhat.com,
	qemu-devel@nongnu.org, armbru@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/3] virtio: let devices be permissive on enabled features
Date: Tue, 6 Mar 2012 15:33:32 +0200	[thread overview]
Message-ID: <20120306133331.GB12096@redhat.com> (raw)
In-Reply-To: <1331036527-7651-2-git-send-email-pbonzini@redhat.com>

On Tue, Mar 06, 2012 at 01:22:05PM +0100, Paolo Bonzini wrote:
> virtio_load checks features that are enabled by the guest and
> blocks migration if they are not available in the destination
> host.  However, in some cases we can let features through because
> we know that guests will be able to proceed even without it.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

So why do we need these hacks? You are saying things
work fine without this information. Then,
why not just have the bit set in supported features always?

> ---
>  hw/virtio-balloon.c    |    2 +-
>  hw/virtio-blk.c        |    2 +-
>  hw/virtio-net.c        |    2 +-
>  hw/virtio-scsi.c       |    2 +-
>  hw/virtio-serial-bus.c |    2 +-
>  hw/virtio.c            |    8 +++++---
>  hw/virtio.h            |    2 +-
>  7 files changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c
> index 075ed87..0ade8b0 100644
> --- a/hw/virtio-balloon.c
> +++ b/hw/virtio-balloon.c
> @@ -216,7 +216,7 @@ static int virtio_balloon_load(QEMUFile *f, void *opaque, int version_id)
>      if (version_id != 1)
>          return -EINVAL;
>  
> -    ret = virtio_load(&s->vdev, f);
> +    ret = virtio_load(&s->vdev, f, 0);
>      if (ret) {
>          return ret;
>      }
> diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
> index d4bb400..c95f8fc 100644
> --- a/hw/virtio-blk.c
> +++ b/hw/virtio-blk.c
> @@ -542,7 +542,7 @@ static int virtio_blk_load(QEMUFile *f, void *opaque, int version_id)
>      if (version_id != 2)
>          return -EINVAL;
>  
> -    ret = virtio_load(&s->vdev, f);
> +    ret = virtio_load(&s->vdev, f, 0);
>      if (ret) {
>          return ret;
>      }
> diff --git a/hw/virtio-net.c b/hw/virtio-net.c
> index 3f190d4..719ba96 100644
> --- a/hw/virtio-net.c
> +++ b/hw/virtio-net.c
> @@ -896,7 +896,7 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
>      if (version_id < 2 || version_id > VIRTIO_NET_VM_VERSION)
>          return -EINVAL;
>  
> -    ret = virtio_load(&n->vdev, f);
> +    ret = virtio_load(&n->vdev, f, 0);
>      if (ret) {
>          return ret;
>      }
> diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c
> index 9797847..da281e2 100644
> --- a/hw/virtio-scsi.c
> +++ b/hw/virtio-scsi.c
> @@ -560,7 +560,7 @@ static int virtio_scsi_load(QEMUFile *f, void *opaque, int version_id)
>      VirtIOSCSI *s = opaque;
>      int ret;
>  
> -    ret = virtio_load(&s->vdev, f);
> +    ret = virtio_load(&s->vdev, f, 0);
>      if (ret) {
>          return ret;
>      }
> diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
> index 4a33872..5ef7d30 100644
> --- a/hw/virtio-serial-bus.c
> +++ b/hw/virtio-serial-bus.c
> @@ -597,7 +597,7 @@ static int virtio_serial_load(QEMUFile *f, void *opaque, int version_id)
>      }
>  
>      /* The virtio device */
> -    ret = virtio_load(&s->vdev, f);
> +    ret = virtio_load(&s->vdev, f, 0);
>      if (ret) {
>          return ret;
>      }
> diff --git a/hw/virtio.c b/hw/virtio.c
> index 064aecf..fdbb286 100644
> --- a/hw/virtio.c
> +++ b/hw/virtio.c
> @@ -777,11 +777,12 @@ int virtio_set_features(VirtIODevice *vdev, uint32_t val)
>      return bad ? -1 : 0;
>  }
>  
> -int virtio_load(VirtIODevice *vdev, QEMUFile *f)
> +int virtio_load(VirtIODevice *vdev, QEMUFile *f, int additional_features)

int? Should be uint32_t?

>  {
>      int num, i, ret;
>      uint32_t features;
>      uint32_t supported_features;
> +    uint32_t disabled_features;
>  
>      if (vdev->binding->load_config) {
>          ret = vdev->binding->load_config(vdev->binding_opaque, f);
> @@ -794,8 +795,9 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f)
>      qemu_get_be16s(f, &vdev->queue_sel);
>      qemu_get_be32s(f, &features);
>  
> -    if (virtio_set_features(vdev, features) < 0) {
> -        supported_features = vdev->binding->get_features(vdev->binding_opaque);
> +    supported_features = vdev->binding->get_features(vdev->binding_opaque);
> +    disabled_features = additional_features & ~supported_features;
> +    if (virtio_set_features(vdev, features & ~disabled_features) < 0) {
>          error_report("Features 0x%x unsupported. Allowed features: 0x%x",
>                       features, supported_features);
>          return -1;
> diff --git a/hw/virtio.h b/hw/virtio.h
> index 400c092..2e8dd20 100644
> --- a/hw/virtio.h
> +++ b/hw/virtio.h
> @@ -154,7 +154,7 @@ void virtio_notify(VirtIODevice *vdev, VirtQueue *vq);
>  
>  void virtio_save(VirtIODevice *vdev, QEMUFile *f);
>  
> -int virtio_load(VirtIODevice *vdev, QEMUFile *f);
> +int virtio_load(VirtIODevice *vdev, QEMUFile *f, int additional_features);
>  
>  void virtio_cleanup(VirtIODevice *vdev);
>  
> -- 
> 1.7.7.6
> 

  reply	other threads:[~2012-03-06 13:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-06 12:22 [Qemu-devel] [PATCH 0/3] Make virtio_load permissive when possible Paolo Bonzini
2012-03-06 12:22 ` [Qemu-devel] [PATCH 1/3] virtio: let devices be permissive on enabled features Paolo Bonzini
2012-03-06 13:33   ` Michael S. Tsirkin [this message]
2012-03-06 13:57     ` Paolo Bonzini
2012-03-06 14:22       ` Orit Wasserman
2012-03-06 12:22 ` [Qemu-devel] [PATCH 2/3] virtio-balloon: note optional features Paolo Bonzini
2012-03-06 14:55   ` Michael S. Tsirkin
2012-03-06 14:59     ` Paolo Bonzini
2012-03-06 15:08       ` Michael S. Tsirkin
2012-03-06 15:13         ` Paolo Bonzini
2012-03-06 12:22 ` [Qemu-devel] [PATCH 3/3] virtio-blk: " Paolo Bonzini
2012-03-06 14:53   ` Michael S. Tsirkin
2012-03-06 15:58     ` Paolo Bonzini
2012-03-06 17:03   ` Anthony Liguori
2012-03-06 17:12     ` Paolo Bonzini
2012-03-06 17:15       ` Anthony Liguori

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=20120306133331.GB12096@redhat.com \
    --to=mst@redhat.com \
    --cc=amit.shah@redhat.com \
    --cc=armbru@redhat.com \
    --cc=owasserm@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=uobergfe@redhat.com \
    /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).