qapi: fix example of dump-guest-memory
[qemu/armbru.git] / hw / virtio / vhost-shadow-virtqueue.h
blobe5e24c536d03744de72ef6b6a6936f52c2dfe3e6
1 /*
2 * vhost shadow virtqueue
4 * SPDX-FileCopyrightText: Red Hat, Inc. 2021
5 * SPDX-FileContributor: Author: Eugenio PĂ©rez <eperezma@redhat.com>
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
10 #ifndef VHOST_SHADOW_VIRTQUEUE_H
11 #define VHOST_SHADOW_VIRTQUEUE_H
13 #include "qemu/event_notifier.h"
14 #include "hw/virtio/virtio.h"
15 #include "standard-headers/linux/vhost_types.h"
16 #include "hw/virtio/vhost-iova-tree.h"
18 /* Shadow virtqueue to relay notifications */
19 typedef struct VhostShadowVirtqueue {
20 /* Shadow vring */
21 struct vring vring;
23 /* Shadow kick notifier, sent to vhost */
24 EventNotifier hdev_kick;
25 /* Shadow call notifier, sent to vhost */
26 EventNotifier hdev_call;
29 * Borrowed virtqueue's guest to host notifier. To borrow it in this event
30 * notifier allows to recover the VhostShadowVirtqueue from the event loop
31 * easily. If we use the VirtQueue's one, we don't have an easy way to
32 * retrieve VhostShadowVirtqueue.
34 * So shadow virtqueue must not clean it, or we would lose VirtQueue one.
36 EventNotifier svq_kick;
38 /* Guest's call notifier, where the SVQ calls guest. */
39 EventNotifier svq_call;
41 /* Virtio queue shadowing */
42 VirtQueue *vq;
44 /* Virtio device */
45 VirtIODevice *vdev;
47 /* IOVA mapping */
48 VhostIOVATree *iova_tree;
50 /* Map for use the guest's descriptors */
51 VirtQueueElement **ring_id_maps;
53 /* Next VirtQueue element that guest made available */
54 VirtQueueElement *next_guest_avail_elem;
56 /* Next head to expose to the device */
57 uint16_t shadow_avail_idx;
59 /* Next free descriptor */
60 uint16_t free_head;
62 /* Last seen used idx */
63 uint16_t shadow_used_idx;
65 /* Next head to consume from the device */
66 uint16_t last_used_idx;
67 } VhostShadowVirtqueue;
69 bool vhost_svq_valid_features(uint64_t features, Error **errp);
71 void vhost_svq_set_svq_kick_fd(VhostShadowVirtqueue *svq, int svq_kick_fd);
72 void vhost_svq_set_svq_call_fd(VhostShadowVirtqueue *svq, int call_fd);
73 void vhost_svq_get_vring_addr(const VhostShadowVirtqueue *svq,
74 struct vhost_vring_addr *addr);
75 size_t vhost_svq_driver_area_size(const VhostShadowVirtqueue *svq);
76 size_t vhost_svq_device_area_size(const VhostShadowVirtqueue *svq);
78 void vhost_svq_start(VhostShadowVirtqueue *svq, VirtIODevice *vdev,
79 VirtQueue *vq);
80 void vhost_svq_stop(VhostShadowVirtqueue *svq);
82 VhostShadowVirtqueue *vhost_svq_new(VhostIOVATree *iova_tree);
84 void vhost_svq_free(gpointer vq);
85 G_DEFINE_AUTOPTR_CLEANUP_FUNC(VhostShadowVirtqueue, vhost_svq_free);
87 #endif