From: Raphael Norwitz <raphael.norwitz@nutanix.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: "qemu-block@nongnu.org" <qemu-block@nongnu.org>,
Raphael Norwitz <raphael.norwitz@nutanix.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"stefanha@redhat.com" <stefanha@redhat.com>,
"mst@redhat.com" <mst@redhat.com>
Subject: Re: [PATCH 3/3] vhost-user: Don't pass file descriptor for VHOST_USER_REM_MEM_REG
Date: Fri, 8 Apr 2022 23:55:35 +0000 [thread overview]
Message-ID: <20220408235532.GB10957@raphael-debian-dev> (raw)
In-Reply-To: <20220407133657.155281-4-kwolf@redhat.com>
On Thu, Apr 07, 2022 at 03:36:57PM +0200, Kevin Wolf wrote:
> The spec clarifies now that QEMU should not send a file descriptor in a
> request to remove a memory region. Change it accordingly.
>
> For libvhost-user, this is a bug fix that makes it compatible with
> rust-vmm's implementation that doesn't send a file descriptor. Keep
> accepting, but ignoring a file descriptor for compatibility with older
> QEMU versions.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
> ---
> hw/virtio/vhost-user.c | 2 +-
> subprojects/libvhost-user/libvhost-user.c | 8 ++++----
> 2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
> index 6abbc9da32..82caf607e5 100644
> --- a/hw/virtio/vhost-user.c
> +++ b/hw/virtio/vhost-user.c
> @@ -751,7 +751,7 @@ static int send_remove_regions(struct vhost_dev *dev,
> vhost_user_fill_msg_region(®ion_buffer, shadow_reg, 0);
> msg->payload.mem_reg.region = region_buffer;
>
> - ret = vhost_user_write(dev, msg, &fd, 1);
> + ret = vhost_user_write(dev, msg, NULL, 0);
> if (ret < 0) {
> return ret;
> }
> diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c
> index eccaff5168..d0041c864b 100644
> --- a/subprojects/libvhost-user/libvhost-user.c
> +++ b/subprojects/libvhost-user/libvhost-user.c
> @@ -822,15 +822,15 @@ vu_rem_mem_reg(VuDev *dev, VhostUserMsg *vmsg) {
> int i;
> bool found = false;
>
> - if (vmsg->fd_num != 1) {
> + if (vmsg->fd_num > 1) {
> vmsg_close_fds(vmsg);
> - vu_panic(dev, "VHOST_USER_REM_MEM_REG received %d fds - only 1 fd "
> + vu_panic(dev, "VHOST_USER_REM_MEM_REG received %d fds - at most 1 fd "
> "should be sent for this message type", vmsg->fd_num);
> return false;
> }
>
> if (vmsg->size < VHOST_USER_MEM_REG_SIZE) {
> - close(vmsg->fds[0]);
> + vmsg_close_fds(vmsg);
> vu_panic(dev, "VHOST_USER_REM_MEM_REG requires a message size of at "
> "least %d bytes and only %d bytes were received",
> VHOST_USER_MEM_REG_SIZE, vmsg->size);
> @@ -877,7 +877,7 @@ vu_rem_mem_reg(VuDev *dev, VhostUserMsg *vmsg) {
> vu_panic(dev, "Specified region not found\n");
> }
>
> - close(vmsg->fds[0]);
> + vmsg_close_fds(vmsg);
>
> return false;
> }
> --
> 2.35.1
>
next prev parent reply other threads:[~2022-04-08 23:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-07 13:36 [PATCH 0/3] vhost-user: Fixes for VHOST_USER_ADD/REM_MEM_REG Kevin Wolf
2022-04-07 13:36 ` [PATCH 1/3] docs/vhost-user: Clarifications " Kevin Wolf
2022-04-09 0:02 ` Raphael Norwitz
2022-04-07 13:36 ` [PATCH 2/3] libvhost-user: Fix extra vu_add/rem_mem_reg reply Kevin Wolf
2022-04-08 23:51 ` Raphael Norwitz
2022-04-07 13:36 ` [PATCH 3/3] vhost-user: Don't pass file descriptor for VHOST_USER_REM_MEM_REG Kevin Wolf
2022-04-08 23:55 ` Raphael Norwitz [this message]
2022-04-12 8:40 ` [PATCH 0/3] vhost-user: Fixes for VHOST_USER_ADD/REM_MEM_REG Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220408235532.GB10957@raphael-debian-dev \
--to=raphael.norwitz@nutanix.com \
--cc=kwolf@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).