summaryrefslogtreecommitdiff
path: root/hw/virtio/virtio.c
diff options
context:
space:
mode:
authorCornelia Huck <cornelia.huck@de.ibm.com>2015-05-26 16:34:47 +0200
committerMichael S. Tsirkin <mst@redhat.com>2015-05-31 16:27:18 +0200
commit6b8f1020540c27246277377aa2c3331ad2bfb160 (patch)
tree882fcff4a803fffaef50573fe343646e1e1f3f30 /hw/virtio/virtio.c
parent2332333c9738b442fbbd5b83a1eaa6be656ab9b5 (diff)
downloadqemu-6b8f1020540c27246277377aa2c3331ad2bfb160.tar.gz
virtio: move host_features
Move host_features from the individual transport proxies into the virtio device. Transports may continue to add feature bits during device plugging. This should it make easier to offer different sets of host features for virtio-1/transitional support. Tested-by: Shannon Zhao <shannon.zhao@linaro.org> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/virtio/virtio.c')
-rw-r--r--hw/virtio/virtio.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 6985e76b64..96d9c6a199 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -970,13 +970,10 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
int virtio_set_features(VirtIODevice *vdev, uint32_t val)
{
- BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
- VirtioBusClass *vbusk = VIRTIO_BUS_GET_CLASS(qbus);
VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
- uint32_t supported_features = vbusk->get_features(qbus->parent);
- bool bad = (val & ~supported_features) != 0;
+ bool bad = (val & ~(vdev->host_features)) != 0;
- val &= supported_features;
+ val &= vdev->host_features;
if (k->set_features) {
k->set_features(vdev, val);
}
@@ -990,7 +987,6 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id)
int32_t config_len;
uint32_t num;
uint32_t features;
- uint32_t supported_features;
BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev);
@@ -1016,9 +1012,8 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int version_id)
qemu_get_be32s(f, &features);
if (virtio_set_features(vdev, features) < 0) {
- supported_features = k->get_features(qbus->parent);
error_report("Features 0x%x unsupported. Allowed features: 0x%x",
- features, supported_features);
+ features, vdev->host_features);
return -1;
}
config_len = qemu_get_be32(f);
@@ -1351,6 +1346,11 @@ static void virtio_device_unrealize(DeviceState *dev, Error **errp)
vdev->bus_name = NULL;
}
+static Property virtio_properties[] = {
+ DEFINE_VIRTIO_COMMON_FEATURES(VirtIODevice, host_features),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
static void virtio_device_class_init(ObjectClass *klass, void *data)
{
/* Set the default value here. */
@@ -1359,6 +1359,7 @@ static void virtio_device_class_init(ObjectClass *klass, void *data)
dc->realize = virtio_device_realize;
dc->unrealize = virtio_device_unrealize;
dc->bus_type = TYPE_VIRTIO_BUS;
+ dc->props = virtio_properties;
}
static const TypeInfo virtio_device_info = {