@@ -127,7 +127,7 @@ static void virtio_balloon_set_config(VirtIODevice *vdev,
static uint32_t virtio_balloon_get_features(VirtIODevice *vdev)
{
- return 0;
+ return virtio_common_features();
}
static ram_addr_t virtio_balloon_to_target(void *opaque, ram_addr_t target)
@@ -445,7 +445,7 @@ static uint32_t virtio_blk_get_features(VirtIODevice *vdev)
if (strcmp(s->serial_str, "0"))
features |= 1 << VIRTIO_BLK_F_IDENTIFY;
- return features;
+ return features | virtio_common_features();
}
static void virtio_blk_save(QEMUFile *f, void *opaque)
@@ -53,7 +53,7 @@ static void virtio_console_handle_input(VirtIODevice *vdev, VirtQueue *vq)
static uint32_t virtio_console_get_features(VirtIODevice *vdev)
{
- return 0;
+ return virtio_common_features();
}
static int vcon_can_read(void *opaque)
@@ -154,7 +154,7 @@ static uint32_t virtio_net_get_features(VirtIODevice *vdev)
}
#endif
- return features;
+ return features | virtio_common_features();
}
static uint32_t virtio_net_bad_features(VirtIODevice *vdev)
@@ -230,9 +230,6 @@ static uint32_t virtio_ioport_read(VirtIOPCIProxy *proxy, uint32_t addr)
switch (addr) {
case VIRTIO_PCI_HOST_FEATURES:
ret = vdev->get_features(vdev);
- ret |= (1 << VIRTIO_F_NOTIFY_ON_EMPTY);
- ret |= (1 << VIRTIO_RING_F_INDIRECT_DESC);
- ret |= (1 << VIRTIO_F_BAD_FEATURE);
break;
case VIRTIO_PCI_GUEST_FEATURES:
ret = vdev->features;
@@ -167,4 +167,14 @@ VirtIODevice *virtio_net_init(DeviceState *dev);
VirtIODevice *virtio_console_init(DeviceState *dev);
VirtIODevice *virtio_balloon_init(DeviceState *dev);
+static inline uint32_t virtio_common_features(void)
+{
+ uint32_t features = 0;
+ features |= (1 << VIRTIO_F_NOTIFY_ON_EMPTY);
+ features |= (1 << VIRTIO_RING_F_INDIRECT_DESC);
+ features |= (1 << VIRTIO_F_BAD_FEATURE);
+
+ return features;
+}
+
#endif