[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v4 24/29] vhost-user: Add VHOST_USER_POSTCOPY_EN
From: |
Marc-André Lureau |
Subject: |
Re: [Qemu-devel] [PATCH v4 24/29] vhost-user: Add VHOST_USER_POSTCOPY_END message |
Date: |
Mon, 12 Mar 2018 17:19:19 +0100 |
On Thu, Mar 8, 2018 at 8:58 PM, Dr. David Alan Gilbert (git)
<address@hidden> 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>
> Reviewed-by: Peter Xu <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
> ---
> contrib/libvhost-user/libvhost-user.c | 23 +++++++++++++++++++++++
> contrib/libvhost-user/libvhost-user.h | 1 +
> docs/interop/vhost-user.txt | 11 +++++++++++
> hw/virtio/vhost-user.c | 1 +
> 4 files changed, 36 insertions(+)
>
> diff --git a/contrib/libvhost-user/libvhost-user.c
> b/contrib/libvhost-user/libvhost-user.c
> index 1b224af706..1f988ab787 100644
> --- a/contrib/libvhost-user/libvhost-user.c
> +++ b/contrib/libvhost-user/libvhost-user.c
> @@ -99,6 +99,7 @@ vu_request_to_string(unsigned int req)
> REQ(VHOST_USER_SET_CONFIG),
> REQ(VHOST_USER_POSTCOPY_ADVISE),
> REQ(VHOST_USER_POSTCOPY_LISTEN),
> + REQ(VHOST_USER_POSTCOPY_END),
> REQ(VHOST_USER_MAX),
> };
> #undef REQ
> @@ -1095,6 +1096,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)
> {
> @@ -1170,6 +1191,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 ed505cf0c1..79f7a53ee8 100644
> --- a/contrib/libvhost-user/libvhost-user.h
> +++ b/contrib/libvhost-user/libvhost-user.h
> @@ -87,6 +87,7 @@ typedef enum VhostUserRequest {
> VHOST_USER_CLOSE_CRYPTO_SESSION = 27,
> VHOST_USER_POSTCOPY_ADVISE = 28,
> VHOST_USER_POSTCOPY_LISTEN = 29,
> + VHOST_USER_POSTCOPY_END = 30,
> VHOST_USER_MAX
> } VhostUserRequest;
>
> diff --git a/docs/interop/vhost-user.txt b/docs/interop/vhost-user.txt
> index cc049196c9..5a31e4234e 100644
> --- a/docs/interop/vhost-user.txt
> +++ b/docs/interop/vhost-user.txt
> @@ -729,6 +729,17 @@ Master message types
> This is always sent sometime after a VHOST_USER_POSTCOPY_ADVISE, and
> thus only when VHOST_USER_PROTOCOL_F_PAGEFAULT is supported.
>
> + * VHOST_USER_POSTCOPY_END
> + Id: 30
> + Slave payload: u64
> +
> + Master advises that postcopy migration has now completed. The
> + slave must disable the userfaultfd. The response is an acknowledgement
> + only.
I guess 0 for success, non-zero otherwise - please update the spec.
> + When VHOST_USER_PROTOCOL_F_PAGEFAULT is supported, this message
> + is sent at the end of the migration, after VHOST_USER_POSTCOPY_LISTEN
> + was previously sent
> +
> Slave message types
> -------------------
>
> diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
> index b304bc475e..45de6d8a53 100644
> --- a/hw/virtio/vhost-user.c
> +++ b/hw/virtio/vhost-user.c
> @@ -82,6 +82,7 @@ typedef enum VhostUserRequest {
> VHOST_USER_CLOSE_CRYPTO_SESSION = 27,
> VHOST_USER_POSTCOPY_ADVISE = 28,
> VHOST_USER_POSTCOPY_LISTEN = 29,
> + VHOST_USER_POSTCOPY_END = 30,
> VHOST_USER_MAX
> } VhostUserRequest;
>
> --
> 2.14.3
>
>
--
Marc-André Lureau
- Re: [Qemu-devel] [PATCH v4 20/29] postcopy: postcopy_notify_shared_wake, (continued)
- [Qemu-devel] [PATCH v4 19/29] postcopy: helper for waking shared, Dr. David Alan Gilbert (git), 2018/03/08
- [Qemu-devel] [PATCH v4 22/29] vhost+postcopy: Call wakeups, Dr. David Alan Gilbert (git), 2018/03/08
- [Qemu-devel] [PATCH v4 21/29] vhost+postcopy: Add vhost waker, Dr. David Alan Gilbert (git), 2018/03/08
- [Qemu-devel] [PATCH v4 23/29] libvhost-user: mprotect & madvises for postcopy, Dr. David Alan Gilbert (git), 2018/03/08
- [Qemu-devel] [PATCH v4 24/29] vhost-user: Add VHOST_USER_POSTCOPY_END message, Dr. David Alan Gilbert (git), 2018/03/08
- Re: [Qemu-devel] [PATCH v4 24/29] vhost-user: Add VHOST_USER_POSTCOPY_END message,
Marc-André Lureau <=
- [Qemu-devel] [PATCH v4 26/29] vhost: Huge page align and merge, Dr. David Alan Gilbert (git), 2018/03/08
- [Qemu-devel] [PATCH v4 29/29] postcopy shared docs, Dr. David Alan Gilbert (git), 2018/03/08
- [Qemu-devel] [PATCH v4 25/29] vhost+postcopy: Wire up POSTCOPY_END notify, Dr. David Alan Gilbert (git), 2018/03/08
- [Qemu-devel] [PATCH v4 28/29] libvhost-user: Claim support for postcopy, Dr. David Alan Gilbert (git), 2018/03/08
- [Qemu-devel] [PATCH v4 27/29] postcopy: Allow shared memory, Dr. David Alan Gilbert (git), 2018/03/08
- Re: [Qemu-devel] [PATCH v4 00/29] postcopy+vhost-user/shared ram, Dr. David Alan Gilbert, 2018/03/09