2010-03-17 14:08:17 +03:00
|
|
|
#ifndef VHOST_H
|
|
|
|
#define VHOST_H
|
|
|
|
|
|
|
|
#include "hw/hw.h"
|
|
|
|
#include "hw/virtio.h"
|
2011-12-18 16:06:05 +04:00
|
|
|
#include "memory.h"
|
2010-03-17 14:08:17 +03:00
|
|
|
|
|
|
|
/* 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 {
|
2011-12-18 16:06:05 +04:00
|
|
|
MemoryListener memory_listener;
|
2010-03-17 14:08:17 +03:00
|
|
|
int control;
|
|
|
|
struct vhost_memory *mem;
|
2011-12-19 15:18:13 +04:00
|
|
|
int n_mem_sections;
|
|
|
|
MemoryRegionSection *mem_sections;
|
2010-03-17 14:08:17 +03:00
|
|
|
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;
|
2011-02-01 23:13:42 +03:00
|
|
|
bool force;
|
2010-03-17 14:08:17 +03:00
|
|
|
};
|
|
|
|
|
2012-08-22 00:52:08 +04:00
|
|
|
int vhost_dev_init(struct vhost_dev *hdev, int devfd, const char *devpath,
|
|
|
|
bool force);
|
2010-03-17 14:08:17 +03:00
|
|
|
void vhost_dev_cleanup(struct vhost_dev *hdev);
|
2011-02-01 23:13:42 +03:00
|
|
|
bool vhost_dev_query(struct vhost_dev *hdev, VirtIODevice *vdev);
|
2010-03-17 14:08:17 +03:00
|
|
|
int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev);
|
|
|
|
void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev);
|
2011-08-11 11:21:18 +04:00
|
|
|
int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev);
|
|
|
|
void vhost_dev_disable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev);
|
2010-03-17 14:08:17 +03:00
|
|
|
|
|
|
|
#endif
|