vhost.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef VHOST_H
  2. #define VHOST_H
  3. #include "hw/hw.h"
  4. #include "hw/virtio.h"
  5. /* Generic structures common for any vhost based device. */
  6. struct vhost_virtqueue {
  7. int kick;
  8. int call;
  9. void *desc;
  10. void *avail;
  11. void *used;
  12. int num;
  13. unsigned long long used_phys;
  14. unsigned used_size;
  15. void *ring;
  16. unsigned long long ring_phys;
  17. unsigned ring_size;
  18. };
  19. typedef unsigned long vhost_log_chunk_t;
  20. #define VHOST_LOG_PAGE 0x1000
  21. #define VHOST_LOG_BITS (8 * sizeof(vhost_log_chunk_t))
  22. #define VHOST_LOG_CHUNK (VHOST_LOG_PAGE * VHOST_LOG_BITS)
  23. struct vhost_memory;
  24. struct vhost_dev {
  25. CPUPhysMemoryClient client;
  26. int control;
  27. struct vhost_memory *mem;
  28. struct vhost_virtqueue *vqs;
  29. int nvqs;
  30. unsigned long long features;
  31. unsigned long long acked_features;
  32. unsigned long long backend_features;
  33. bool started;
  34. bool log_enabled;
  35. vhost_log_chunk_t *log;
  36. unsigned long long log_size;
  37. bool force;
  38. };
  39. int vhost_dev_init(struct vhost_dev *hdev, int devfd, bool force);
  40. void vhost_dev_cleanup(struct vhost_dev *hdev);
  41. bool vhost_dev_query(struct vhost_dev *hdev, VirtIODevice *vdev);
  42. int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev);
  43. void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev);
  44. int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev);
  45. void vhost_dev_disable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev);
  46. #endif