diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2020-10-26 10:33:59 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2020-10-26 10:33:59 +0000 |
commit | a5fac424c76d6401ecde4ecb7d846e656d0d6e89 (patch) | |
tree | f3d1cc0acc33b594e23bba6d47d5b93cc30d4d02 /include | |
parent | 4c5b97bfd0dd54dc27717ae8d1cd10e14eef1430 (diff) | |
parent | 4f193168af097ef664287f4c801724f063a60fc2 (diff) | |
download | qemu-a5fac424c76d6401ecde4ecb7d846e656d0d6e89.zip qemu-a5fac424c76d6401ecde4ecb7d846e656d0d6e89.tar.gz qemu-a5fac424c76d6401ecde4ecb7d846e656d0d6e89.tar.bz2 |
Merge remote-tracking branch 'remotes/stefanha-gitlab/tags/block-pull-request' into staging
Pull request
v3:
* Fix linker error on FreeBSD and other !CONFIG_LINUX host OSes [Peter]
# gpg: Signature made Fri 23 Oct 2020 16:21:19 BST
# gpg: using RSA key 8695A8BFD3F97CDAAC35775A9CA4ABB381AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" [full]
# gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" [full]
# Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35 775A 9CA4 ABB3 81AB 73C8
* remotes/stefanha-gitlab/tags/block-pull-request: (28 commits)
iotests: add commit top->base cases to 274
block/io: fix bdrv_is_allocated_above
block/io: bdrv_common_block_status_above: support bs == base
block/io: bdrv_common_block_status_above: support include_base
block/io: fix bdrv_co_block_status_above
block/export: add vhost-user-blk multi-queue support
block/export: add iothread and fixed-iothread options
block: move block exports to libblockdev
qemu-storage-daemon: avoid compiling blockdev_ss twice
util/vhost-user-server: use static library in meson.build
util/vhost-user-server: move header to include/
block/export: convert vhost-user-blk server to block export API
block/export: report flush errors
util/vhost-user-server: rework vu_client_trip() coroutine lifecycle
util/vhost-user-server: check EOF when reading payload
util/vhost-user-server: fix memory leak in vu_message_read()
util/vhost-user-server: drop unused DevicePanicNotifier
block/export: consolidate request structs into VuBlockReq
util/vhost-user-server: drop unnecessary watch deletion
util/vhost-user-server: drop unnecessary QOM cast
...
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/qemu/vhost-user-server.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/include/qemu/vhost-user-server.h b/include/qemu/vhost-user-server.h new file mode 100644 index 0000000..0da4c2c --- /dev/null +++ b/include/qemu/vhost-user-server.h @@ -0,0 +1,65 @@ +/* + * Sharing QEMU devices via vhost-user protocol + * + * Copyright (c) Coiby Xu <coiby.xu@gmail.com>. + * Copyright (c) 2020 Red Hat, Inc. + * + * This work is licensed under the terms of the GNU GPL, version 2 or + * later. See the COPYING file in the top-level directory. + */ + +#ifndef VHOST_USER_SERVER_H +#define VHOST_USER_SERVER_H + +#include "contrib/libvhost-user/libvhost-user.h" +#include "io/channel-socket.h" +#include "io/channel-file.h" +#include "io/net-listener.h" +#include "qemu/error-report.h" +#include "qapi/error.h" +#include "standard-headers/linux/virtio_blk.h" + +/* A kick fd that we monitor on behalf of libvhost-user */ +typedef struct VuFdWatch { + VuDev *vu_dev; + int fd; /*kick fd*/ + void *pvt; + vu_watch_cb cb; + QTAILQ_ENTRY(VuFdWatch) next; +} VuFdWatch; + +/** + * VuServer: + * A vhost-user server instance with user-defined VuDevIface callbacks. + * Vhost-user device backends can be implemented using VuServer. VuDevIface + * callbacks and virtqueue kicks run in the given AioContext. + */ +typedef struct { + QIONetListener *listener; + QEMUBH *restart_listener_bh; + AioContext *ctx; + int max_queues; + const VuDevIface *vu_iface; + + /* Protected by ctx lock */ + VuDev vu_dev; + QIOChannel *ioc; /* The I/O channel with the client */ + QIOChannelSocket *sioc; /* The underlying data channel with the client */ + QTAILQ_HEAD(, VuFdWatch) vu_fd_watches; + + Coroutine *co_trip; /* coroutine for processing VhostUserMsg */ +} VuServer; + +bool vhost_user_server_start(VuServer *server, + SocketAddress *unix_socket, + AioContext *ctx, + uint16_t max_queues, + const VuDevIface *vu_iface, + Error **errp); + +void vhost_user_server_stop(VuServer *server); + +void vhost_user_server_attach_aio_context(VuServer *server, AioContext *ctx); +void vhost_user_server_detach_aio_context(VuServer *server); + +#endif /* VHOST_USER_SERVER_H */ |