mirror of https://github.com/xemu-project/xemu.git
vhost-user: fix shared object return values
VHOST_USER_BACKEND_SHARED_OBJECT_ADD and VHOST_USER_BACKEND_SHARED_OBJECT_REMOVE state in the spec that they return 0 for successful operations, non-zero otherwise. However, implementation relies on the return types of the virtio-dmabuf library, with opposite semantics (true if everything is correct, false otherwise). Therefore, current implementation violates the specification. Revert the logic so that the implementation of the vhost-user handling methods matches the specification. Fixes:043e127a12
Fixes:1609476662
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> Signed-off-by: Albert Esteve <aesteve@redhat.com> Message-Id: <20241022124615.585596-1-aesteve@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
d4d5212c54
commit
eea5aeef84
|
@ -1623,9 +1623,14 @@ vhost_user_backend_handle_shared_object_add(struct vhost_dev *dev,
|
|||
QemuUUID uuid;
|
||||
|
||||
memcpy(uuid.data, object->uuid, sizeof(object->uuid));
|
||||
return virtio_add_vhost_device(&uuid, dev);
|
||||
return !virtio_add_vhost_device(&uuid, dev);
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle VHOST_USER_BACKEND_SHARED_OBJECT_REMOVE backend requests.
|
||||
*
|
||||
* Return: 0 on success, 1 on error.
|
||||
*/
|
||||
static int
|
||||
vhost_user_backend_handle_shared_object_remove(struct vhost_dev *dev,
|
||||
VhostUserShared *object)
|
||||
|
@ -1639,16 +1644,16 @@ vhost_user_backend_handle_shared_object_remove(struct vhost_dev *dev,
|
|||
struct vhost_dev *owner = virtio_lookup_vhost_device(&uuid);
|
||||
if (dev != owner) {
|
||||
/* Not allowed to remove non-owned entries */
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
/* Not allowed to remove non-owned entries */
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return virtio_remove_resource(&uuid);
|
||||
return !virtio_remove_resource(&uuid);
|
||||
}
|
||||
|
||||
static bool vhost_user_send_resp(QIOChannel *ioc, VhostUserHeader *hdr,
|
||||
|
|
Loading…
Reference in New Issue