From: Albert Esteve Date: Tue, 22 Oct 2024 12:46:14 +0000 (+0200) Subject: vhost-user: fix shared object return values X-Git-Tag: v8.2.9~19 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=027cc19383a7afddcac56492b1bffc69e5d7f060;p=thirdparty%2Fqemu.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: 043e127a126bb3ceb5fc753deee27d261fd0c5ce Fixes: 160947666276c5b7f6bca4d746bcac2966635d79 Reviewed-by: Stefano Garzarella Signed-off-by: Albert Esteve Message-Id: <20241022124615.585596-1-aesteve@redhat.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit eea5aeef84e1b74f515b474d3a86377701f93750) Signed-off-by: Michael Tokarev (Mjt: remove changes fixing v8.2.0-2279-g043e127a126b "hw/virtio: check owner for removing objects") --- diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index f214df804b2..7db79818412 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -1607,16 +1607,21 @@ 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(VhostUserShared *object) { QemuUUID uuid; memcpy(uuid.data, object->uuid, sizeof(object->uuid)); - return virtio_remove_resource(&uuid); + return !virtio_remove_resource(&uuid); } static bool vhost_user_send_resp(QIOChannel *ioc, VhostUserHeader *hdr,