[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC v2 26/32] vhost: Add VHOST_USER_POSTCOPY_END messa
From: |
Peter Xu |
Subject: |
Re: [Qemu-devel] [RFC v2 26/32] vhost: Add VHOST_USER_POSTCOPY_END message |
Date: |
Wed, 30 Aug 2017 14:55:46 +0800 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
On Thu, Aug 24, 2017 at 08:27:24PM +0100, Dr. David Alan Gilbert (git) wrote:
> 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>
(I feel like the title should be for "vub", not "vhost"?)
Reviewed-by: Peter Xu <address@hidden>
> ---
> contrib/libvhost-user/libvhost-user.c | 23 +++++++++++++++++++++++
> contrib/libvhost-user/libvhost-user.h | 1 +
> docs/interop/vhost-user.txt | 8 ++++++++
> hw/virtio/vhost-user.c | 1 +
> 4 files changed, 33 insertions(+)
>
> diff --git a/contrib/libvhost-user/libvhost-user.c
> b/contrib/libvhost-user/libvhost-user.c
> index d816851c6d..23bff47649 100644
> --- a/contrib/libvhost-user/libvhost-user.c
> +++ b/contrib/libvhost-user/libvhost-user.c
> @@ -67,6 +67,7 @@ vu_request_to_string(int req)
> REQ(VHOST_USER_SET_VRING_ENDIAN),
> REQ(VHOST_USER_POSTCOPY_ADVISE),
> REQ(VHOST_USER_POSTCOPY_LISTEN),
> + REQ(VHOST_USER_POSTCOPY_END),
> REQ(VHOST_USER_MAX),
> };
> #undef REQ
> @@ -893,6 +894,26 @@ vu_set_postcopy_listen(VuDev *dev, VhostUserMsg *vmsg)
> vmsg->payload.u64 = 0; /* Success */
> return true;
> }
> +
> +static bool
> +vu_set_postcopy_end(VuDev *dev, VhostUserMsg *vmsg)
> +{
> + DPRINT("%s: Entry\n", __func__);
> + dev->postcopy_listening = false;
> + if (dev->postcopy_ufd > 0) {
> + close(dev->postcopy_ufd);
> + dev->postcopy_ufd = -1;
> + DPRINT("%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;
> + DPRINT("%s: exit\n", __func__);
> + return true;
> +}
> +
> static bool
> vu_process_message(VuDev *dev, VhostUserMsg *vmsg)
> {
> @@ -962,6 +983,8 @@ vu_process_message(VuDev *dev, VhostUserMsg *vmsg)
> return vu_set_postcopy_advise(dev, vmsg);
> case VHOST_USER_POSTCOPY_LISTEN:
> return vu_set_postcopy_listen(dev, vmsg);
> + case VHOST_USER_POSTCOPY_END:
> + return vu_set_postcopy_end(dev, vmsg);
> default:
> vmsg_close_fds(vmsg);
> vu_panic(dev, "Unhandled request: %d", vmsg->request);
> diff --git a/contrib/libvhost-user/libvhost-user.h
> b/contrib/libvhost-user/libvhost-user.h
> index 29c11ba56c..a78596e6fd 100644
> --- a/contrib/libvhost-user/libvhost-user.h
> +++ b/contrib/libvhost-user/libvhost-user.h
> @@ -68,6 +68,7 @@ typedef enum VhostUserRequest {
> VHOST_USER_SET_VRING_ENDIAN = 23,
> VHOST_USER_POSTCOPY_ADVISE = 24,
> VHOST_USER_POSTCOPY_LISTEN = 25,
> + VHOST_USER_POSTCOPY_END = 26,
> VHOST_USER_MAX
> } VhostUserRequest;
>
> diff --git a/docs/interop/vhost-user.txt b/docs/interop/vhost-user.txt
> index b2a548c94d..d6586e0b43 100644
> --- a/docs/interop/vhost-user.txt
> +++ b/docs/interop/vhost-user.txt
> @@ -627,6 +627,14 @@ Master message types
>
> Master advises slave that a transition to postcopy mode has happened.
>
> + * VHOST_USER_POSTCOPY_END
> + Id: 26
> + Slave payload: u64
> +
> + Master advises that postcopy migration has now completed. The
> + slave must disable the userfaultfd. The response is an acknowledgement
> + only.
> +
> Slave message types
> -------------------
>
> diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
> index 4d03383a66..c2e55be0fd 100644
> --- a/hw/virtio/vhost-user.c
> +++ b/hw/virtio/vhost-user.c
> @@ -71,6 +71,7 @@ typedef enum VhostUserRequest {
> VHOST_USER_SET_VRING_ENDIAN = 23,
> VHOST_USER_POSTCOPY_ADVISE = 24,
> VHOST_USER_POSTCOPY_LISTEN = 25,
> + VHOST_USER_POSTCOPY_END = 26,
> VHOST_USER_MAX
> } VhostUserRequest;
>
> --
> 2.13.5
>
--
Peter Xu
- [Qemu-devel] [RFC v2 20/32] postcopy: wake shared, (continued)
- [Qemu-devel] [RFC v2 20/32] postcopy: wake shared, Dr. David Alan Gilbert (git), 2017/08/24
- [Qemu-devel] [RFC v2 21/32] postcopy: postcopy_notify_shared_wake, Dr. David Alan Gilbert (git), 2017/08/24
- [Qemu-devel] [RFC v2 22/32] vhost+postcopy: Add vhost waker, Dr. David Alan Gilbert (git), 2017/08/24
- [Qemu-devel] [RFC v2 23/32] vhost+postcopy: Call wakeups, Dr. David Alan Gilbert (git), 2017/08/24
- [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
- Re: [Qemu-devel] [RFC v2 26/32] vhost: Add VHOST_USER_POSTCOPY_END message,
Peter Xu <=
- [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), 2017/08/24
- [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