1 /*
2  * vhost shadow virtqueue
3  *
4  * SPDX-FileCopyrightText: Red Hat, Inc. 2021
5  * SPDX-FileContributor: Author: Eugenio Pérez <eperezma@redhat.com>
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  */
9 
10 #ifndef VHOST_SHADOW_VIRTQUEUE_H
11 #define VHOST_SHADOW_VIRTQUEUE_H
12 
13 #include "qemu/event_notifier.h"
14 
15 /* Shadow virtqueue to relay notifications */
16 typedef struct VhostShadowVirtqueue {
17     /* Shadow kick notifier, sent to vhost */
18     EventNotifier hdev_kick;
19     /* Shadow call notifier, sent to vhost */
20     EventNotifier hdev_call;
21 
22     /*
23      * Borrowed virtqueue's guest to host notifier. To borrow it in this event
24      * notifier allows to recover the VhostShadowVirtqueue from the event loop
25      * easily. If we use the VirtQueue's one, we don't have an easy way to
26      * retrieve VhostShadowVirtqueue.
27      *
28      * So shadow virtqueue must not clean it, or we would lose VirtQueue one.
29      */
30     EventNotifier svq_kick;
31 
32     /* Guest's call notifier, where the SVQ calls guest. */
33     EventNotifier svq_call;
34 } VhostShadowVirtqueue;
35 
36 void vhost_svq_set_svq_kick_fd(VhostShadowVirtqueue *svq, int svq_kick_fd);
37 void vhost_svq_set_svq_call_fd(VhostShadowVirtqueue *svq, int call_fd);
38 
39 void vhost_svq_stop(VhostShadowVirtqueue *svq);
40 
41 VhostShadowVirtqueue *vhost_svq_new(void);
42 
43 void vhost_svq_free(gpointer vq);
44 G_DEFINE_AUTOPTR_CLEANUP_FUNC(VhostShadowVirtqueue, vhost_svq_free);
45 
46 #endif
47