[PATCH 0/3] vhost-user: Fixes for VHOST_USER_ADD/REM_MEM_REG

Kevin Wolf posted 3 patches 2 years, 1 month ago
Test checkpatch passed
Failed in applying to current master (apply log)
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>
docs/interop/vhost-user.rst               | 17 +++++++++++++++++
hw/virtio/vhost-user.c                    |  2 +-
subprojects/libvhost-user/libvhost-user.c | 17 +++++++----------
3 files changed, 25 insertions(+), 11 deletions(-)
[PATCH 0/3] vhost-user: Fixes for VHOST_USER_ADD/REM_MEM_REG
Posted by Kevin Wolf 2 years, 1 month ago
While implementing a vhost-user-blk driver for libblkio, I found some
problems with VHOST_USER_ADD/REM_MEM_REG both in the spec and in the
implementations in QEMU and libvhost-user that this series addresses.

I also noticed that you can use REM_MEM_REG or SET_MEM_TABLE to unmap a
memory region that is still in use (e.g. a block I/O request using
addresses from the region has been started, but not completed yet),
which is not great. I'm not sure how to fix this best, though.

We would have to wait for these requests to complete (maybe introduce a
refcount and wait for it to drop to zero), but waiting seems impossible
in libvhost-user because it doesn't have any main loop integration. Just
failing the memory region removal would be safe, but potentially a
rather awkward interface because clients would have to implement some
retry logic.

Kevin Wolf (3):
  docs/vhost-user: Clarifications for VHOST_USER_ADD/REM_MEM_REG
  libvhost-user: Fix extra vu_add/rem_mem_reg reply
  vhost-user: Don't pass file descriptor for VHOST_USER_REM_MEM_REG

 docs/interop/vhost-user.rst               | 17 +++++++++++++++++
 hw/virtio/vhost-user.c                    |  2 +-
 subprojects/libvhost-user/libvhost-user.c | 17 +++++++----------
 3 files changed, 25 insertions(+), 11 deletions(-)

-- 
2.35.1
Re: [PATCH 0/3] vhost-user: Fixes for VHOST_USER_ADD/REM_MEM_REG
Posted by Stefan Hajnoczi 2 years, 1 month ago
On Thu, Apr 07, 2022 at 03:36:54PM +0200, Kevin Wolf wrote:
> While implementing a vhost-user-blk driver for libblkio, I found some
> problems with VHOST_USER_ADD/REM_MEM_REG both in the spec and in the
> implementations in QEMU and libvhost-user that this series addresses.
> 
> I also noticed that you can use REM_MEM_REG or SET_MEM_TABLE to unmap a
> memory region that is still in use (e.g. a block I/O request using
> addresses from the region has been started, but not completed yet),
> which is not great. I'm not sure how to fix this best, though.
> 
> We would have to wait for these requests to complete (maybe introduce a
> refcount and wait for it to drop to zero), but waiting seems impossible
> in libvhost-user because it doesn't have any main loop integration. Just
> failing the memory region removal would be safe, but potentially a
> rather awkward interface because clients would have to implement some
> retry logic.
> 
> Kevin Wolf (3):
>   docs/vhost-user: Clarifications for VHOST_USER_ADD/REM_MEM_REG
>   libvhost-user: Fix extra vu_add/rem_mem_reg reply
>   vhost-user: Don't pass file descriptor for VHOST_USER_REM_MEM_REG
> 
>  docs/interop/vhost-user.rst               | 17 +++++++++++++++++
>  hw/virtio/vhost-user.c                    |  2 +-
>  subprojects/libvhost-user/libvhost-user.c | 17 +++++++----------
>  3 files changed, 25 insertions(+), 11 deletions(-)
> 
> -- 
> 2.35.1
> 

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>