qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/3] virtio: let devices be permissive on enabled fe


From: Paolo Bonzini
Subject: [Qemu-devel] [PATCH 1/3] virtio: let devices be permissive on enabled features
Date: Tue, 6 Mar 2012 13:22:05 +0100

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 <address@hidden>
---
 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 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 via email to

[Prev in Thread] Current Thread [Next in Thread]