From 6d74ca5aa83b83fb52332f7735c61ecb7a5328c1 Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Tue, 8 Dec 2009 20:07:48 +0200 Subject: virtio: verify features on load migrating between hosts which have different features might break silently, if the migration destination does not support some features supported by source. Prevent this from happening by comparing acked feature bits with the mask supported by the device. Signed-off-by: Michael S. Tsirkin Signed-off-by: Anthony Liguori --- hw/syborg_virtio.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'hw/syborg_virtio.c') diff --git a/hw/syborg_virtio.c b/hw/syborg_virtio.c index 6cf5a15c2c..a84206a11c 100644 --- a/hw/syborg_virtio.c +++ b/hw/syborg_virtio.c @@ -87,7 +87,7 @@ static uint32_t syborg_virtio_readl(void *opaque, target_phys_addr_t offset) break; case SYBORG_VIRTIO_HOST_FEATURES: ret = vdev->get_features(vdev); - ret |= (1 << VIRTIO_F_NOTIFY_ON_EMPTY); + ret |= vdev->binding->get_features(s); break; case SYBORG_VIRTIO_GUEST_FEATURES: ret = vdev->features; @@ -242,8 +242,16 @@ static void syborg_virtio_update_irq(void *opaque, uint16_t vector) qemu_set_irq(proxy->irq, level != 0); } +static unsigned syborg_virtio_get_features(void *opaque) +{ + unsigned ret = 0; + ret |= (1 << VIRTIO_F_NOTIFY_ON_EMPTY); + return ret; +} + static VirtIOBindings syborg_virtio_bindings = { - .notify = syborg_virtio_update_irq + .notify = syborg_virtio_update_irq, + .get_features = syborg_virtio_get_features, }; static int syborg_virtio_init(SyborgVirtIOProxy *proxy, VirtIODevice *vdev) -- cgit v1.2.3