From: "Dr. David Alan Gilbert" <address@hidden>
This message is sent just before the end of postcopy to get the
client to stop using userfault since we wont respond to any more
requests. It should close userfaultfd so that any other pages
get mapped to the backing file automatically by the kernel, since
at this point we know we've received everything.
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
---
contrib/libvhost-user/libvhost-user.c | 23 +++++++++++++++++++++++
contrib/libvhost-user/libvhost-user.h | 1 +
hw/virtio/vhost-user.c | 1 +
3 files changed, 25 insertions(+)
diff --git a/contrib/libvhost-user/libvhost-user.c
b/contrib/libvhost-user/libvhost-user.c
index d37052b7b0..c1716d1a62 100644
--- a/contrib/libvhost-user/libvhost-user.c
+++ b/contrib/libvhost-user/libvhost-user.c
@@ -68,6 +68,7 @@ vu_request_to_string(int req)
REQ(VHOST_USER_INPUT_GET_CONFIG),
REQ(VHOST_USER_POSTCOPY_ADVISE),
REQ(VHOST_USER_POSTCOPY_LISTEN),
+ REQ(VHOST_USER_POSTCOPY_END),
REQ(VHOST_USER_MAX),
};
#undef REQ
@@ -889,6 +890,26 @@ vu_set_postcopy_listen(VuDev *dev, VhostUserMsg *vmsg)
return false;
}
+
+static bool
+vu_set_postcopy_end(VuDev *dev, VhostUserMsg *vmsg)
+{
+ fprintf(stderr, "%s: Entry\n", __func__);
+ dev->postcopy_listening = false;
+ if (dev->postcopy_ufd > 0) {
+ close(dev->postcopy_ufd);
+ dev->postcopy_ufd = -1;
+ fprintf(stderr, "%s: Done close\n", __func__);
+ }
+
+ vmsg->fd_num = 0;
+ vmsg->payload.u64 = 0;
+ vmsg->size = sizeof(vmsg->payload.u64);
+ vmsg->flags = VHOST_USER_VERSION | VHOST_USER_REPLY_MASK;
+ fprintf(stderr, "%s: exit\n", __func__);
+ return true;
+}
+