[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 49/50] libvhost-user: Claim support for postcopy
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL v2 49/50] libvhost-user: Claim support for postcopy |
Date: |
Tue, 20 Mar 2018 05:18:01 +0200 |
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>
Reviewed-by: Marc-André Lureau <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <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 504ff5e..beeed0c 100644
--- a/contrib/libvhost-user/libvhost-user.c
+++ b/contrib/libvhost-user/libvhost-user.c
@@ -185,6 +185,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)
{
@@ -939,6 +968,10 @@ vu_get_protocol_features_exec(VuDev *dev, VhostUserMsg
*vmsg)
uint64_t features = 1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD |
1ULL << VHOST_USER_PROTOCOL_F_SLAVE_REQ;
+ if (have_userfault()) {
+ features |= 1ULL << VHOST_USER_PROTOCOL_F_PAGEFAULT;
+ }
+
if (dev->iface->get_protocol_features) {
features |= dev->iface->get_protocol_features(dev);
}
--
MST
- [Qemu-devel] [PULL v2 46/50] vhost+postcopy: Wire up POSTCOPY_END notify, (continued)
- [Qemu-devel] [PULL v2 46/50] vhost+postcopy: Wire up POSTCOPY_END notify, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 43/50] vhost+postcopy: Call wakeups, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 44/50] libvhost-user: mprotect & madvises for postcopy, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 35/50] libvhost-user+postcopy: Register new regions with the ufd, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 48/50] postcopy: Allow shared memory, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 42/50] vhost+postcopy: Add vhost waker, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 45/50] vhost-user: Add VHOST_USER_POSTCOPY_END message, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 50/50] postcopy shared docs, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 41/50] postcopy: postcopy_notify_shared_wake, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 47/50] vhost: Huge page align and merge, Michael S. Tsirkin, 2018/03/19
- [Qemu-devel] [PULL v2 49/50] libvhost-user: Claim support for postcopy,
Michael S. Tsirkin <=
- Re: [Qemu-devel] [PULL v2 00/50] virtio, vhost, pci, pc: features, cleanups, Peter Maydell, 2018/03/20
- Re: [Qemu-devel] [PULL v2 00/50] virtio, vhost, pci, pc: features, cleanups, Michael S. Tsirkin, 2018/03/20
- Re: [Qemu-devel] [PULL v2 00/50] virtio, vhost, pci, pc: features, cleanups, Michael S. Tsirkin, 2018/03/20
- Re: [Qemu-devel] [PULL v2 00/50] virtio, vhost, pci, pc: features, cleanups, Peter Maydell, 2018/03/20
- Re: [Qemu-devel] [PULL v2 00/50] virtio, vhost, pci, pc: features, cleanups, Michael S. Tsirkin, 2018/03/20
- Re: [Qemu-devel] [PULL v2 00/50] virtio, vhost, pci, pc: features, cleanups, Peter Maydell, 2018/03/20
- Re: [Qemu-devel] [PULL v2 00/50] virtio, vhost, pci, pc: features, cleanups, Michael S. Tsirkin, 2018/03/20
- Re: [Qemu-devel] [PULL v2 00/50] virtio, vhost, pci, pc: features, cleanups, Peter Maydell, 2018/03/20
- Re: [Qemu-devel] [PULL v2 00/50] virtio, vhost, pci, pc: features, cleanups, Michael S. Tsirkin, 2018/03/20