aboutsummaryrefslogtreecommitdiff
path: root/hw/virtio-bus.c
diff options
context:
space:
mode:
authorKONRAD Frederic <fred.konrad@greensocs.com>2013-01-15 00:08:02 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2013-01-21 13:23:12 -0600
commit8e05db9234050cb3f0ffb765608dd8b176334ae1 (patch)
tree416e9423918dc781faa542d02ab0cbbaa699f730 /hw/virtio-bus.c
parentff8eca5536edd3f84bc87277e158e4db11dadf82 (diff)
downloadqemu-8e05db9234050cb3f0ffb765608dd8b176334ae1.zip
qemu-8e05db9234050cb3f0ffb765608dd8b176334ae1.tar.gz
qemu-8e05db9234050cb3f0ffb765608dd8b176334ae1.tar.bz2
virtio-device: refactor virtio-device.
Create the virtio-device which is abstract. All the virtio-device can extend this class. It also add some functions to virtio-bus. Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/virtio-bus.c')
-rw-r--r--hw/virtio-bus.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/hw/virtio-bus.c b/hw/virtio-bus.c
index b8f656e..6045d8a 100644
--- a/hw/virtio-bus.c
+++ b/hw/virtio-bus.c
@@ -113,6 +113,41 @@ size_t virtio_bus_get_vdev_config_len(VirtioBusState *bus)
return bus->vdev->config_len;
}
+/* Get the features of the plugged device. */
+uint32_t virtio_bus_get_vdev_features(VirtioBusState *bus,
+ uint32_t requested_features)
+{
+ VirtioDeviceClass *k;
+ assert(bus->vdev != NULL);
+ k = VIRTIO_DEVICE_GET_CLASS(bus->vdev);
+ assert(k->get_features != NULL);
+ return k->get_features(bus->vdev, requested_features);
+}
+
+/* Get bad features of the plugged device. */
+uint32_t virtio_bus_get_vdev_bad_features(VirtioBusState *bus)
+{
+ VirtioDeviceClass *k;
+ assert(bus->vdev != NULL);
+ k = VIRTIO_DEVICE_GET_CLASS(bus->vdev);
+ if (k->bad_features != NULL) {
+ return k->bad_features(bus->vdev);
+ } else {
+ return 0;
+ }
+}
+
+/* Get config of the plugged device. */
+void virtio_bus_get_vdev_config(VirtioBusState *bus, uint8_t *config)
+{
+ VirtioDeviceClass *k;
+ assert(bus->vdev != NULL);
+ k = VIRTIO_DEVICE_GET_CLASS(bus->vdev);
+ if (k->get_config != NULL) {
+ k->get_config(bus->vdev, config);
+ }
+}
+
static const TypeInfo virtio_bus_info = {
.name = TYPE_VIRTIO_BUS,
.parent = TYPE_BUS,