util/vhost-user-server: drop unused DevicePanicNotifier
[qemu.git] / util / vhost-user-server.h
1 /*
2 * Sharing QEMU devices via vhost-user protocol
3 *
4 * Copyright (c) Coiby Xu <coiby.xu@gmail.com>.
5 * Copyright (c) 2020 Red Hat, Inc.
6 *
7 * This work is licensed under the terms of the GNU GPL, version 2 or
8 * later. See the COPYING file in the top-level directory.
9 */
10
11 #ifndef VHOST_USER_SERVER_H
12 #define VHOST_USER_SERVER_H
13
14 #include "contrib/libvhost-user/libvhost-user.h"
15 #include "io/channel-socket.h"
16 #include "io/channel-file.h"
17 #include "io/net-listener.h"
18 #include "qemu/error-report.h"
19 #include "qapi/error.h"
20 #include "standard-headers/linux/virtio_blk.h"
21
22 typedef struct VuFdWatch {
23 VuDev *vu_dev;
24 int fd; /*kick fd*/
25 void *pvt;
26 vu_watch_cb cb;
27 bool processing;
28 QTAILQ_ENTRY(VuFdWatch) next;
29 } VuFdWatch;
30
31 typedef struct VuServer VuServer;
32
33 struct VuServer {
34 QIONetListener *listener;
35 AioContext *ctx;
36 int max_queues;
37 const VuDevIface *vu_iface;
38 VuDev vu_dev;
39 QIOChannel *ioc; /* The I/O channel with the client */
40 QIOChannelSocket *sioc; /* The underlying data channel with the client */
41 /* IOChannel for fd provided via VHOST_USER_SET_SLAVE_REQ_FD */
42 QIOChannel *ioc_slave;
43 QIOChannelSocket *sioc_slave;
44 Coroutine *co_trip; /* coroutine for processing VhostUserMsg */
45 QTAILQ_HEAD(, VuFdWatch) vu_fd_watches;
46 /* restart coroutine co_trip if AIOContext is changed */
47 bool aio_context_changed;
48 bool processing_msg;
49 };
50
51 bool vhost_user_server_start(VuServer *server,
52 SocketAddress *unix_socket,
53 AioContext *ctx,
54 uint16_t max_queues,
55 const VuDevIface *vu_iface,
56 Error **errp);
57
58 void vhost_user_server_stop(VuServer *server);
59
60 void vhost_user_server_set_aio_context(VuServer *server, AioContext *ctx);
61
62 #endif /* VHOST_USER_SERVER_H */