]>
Commit | Line | Data |
---|---|---|
9c4d05b7 MAL |
1 | /* |
2 | * This work is licensed under the terms of the GNU GPL, version 2 or | |
3 | * (at your option) any later version. See the COPYING file in the | |
4 | * top-level directory. | |
5 | */ | |
6 | ||
7 | #include "qemu/osdep.h" | |
9c4d05b7 MAL |
8 | #include "hw/virtio/virtio-input.h" |
9 | ||
bad38726 LY |
10 | static Property vinput_properties[] = { |
11 | DEFINE_PROP_CHR("chardev", VHostUserBase, chardev), | |
12 | DEFINE_PROP_END_OF_LIST(), | |
9c4d05b7 MAL |
13 | }; |
14 | ||
bad38726 | 15 | static void vinput_realize(DeviceState *dev, Error **errp) |
9c4d05b7 | 16 | { |
bad38726 LY |
17 | VHostUserBase *vub = VHOST_USER_BASE(dev); |
18 | VHostUserBaseClass *vubc = VHOST_USER_BASE_GET_CLASS(dev); | |
9c4d05b7 | 19 | |
bad38726 LY |
20 | /* Fixed for input device */ |
21 | vub->virtio_id = VIRTIO_ID_INPUT; | |
22 | vub->num_vqs = 2; | |
23 | vub->vq_size = 4; | |
24 | vub->config_size = sizeof(virtio_input_config); | |
9c4d05b7 | 25 | |
bad38726 | 26 | vubc->parent_realize(dev, errp); |
c255488d JP |
27 | } |
28 | ||
9c4d05b7 MAL |
29 | static const VMStateDescription vmstate_vhost_input = { |
30 | .name = "vhost-user-input", | |
31 | .unmigratable = 1, | |
32 | }; | |
33 | ||
34 | static void vhost_input_class_init(ObjectClass *klass, void *data) | |
35 | { | |
bad38726 | 36 | VHostUserBaseClass *vubc = VHOST_USER_BASE_CLASS(klass); |
9c4d05b7 MAL |
37 | DeviceClass *dc = DEVICE_CLASS(klass); |
38 | ||
39 | dc->vmsd = &vmstate_vhost_input; | |
bad38726 LY |
40 | device_class_set_props(dc, vinput_properties); |
41 | device_class_set_parent_realize(dc, vinput_realize, | |
42 | &vubc->parent_realize); | |
43 | set_bit(DEVICE_CATEGORY_INPUT, dc->categories); | |
9c4d05b7 MAL |
44 | } |
45 | ||
46 | static const TypeInfo vhost_input_info = { | |
47 | .name = TYPE_VHOST_USER_INPUT, | |
bad38726 | 48 | .parent = TYPE_VHOST_USER_BASE, |
9c4d05b7 | 49 | .instance_size = sizeof(VHostUserInput), |
9c4d05b7 MAL |
50 | .class_init = vhost_input_class_init, |
51 | }; | |
52 | ||
53 | static void vhost_input_register_types(void) | |
54 | { | |
55 | type_register_static(&vhost_input_info); | |
56 | } | |
57 | ||
58 | type_init(vhost_input_register_types) |