summary refs log tree commit diff stats
path: root/include/qemu
diff options
context:
space:
mode:
authorPeter Xu <peterx@redhat.com>2023-02-01 16:10:54 -0500
committerJuan Quintela <quintela@redhat.com>2023-02-06 19:22:56 +0100
commitd5890ea0722831eea76a0efd23a496b3e8815fe8 (patch)
treec9d365c7db03036f2928100155bb8d77ccad6bee /include/qemu
parentd9df92925ef2b7ca8774ef44b0e1f859a91d4cd6 (diff)
downloadfocaccia-qemu-d5890ea0722831eea76a0efd23a496b3e8815fe8.tar.gz
focaccia-qemu-d5890ea0722831eea76a0efd23a496b3e8815fe8.zip
util/userfaultfd: Add uffd_open()
Add a helper to create the uffd handle.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Diffstat (limited to 'include/qemu')
-rw-r--r--include/qemu/userfaultfd.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/qemu/userfaultfd.h b/include/qemu/userfaultfd.h
index 6b74f92792..d764496f0b 100644
--- a/include/qemu/userfaultfd.h
+++ b/include/qemu/userfaultfd.h
@@ -13,10 +13,20 @@
 #ifndef USERFAULTFD_H
 #define USERFAULTFD_H
 
+#ifdef CONFIG_LINUX
+
 #include "qemu/osdep.h"
 #include "exec/hwaddr.h"
 #include <linux/userfaultfd.h>
 
+/**
+ * uffd_open(): Open an userfaultfd handle for current context.
+ *
+ * @flags: The flags we want to pass in when creating the handle.
+ *
+ * Returns: the uffd handle if >=0, or <0 if error happens.
+ */
+int uffd_open(int flags);
 int uffd_query_features(uint64_t *features);
 int uffd_create_fd(uint64_t features, bool non_blocking);
 void uffd_close_fd(int uffd_fd);
@@ -32,4 +42,6 @@ int uffd_wakeup(int uffd_fd, void *addr, uint64_t length);
 int uffd_read_events(int uffd_fd, struct uffd_msg *msgs, int count);
 bool uffd_poll_events(int uffd_fd, int tmo);
 
+#endif /* CONFIG_LINUX */
+
 #endif /* USERFAULTFD_H */