[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 04/13] vhost-user: Don't pass file descriptor for VHOST_USER_REM_M
From: |
Kevin Wolf |
Subject: |
[PULL 04/13] vhost-user: Don't pass file descriptor for VHOST_USER_REM_MEM_REG |
Date: |
Wed, 4 May 2022 16:25:13 +0200 |
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>
Message-Id: <20220407133657.155281-4-kwolf@redhat.com>
Reviewed-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.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 a80315ecfc..2d434ff0bc 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
- [PULL 00/13] Block layer patches, Kevin Wolf, 2022/05/04
- [PULL 02/13] docs/vhost-user: Clarifications for VHOST_USER_ADD/REM_MEM_REG, Kevin Wolf, 2022/05/04
- [PULL 03/13] libvhost-user: Fix extra vu_add/rem_mem_reg reply, Kevin Wolf, 2022/05/04
- [PULL 04/13] vhost-user: Don't pass file descriptor for VHOST_USER_REM_MEM_REG,
Kevin Wolf <=
- [PULL 06/13] qcow2: Do not reopen data_file in invalidate_cache, Kevin Wolf, 2022/05/04
- [PULL 09/13] block/vmdk: Fix reopening bs->file, Kevin Wolf, 2022/05/04
- [PULL 01/13] qemu-img: properly list formats which have consistency check implemented, Kevin Wolf, 2022/05/04
- [PULL 07/13] Revert "main-loop: Disable GLOBAL_STATE_CODE() assertions", Kevin Wolf, 2022/05/04
- [PULL 13/13] coroutine-win32: use QEMU_DEFINE_STATIC_CO_TLS(), Kevin Wolf, 2022/05/04
- [PULL 05/13] block: Classify bdrv_get_flags() as I/O function, Kevin Wolf, 2022/05/04
- [PULL 10/13] iotests/reopen-file: Test reopening file child, Kevin Wolf, 2022/05/04
- [PULL 12/13] coroutine: use QEMU_DEFINE_STATIC_CO_TLS(), Kevin Wolf, 2022/05/04
- [PULL 08/13] iotests: Add regression test for issue 945, Kevin Wolf, 2022/05/04
- [PULL 11/13] coroutine-ucontext: use QEMU_DEFINE_STATIC_CO_TLS(), Kevin Wolf, 2022/05/04