cachepc-qemu

Fork of AMDESE/qemu with changes for cachepc side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-qemu
Log | Files | Refs | Submodules | LICENSE | sfeed.txt

vhost-user-server.h (2047B)


      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 "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 "qemu/error-report.h"
     19#include "qapi/error.h"
     20#include "standard-headers/linux/virtio_blk.h"
     21
     22/* A kick fd that we monitor on behalf of libvhost-user */
     23typedef struct VuFdWatch {
     24    VuDev *vu_dev;
     25    int fd; /*kick fd*/
     26    void *pvt;
     27    vu_watch_cb cb;
     28    QTAILQ_ENTRY(VuFdWatch) next;
     29} VuFdWatch;
     30
     31/**
     32 * VuServer:
     33 * A vhost-user server instance with user-defined VuDevIface callbacks.
     34 * Vhost-user device backends can be implemented using VuServer. VuDevIface
     35 * callbacks and virtqueue kicks run in the given AioContext.
     36 */
     37typedef struct {
     38    QIONetListener *listener;
     39    QEMUBH *restart_listener_bh;
     40    AioContext *ctx;
     41    int max_queues;
     42    const VuDevIface *vu_iface;
     43
     44    /* Protected by ctx lock */
     45    VuDev vu_dev;
     46    QIOChannel *ioc; /* The I/O channel with the client */
     47    QIOChannelSocket *sioc; /* The underlying data channel with the client */
     48    QTAILQ_HEAD(, VuFdWatch) vu_fd_watches;
     49
     50    Coroutine *co_trip; /* coroutine for processing VhostUserMsg */
     51} VuServer;
     52
     53bool vhost_user_server_start(VuServer *server,
     54                             SocketAddress *unix_socket,
     55                             AioContext *ctx,
     56                             uint16_t max_queues,
     57                             const VuDevIface *vu_iface,
     58                             Error **errp);
     59
     60void vhost_user_server_stop(VuServer *server);
     61
     62void vhost_user_server_attach_aio_context(VuServer *server, AioContext *ctx);
     63void vhost_user_server_detach_aio_context(VuServer *server);
     64
     65#endif /* VHOST_USER_SERVER_H */