]> git.proxmox.com Git - mirror_qemu.git/commitdiff
event_notifier: add event_notifier_get_wfd()
authorSergio Lopez <slp@redhat.com>
Fri, 4 Mar 2022 10:08:51 +0000 (11:08 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Sun, 6 Mar 2022 11:19:47 +0000 (06:19 -0500)
event_notifier_get_fd(const EventNotifier *e) always returns
EventNotifier's read file descriptor (rfd). This is not a problem when
the EventNotifier is backed by a an eventfd, as a single file
descriptor is used both for reading and triggering events (rfd ==
wfd).

But, when EventNotifier is backed by a pipe pair, we have two file
descriptors, one that can only be used for reads (rfd), and the other
only for writes (wfd).

There's, at least, one known situation in which we need to obtain wfd
instead of rfd, which is when setting up the file that's going to be
sent to the peer in vhost's SET_VRING_CALL.

Add a new event_notifier_get_wfd(const EventNotifier *e) that can be
used to obtain wfd where needed.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20220304100854.14829-2-slp@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
include/qemu/event_notifier.h
util/event_notifier-posix.c

index b79add035de8b2f00dbba4c8bca562b3dc3a0ca4..8a4ff308e191b21307eff0d6f46cc37c5faef7f2 100644 (file)
@@ -38,6 +38,7 @@ int event_notifier_test_and_clear(EventNotifier *);
 #ifdef CONFIG_POSIX
 void event_notifier_init_fd(EventNotifier *, int fd);
 int event_notifier_get_fd(const EventNotifier *);
+int event_notifier_get_wfd(const EventNotifier *);
 #else
 HANDLE event_notifier_get_handle(EventNotifier *);
 #endif
index 8307013c5df0788c93ba66ca8d43a3b498f4c32e..16294e98d434e83e39fa13fb721fba7b09a595e4 100644 (file)
@@ -99,6 +99,11 @@ int event_notifier_get_fd(const EventNotifier *e)
     return e->rfd;
 }
 
+int event_notifier_get_wfd(const EventNotifier *e)
+{
+    return e->wfd;
+}
+
 int event_notifier_set(EventNotifier *e)
 {
     static const uint64_t value = 1;