vhost-user: Don't pass file descriptor for VHOST_USER_REM_MEM_REG
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>
This commit is contained in:
parent
5ebfdeb212
commit
a81d8d4a72
@ -751,7 +751,7 @@ static int send_remove_regions(struct vhost_dev *dev,
|
|||||||
vhost_user_fill_msg_region(®ion_buffer, shadow_reg, 0);
|
vhost_user_fill_msg_region(®ion_buffer, shadow_reg, 0);
|
||||||
msg->payload.mem_reg.region = region_buffer;
|
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) {
|
if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -822,15 +822,15 @@ vu_rem_mem_reg(VuDev *dev, VhostUserMsg *vmsg) {
|
|||||||
int i;
|
int i;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
if (vmsg->fd_num != 1) {
|
if (vmsg->fd_num > 1) {
|
||||||
vmsg_close_fds(vmsg);
|
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);
|
"should be sent for this message type", vmsg->fd_num);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vmsg->size < VHOST_USER_MEM_REG_SIZE) {
|
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 "
|
vu_panic(dev, "VHOST_USER_REM_MEM_REG requires a message size of at "
|
||||||
"least %d bytes and only %d bytes were received",
|
"least %d bytes and only %d bytes were received",
|
||||||
VHOST_USER_MEM_REG_SIZE, vmsg->size);
|
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");
|
vu_panic(dev, "Specified region not found\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
close(vmsg->fds[0]);
|
vmsg_close_fds(vmsg);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user