1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#ifndef VIRTIO_BUS_H
26#define VIRTIO_BUS_H
27
28#include "hw/qdev.h"
29#include "sysemu/sysemu.h"
30#include "hw/virtio/virtio.h"
31
32#define TYPE_VIRTIO_BUS "virtio-bus"
33#define VIRTIO_BUS_GET_CLASS(obj) \
34 OBJECT_GET_CLASS(VirtioBusClass, obj, TYPE_VIRTIO_BUS)
35#define VIRTIO_BUS_CLASS(klass) \
36 OBJECT_CLASS_CHECK(VirtioBusClass, klass, TYPE_VIRTIO_BUS)
37#define VIRTIO_BUS(obj) OBJECT_CHECK(VirtioBusState, (obj), TYPE_VIRTIO_BUS)
38
39typedef struct VirtioBusState VirtioBusState;
40
41typedef struct VirtioBusClass {
42
43 BusClass parent;
44 void (*notify)(DeviceState *d, uint16_t vector);
45 void (*save_config)(DeviceState *d, QEMUFile *f);
46 void (*save_queue)(DeviceState *d, int n, QEMUFile *f);
47 int (*load_config)(DeviceState *d, QEMUFile *f);
48 int (*load_queue)(DeviceState *d, int n, QEMUFile *f);
49 int (*load_done)(DeviceState *d, QEMUFile *f);
50 unsigned (*get_features)(DeviceState *d);
51 bool (*query_guest_notifiers)(DeviceState *d);
52 int (*set_guest_notifiers)(DeviceState *d, int nvqs, bool assign);
53 int (*set_host_notifier)(DeviceState *d, int n, bool assigned);
54 void (*vmstate_change)(DeviceState *d, bool running);
55
56
57
58
59 void (*device_plugged)(DeviceState *d);
60
61
62
63
64 void (*device_unplug)(DeviceState *d);
65
66
67
68
69
70 bool has_variable_vring_alignment;
71} VirtioBusClass;
72
73struct VirtioBusState {
74 BusState parent_obj;
75
76
77
78 VirtIODevice *vdev;
79};
80
81int virtio_bus_plug_device(VirtIODevice *vdev);
82void virtio_bus_reset(VirtioBusState *bus);
83void virtio_bus_destroy_device(VirtioBusState *bus);
84
85uint16_t virtio_bus_get_vdev_id(VirtioBusState *bus);
86
87size_t virtio_bus_get_vdev_config_len(VirtioBusState *bus);
88
89uint32_t virtio_bus_get_vdev_features(VirtioBusState *bus,
90 uint32_t requested_features);
91
92void virtio_bus_set_vdev_features(VirtioBusState *bus,
93 uint32_t requested_features);
94
95uint32_t virtio_bus_get_vdev_bad_features(VirtioBusState *bus);
96
97void virtio_bus_get_vdev_config(VirtioBusState *bus, uint8_t *config);
98
99void virtio_bus_set_vdev_config(VirtioBusState *bus, uint8_t *config);
100
101#endif
102