]>
git.proxmox.com Git - mirror_qemu.git/blob - include/qemu/vhost-user-server.h
2 * Sharing QEMU devices via vhost-user protocol
4 * Copyright (c) Coiby Xu <coiby.xu@gmail.com>.
5 * Copyright (c) 2020 Red Hat, Inc.
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.
11 #ifndef VHOST_USER_SERVER_H
12 #define VHOST_USER_SERVER_H
14 #include "subprojects/libvhost-user/libvhost-user.h" /* only for the type definitions */
15 #include "io/channel-socket.h"
16 #include "io/channel-file.h"
17 #include "io/net-listener.h"
18 #include "qapi/error.h"
19 #include "standard-headers/linux/virtio_blk.h"
21 /* A kick fd that we monitor on behalf of libvhost-user */
22 typedef struct VuFdWatch
{
27 QTAILQ_ENTRY(VuFdWatch
) next
;
32 * A vhost-user server instance with user-defined VuDevIface callbacks.
33 * Vhost-user device backends can be implemented using VuServer. VuDevIface
34 * callbacks and virtqueue kicks run in the given AioContext.
37 QIONetListener
*listener
;
38 QEMUBH
*restart_listener_bh
;
41 const VuDevIface
*vu_iface
;
43 unsigned int in_flight
; /* atomic */
45 /* Protected by ctx lock */
46 bool in_qio_channel_yield
;
50 QIOChannel
*ioc
; /* The I/O channel with the client */
51 QIOChannelSocket
*sioc
; /* The underlying data channel with the client */
52 QTAILQ_HEAD(, VuFdWatch
) vu_fd_watches
;
54 Coroutine
*co_trip
; /* coroutine for processing VhostUserMsg */
57 bool vhost_user_server_start(VuServer
*server
,
58 SocketAddress
*unix_socket
,
61 const VuDevIface
*vu_iface
,
64 void vhost_user_server_stop(VuServer
*server
);
66 void vhost_user_server_inc_in_flight(VuServer
*server
);
67 void vhost_user_server_dec_in_flight(VuServer
*server
);
68 bool vhost_user_server_has_in_flight(VuServer
*server
);
70 void vhost_user_server_attach_aio_context(VuServer
*server
, AioContext
*ctx
);
71 void vhost_user_server_detach_aio_context(VuServer
*server
);
73 #endif /* VHOST_USER_SERVER_H */