vhost.h 1.5 KB
Newer Older
M
Michael S. Tsirkin 已提交
1 2 3 4 5
#ifndef VHOST_H
#define VHOST_H

#include "hw/hw.h"
#include "hw/virtio.h"
A
Avi Kivity 已提交
6
#include "memory.h"
M
Michael S. Tsirkin 已提交
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

/* Generic structures common for any vhost based device. */
struct vhost_virtqueue {
    int kick;
    int call;
    void *desc;
    void *avail;
    void *used;
    int num;
    unsigned long long used_phys;
    unsigned used_size;
    void *ring;
    unsigned long long ring_phys;
    unsigned ring_size;
};

typedef unsigned long vhost_log_chunk_t;
#define VHOST_LOG_PAGE 0x1000
#define VHOST_LOG_BITS (8 * sizeof(vhost_log_chunk_t))
#define VHOST_LOG_CHUNK (VHOST_LOG_PAGE * VHOST_LOG_BITS)

struct vhost_memory;
struct vhost_dev {
A
Avi Kivity 已提交
30
    MemoryListener memory_listener;
M
Michael S. Tsirkin 已提交
31 32
    int control;
    struct vhost_memory *mem;
33 34
    int n_mem_sections;
    MemoryRegionSection *mem_sections;
M
Michael S. Tsirkin 已提交
35 36 37 38 39 40 41 42 43
    struct vhost_virtqueue *vqs;
    int nvqs;
    unsigned long long features;
    unsigned long long acked_features;
    unsigned long long backend_features;
    bool started;
    bool log_enabled;
    vhost_log_chunk_t *log;
    unsigned long long log_size;
44
    bool force;
M
Michael S. Tsirkin 已提交
45 46
};

47 48
int vhost_dev_init(struct vhost_dev *hdev, int devfd, const char *devpath,
                   bool force);
M
Michael S. Tsirkin 已提交
49
void vhost_dev_cleanup(struct vhost_dev *hdev);
50
bool vhost_dev_query(struct vhost_dev *hdev, VirtIODevice *vdev);
M
Michael S. Tsirkin 已提交
51 52
int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev);
void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev);
53 54
int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev);
void vhost_dev_disable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev);
M
Michael S. Tsirkin 已提交
55 56

#endif