[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v2 29/32] vhost-user: Claim support for postcopy
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[Qemu-devel] [RFC v2 29/32] vhost-user: Claim support for postcopy |
Date: |
Thu, 24 Aug 2017 20:27:27 +0100 |
From: "Dr. David Alan Gilbert" <address@hidden>
Tell QEMU we understand the protocol features needed for postcopy.
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
---
contrib/libvhost-user/libvhost-user.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/contrib/libvhost-user/libvhost-user.c
b/contrib/libvhost-user/libvhost-user.c
index 23bff47649..290748733b 100644
--- a/contrib/libvhost-user/libvhost-user.c
+++ b/contrib/libvhost-user/libvhost-user.c
@@ -144,6 +144,35 @@ vmsg_close_fds(VhostUserMsg *vmsg)
}
}
+/* A test to see if we have userfault available */
+static bool
+have_userfault(void)
+{
+#if defined(__linux__) && defined(__NR_userfaultfd) &&\
+ defined(UFFD_FEATURE_MISSING_SHMEM) &&\
+ defined(UFFD_FEATURE_MISSING_HUGETLBFS)
+ /* Now test the kernel we're running on really has the features */
+ int ufd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK);
+ struct uffdio_api api_struct;
+ if (ufd < 0) {
+ return false;
+ }
+
+ api_struct.api = UFFD_API;
+ api_struct.features = UFFD_FEATURE_MISSING_SHMEM |
+ UFFD_FEATURE_MISSING_HUGETLBFS;
+ if (ioctl(ufd, UFFDIO_API, &api_struct)) {
+ close(ufd);
+ return false;
+ }
+ close(ufd);
+ return true;
+
+#else
+ return false;
+#endif
+}
+
static bool
vu_message_read(VuDev *dev, int conn_fd, VhostUserMsg *vmsg)
{
@@ -796,6 +825,10 @@ vu_get_protocol_features_exec(VuDev *dev, VhostUserMsg
*vmsg)
{
uint64_t features = 1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD;
+ if (have_userfault()) {
+ features |= 1ULL << VHOST_USER_PROTOCOL_F_PAGEFAULT;
+ }
+
if (dev->iface->get_protocol_features) {
features |= dev->iface->get_protocol_features(dev);
}
--
2.13.5
- [Qemu-devel] [RFC v2 24/32] vub+postcopy: madvises, (continued)
- [Qemu-devel] [RFC v2 24/32] vub+postcopy: madvises, Dr. David Alan Gilbert (git), 2017/08/24
- [Qemu-devel] [RFC v2 25/32] vhost+postcopy: Lock around set_mem_table, Dr. David Alan Gilbert (git), 2017/08/24
- [Qemu-devel] [RFC v2 26/32] vhost: Add VHOST_USER_POSTCOPY_END message, Dr. David Alan Gilbert (git), 2017/08/24
- [Qemu-devel] [RFC v2 27/32] vhost+postcopy: Wire up POSTCOPY_END notify, Dr. David Alan Gilbert (git), 2017/08/24
- [Qemu-devel] [RFC v2 28/32] postcopy: Allow shared memory, Dr. David Alan Gilbert (git), 2017/08/24
- [Qemu-devel] [RFC v2 29/32] vhost-user: Claim support for postcopy,
Dr. David Alan Gilbert (git) <=
- [Qemu-devel] [RFC v2 30/32] vhost: Merge neighbouring hugepage regions where appropriate, Dr. David Alan Gilbert (git), 2017/08/24
- [Qemu-devel] [RFC v2 31/32] vhost: Don't break merged regions on small remove/non-adds, Dr. David Alan Gilbert (git), 2017/08/24
- [Qemu-devel] [RFC v2 32/32] postcopy shared docs, Dr. David Alan Gilbert (git), 2017/08/24