1 /*
2  * Parent class for vhost-vsock devices
3  *
4  * Copyright 2015-2020 Red Hat, Inc.
5  *
6  * This work is licensed under the terms of the GNU GPL, version 2 or
7  * (at your option) any later version.  See the COPYING file in the
8  * top-level directory.
9  */
10 
11 #ifndef _QEMU_VHOST_VSOCK_COMMON_H
12 #define _QEMU_VHOST_VSOCK_COMMON_H
13 
14 #include "hw/virtio/virtio.h"
15 #include "hw/virtio/vhost.h"
16 #include "qom/object.h"
17 
18 #define TYPE_VHOST_VSOCK_COMMON "vhost-vsock-common"
19 typedef struct VHostVSockCommon VHostVSockCommon;
20 DECLARE_INSTANCE_CHECKER(VHostVSockCommon, VHOST_VSOCK_COMMON,
21                          TYPE_VHOST_VSOCK_COMMON)
22 
23 enum {
24     VHOST_VSOCK_SAVEVM_VERSION = 0,
25 
26     VHOST_VSOCK_QUEUE_SIZE = 128,
27 };
28 
29 struct VHostVSockCommon {
30     VirtIODevice parent;
31 
32     struct vhost_virtqueue vhost_vqs[2];
33     struct vhost_dev vhost_dev;
34 
35     VirtQueue *event_vq;
36     VirtQueue *recv_vq;
37     VirtQueue *trans_vq;
38 
39     QEMUTimer *post_load_timer;
40 };
41 
42 int vhost_vsock_common_start(VirtIODevice *vdev);
43 void vhost_vsock_common_stop(VirtIODevice *vdev);
44 int vhost_vsock_common_pre_save(void *opaque);
45 int vhost_vsock_common_post_load(void *opaque, int version_id);
46 void vhost_vsock_common_realize(VirtIODevice *vdev, const char *name);
47 void vhost_vsock_common_unrealize(VirtIODevice *vdev);
48 
49 #endif /* _QEMU_VHOST_VSOCK_COMMON_H */
50