[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 12/29] vhost+postcopy: Register shared ufd with postco
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[Qemu-devel] [RFC 12/29] vhost+postcopy: Register shared ufd with postcopy |
Date: |
Wed, 28 Jun 2017 20:00:30 +0100 |
From: "Dr. David Alan Gilbert" <address@hidden>
Register the UFD that comes in as the response to the 'advise' method
with the postcopy code.
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
---
hw/virtio/vhost-user.c | 23 ++++++++++++++++++++++-
migration/postcopy-ram.h | 2 +-
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index ee9a1ac8a3..b98fbe4834 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -24,6 +24,7 @@
#include <sys/socket.h>
#include <sys/un.h>
#include <linux/vhost.h>
+#include <linux/userfaultfd.h>
#define VHOST_MEMORY_MAX_NREGIONS 8
#define VHOST_USER_F_PROTOCOL_FEATURES 30
@@ -128,6 +129,7 @@ struct vhost_user {
CharBackend *chr;
int slave_fd;
NotifierWithReturn postcopy_notifier;
+ struct PostCopyFD postcopy_fd;
};
static bool ioeventfd_enabled(void)
@@ -707,6 +709,19 @@ out:
}
/*
+ * Called back from the postcopy fault thread when a fault is received on our
+ * ufd.
+ * TODO: This is Linux specific
+ */
+static int vhost_user_postcopy_fault_handler(struct PostCopyFD *pcfd,
+ void *ufd)
+{
+ struct uffd_msg *msg = ufd;
+
+ return 0;
+}
+
+/*
* Called at the start of an inbound postcopy on reception of the
* 'advise' command.
*/
@@ -745,8 +760,14 @@ static int vhost_user_postcopy_advise(struct vhost_dev
*dev, Error **errp)
error_setg(errp, "%s: Failed to get ufd", __func__);
return -1;
}
+ fcntl(ufd, F_SETFL, O_NONBLOCK);
- /* TODO: register ufd with userfault thread */
+ /* register ufd with userfault thread */
+ u->postcopy_fd.fd = ufd;
+ u->postcopy_fd.data = dev;
+ u->postcopy_fd.handler = vhost_user_postcopy_fault_handler;
+ u->postcopy_fd.idstr = "vhost-user"; /* Need to find unique name */
+ postcopy_register_shared_ufd(&u->postcopy_fd);
return 0;
}
diff --git a/migration/postcopy-ram.h b/migration/postcopy-ram.h
index ba8a8ffec5..28c216cc7a 100644
--- a/migration/postcopy-ram.h
+++ b/migration/postcopy-ram.h
@@ -153,7 +153,7 @@ struct PostCopyFD {
/* Handler to be called whenever we get a poll event */
pcfdhandler handler;
/* A string to use in error messages */
- char *idstr;
+ const char *idstr;
};
/* Register a userfaultfd owned by an external process for
--
2.13.0
- [Qemu-devel] [RFC 02/29] migrate: Update ram_block_discard_range for shared, (continued)
- [Qemu-devel] [RFC 02/29] migrate: Update ram_block_discard_range for shared, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 04/29] migration/ram: ramblock_recv_bitmap_test_byte_offset, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 03/29] qemu_ram_block_host_offset, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 05/29] postcopy: use UFFDIO_ZEROPAGE only when available, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 06/29] postcopy: Add notifier chain, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 07/29] postcopy: Add vhost-user flag for postcopy and check it, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 10/29] vhub: Open userfaultfd, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 09/29] vhub: Support sending fds back to qemu, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 08/29] vhost-user: Add 'VHOST_USER_POSTCOPY_ADVISE' message, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 11/29] postcopy: Allow registering of fd handler, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 12/29] vhost+postcopy: Register shared ufd with postcopy,
Dr. David Alan Gilbert (git) <=
- [Qemu-devel] [RFC 13/29] vhost+postcopy: Transmit 'listen' to client, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 14/29] vhost+postcopy: Register new regions with the ufd, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 15/29] vhost+postcopy: Send address back to qemu, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 16/29] vhost+postcopy: Stash RAMBlock and offset, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 17/29] vhost+postcopy: Send requests to source for shared pages, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 18/29] vhost+postcopy: Resolve client address, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 19/29] postcopy: wake shared, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 20/29] postcopy: postcopy_notify_shared_wake, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 22/29] vhost+postcopy: Call wakeups, Dr. David Alan Gilbert (git), 2017/06/28
- [Qemu-devel] [RFC 21/29] vhost+postcopy: Add vhost waker, Dr. David Alan Gilbert (git), 2017/06/28