[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 42/65] vhost-user: fix shared object return values
From: |
Michael S. Tsirkin |
Subject: |
[PULL 42/65] vhost-user: fix shared object return values |
Date: |
Mon, 4 Nov 2024 16:08:20 -0500 |
From: Albert Esteve <aesteve@redhat.com>
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 <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>
---
hw/virtio/vhost-user.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index d1b0893b4d..f170f0b25b 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -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,
--
MST
- Re: [PULL 32/65] amd_iommu: Check APIC ID > 255 for XTSup, (continued)
- [PULL 34/65] virtio/vhost-user: fix qemu abort when hotunplug vhost-user-net device, Michael S. Tsirkin, 2024/11/04
- [PULL 33/65] virtio-pci: fix memory_region_find for VirtIOPCIRegion's MR, Michael S. Tsirkin, 2024/11/04
- [PULL 35/65] hw/cxl: Fix uint32 overflow cxl-mailbox-utils.c, Michael S. Tsirkin, 2024/11/04
- [PULL 37/65] mem/cxl_type3: Fix overlapping region validation error, Michael S. Tsirkin, 2024/11/04
- [PULL 38/65] hw/mem/cxl_type3: Fix More flag setting for dynamic capacity event records, Michael S. Tsirkin, 2024/11/04
- [PULL 39/65] hw/cxl/cxl-mailbox-utils: Fix for device DDR5 ECS control feature tables, Michael S. Tsirkin, 2024/11/04
- [PULL 40/65] hw/cxl: Fix indent of structure member, Michael S. Tsirkin, 2024/11/04
- [PULL 36/65] hw/cxl: Fix background completion percentage calculation, Michael S. Tsirkin, 2024/11/04
- [PULL 41/65] hw/pci-bridge: Make pxb_dev_realize_common() return if it succeeded, Michael S. Tsirkin, 2024/11/04
- [PULL 42/65] vhost-user: fix shared object return values,
Michael S. Tsirkin <=
- [PULL 44/65] pcie: enable Extended tag field support, Michael S. Tsirkin, 2024/11/04
- [PULL 45/65] cxl/cxl-mailbox-utils: Fix size check for cmd_firmware_update_get_info, Michael S. Tsirkin, 2024/11/04
- [PULL 46/65] hw/cxl/cxl-mailbox-util: Fix output buffer index update when retrieving DC extents, Michael S. Tsirkin, 2024/11/04
- [PULL 47/65] hw/cxl: Check size of input data to dynamic capacity mailbox commands, Michael S. Tsirkin, 2024/11/04
- [PULL 48/65] hw/cxl: Check input includes at least the header in cmd_features_set_feature(), Michael S. Tsirkin, 2024/11/04
- [PULL 49/65] hw/cxl: Check input length is large enough in cmd_events_clear_records(), Michael S. Tsirkin, 2024/11/04
- [PULL 50/65] hw/cxl: Check enough data in cmd_firmware_update_transfer(), Michael S. Tsirkin, 2024/11/04
- [PULL 53/65] hw/cxl: Ensuring enough data to read parameters in cmd_tunnel_management_cmd(), Michael S. Tsirkin, 2024/11/04
- [PULL 54/65] hw/cxl: Check that writes do not go beyond end of target attributes, Michael S. Tsirkin, 2024/11/04
- [PULL 55/65] hw/cxl: Ensure there is enough data for the header in cmd_ccls_set_lsa(), Michael S. Tsirkin, 2024/11/04