From nobody Mon Feb 9 08:29:12 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1612897592; cv=none; d=zohomail.com; s=zohoarc; b=Eb3xB5dfjVHaey8j5LQ3/yb96pqpra99thUMcYBf8I1p5N48Ko03xd9j+xl653dW6nC0prL3Pv19XJb9P0zzqWGR3ncKh7sPTih3+B0lqcRqRxGM1B7qhfFAvQEVnQsQ/rjKjo0PMo13u6fglnX6pf099OP/KFUUfFLag8oDjXg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612897592; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=q8pEUQ5FwlT0wragKtjYtr65kguSGvb6UgV7rba+aMM=; b=UbgvnibBPBSYS+/Ej3iLq0dKrX6WJPwao7MPp3qAtLTOA6IHproruXxVVLF3wIYQGU6P7sqPRhNdrCi6pEMFFPB4dzTkJ37zgQTlW0ZIt3zK8DsIikSvTxMxo277ROnyY1C5W25u5XIefN6+aH0dED70WAE4i4ehStW9pI7FZ84= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1612897592329973.7557063129531; Tue, 9 Feb 2021 11:06:32 -0800 (PST) Received: from localhost ([::1]:47312 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9YLG-0003SS-Dt for importer@patchew.org; Tue, 09 Feb 2021 14:06:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51330) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9YHl-0001jz-V4 for qemu-devel@nongnu.org; Tue, 09 Feb 2021 14:02:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:57532) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l9YHi-0001ZV-Bg for qemu-devel@nongnu.org; Tue, 09 Feb 2021 14:02:53 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-475-n8pSb7C0NH6sVg1fx-2eUA-1; Tue, 09 Feb 2021 14:02:45 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A02FE801976 for ; Tue, 9 Feb 2021 19:02:44 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-112-66.ams2.redhat.com [10.36.112.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0650360C04; Tue, 9 Feb 2021 19:02:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612897367; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q8pEUQ5FwlT0wragKtjYtr65kguSGvb6UgV7rba+aMM=; b=OYER9qPSdYxeEJRcgWi/YsGPKdFA1wTlevwRXcOomtDPbiieoLO6fdk/e1svcxMr86R7fA X139Lea4ujlxL8yzLOOTzMLiu9qbvwj2eiaED94IrIS0S1ugmgNgJYwYUX1Z7NW7J33rwX xPenPMYQn5WqU+QsB4ueXbVj98qNhA4= X-MC-Unique: n8pSb7C0NH6sVg1fx-2eUA-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, vgoyal@redhat.com, stefanha@redhat.com, virtio-fs@redhat.com, marcandre.lureau@redhat.com, mst@redhat.com Subject: [PATCH 01/24] DAX: vhost-user: Rework slave return values Date: Tue, 9 Feb 2021 19:02:01 +0000 Message-Id: <20210209190224.62827-2-dgilbert@redhat.com> In-Reply-To: <20210209190224.62827-1-dgilbert@redhat.com> References: <20210209190224.62827-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.57, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" All the current slave handlers on the qemu side generate an 'int' return value that's squashed down to a bool (!!ret) and stuffed into a uint64_t (field of a union) to be returned. Move the uint64_t type back up through the individual handlers so that we can mkae one actually return a full uint64_t. Note that the definition in the interop spec says most of these cases are defined as returning 0 on success and non-0 for failure, so it's OK to change from a bool to another non-0. Vivek: This is needed because upcoming patches in series will add new functions which want to return full error code. Existing functions continue to return true/false so, it should not lead to change of behavior for existing users. Signed-off-by: Dr. David Alan Gilbert --- hw/virtio/vhost-backend.c | 4 ++-- hw/virtio/vhost-user.c | 32 ++++++++++++++++--------------- include/hw/virtio/vhost-backend.h | 2 +- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c index 31b33bde37..21082084ea 100644 --- a/hw/virtio/vhost-backend.c +++ b/hw/virtio/vhost-backend.c @@ -401,7 +401,7 @@ int vhost_backend_invalidate_device_iotlb(struct vhost_= dev *dev, return -ENODEV; } =20 -int vhost_backend_handle_iotlb_msg(struct vhost_dev *dev, +uint64_t vhost_backend_handle_iotlb_msg(struct vhost_dev *dev, struct vhost_iotlb_msg *imsg) { int ret =3D 0; @@ -429,5 +429,5 @@ int vhost_backend_handle_iotlb_msg(struct vhost_dev *de= v, break; } =20 - return ret; + return !!ret; } diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 2fdd5daf74..13789cc55e 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -1317,24 +1317,25 @@ static int vhost_user_reset_device(struct vhost_dev= *dev) return 0; } =20 -static int vhost_user_slave_handle_config_change(struct vhost_dev *dev) +static uint64_t vhost_user_slave_handle_config_change(struct vhost_dev *de= v) { int ret =3D -1; =20 if (!dev->config_ops) { - return -1; + return true; } =20 if (dev->config_ops->vhost_dev_config_notifier) { ret =3D dev->config_ops->vhost_dev_config_notifier(dev); } =20 - return ret; + return !!ret; } =20 -static int vhost_user_slave_handle_vring_host_notifier(struct vhost_dev *d= ev, - VhostUserVringArea = *area, - int fd) +static uint64_t vhost_user_slave_handle_vring_host_notifier( + struct vhost_dev *dev, + VhostUserVringArea *area, + int fd) { int queue_idx =3D area->u64 & VHOST_USER_VRING_IDX_MASK; size_t page_size =3D qemu_real_host_page_size; @@ -1348,7 +1349,7 @@ static int vhost_user_slave_handle_vring_host_notifie= r(struct vhost_dev *dev, if (!virtio_has_feature(dev->protocol_features, VHOST_USER_PROTOCOL_F_HOST_NOTIFIER) || vdev =3D=3D NULL || queue_idx >=3D virtio_get_num_queues(vdev)) { - return -1; + return true; } =20 n =3D &user->notifier[queue_idx]; @@ -1361,18 +1362,18 @@ static int vhost_user_slave_handle_vring_host_notif= ier(struct vhost_dev *dev, } =20 if (area->u64 & VHOST_USER_VRING_NOFD_MASK) { - return 0; + return false; } =20 /* Sanity check. */ if (area->size !=3D page_size) { - return -1; + return true; } =20 addr =3D mmap(NULL, page_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, area->offset); if (addr =3D=3D MAP_FAILED) { - return -1; + return true; } =20 name =3D g_strdup_printf("vhost-user/host-notifier@%p mmaps[%d]", @@ -1383,13 +1384,13 @@ static int vhost_user_slave_handle_vring_host_notif= ier(struct vhost_dev *dev, =20 if (virtio_queue_set_host_notifier_mr(vdev, queue_idx, &n->mr, true)) { munmap(addr, page_size); - return -1; + return true; } =20 n->addr =3D addr; n->set =3D true; =20 - return 0; + return false; } =20 static void slave_read(void *opaque) @@ -1398,7 +1399,8 @@ static void slave_read(void *opaque) struct vhost_user *u =3D dev->opaque; VhostUserHeader hdr =3D { 0, }; VhostUserPayload payload =3D { 0, }; - int size, ret =3D 0; + int size; + uint64_t ret =3D 0; struct iovec iov; struct msghdr msgh; int fd[VHOST_USER_SLAVE_MAX_FDS]; @@ -1472,7 +1474,7 @@ static void slave_read(void *opaque) break; default: error_report("Received unexpected msg type: %d.", hdr.request); - ret =3D -EINVAL; + ret =3D (uint64_t)-EINVAL; } =20 /* Close the remaining file descriptors. */ @@ -1493,7 +1495,7 @@ static void slave_read(void *opaque) hdr.flags &=3D ~VHOST_USER_NEED_REPLY_MASK; hdr.flags |=3D VHOST_USER_REPLY_MASK; =20 - payload.u64 =3D !!ret; + payload.u64 =3D ret; hdr.size =3D sizeof(payload.u64); =20 iovec[0].iov_base =3D &hdr; diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-ba= ckend.h index 8a6f8e2a7a..64ac6b6444 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -186,7 +186,7 @@ int vhost_backend_update_device_iotlb(struct vhost_dev = *dev, int vhost_backend_invalidate_device_iotlb(struct vhost_dev *dev, uint64_t iova, uint64_t l= en); =20 -int vhost_backend_handle_iotlb_msg(struct vhost_dev *dev, +uint64_t vhost_backend_handle_iotlb_msg(struct vhost_dev *dev, struct vhost_iotlb_msg *imsg); =20 int vhost_user_gpu_set_socket(struct vhost_dev *dev, int fd); --=20 2.29.2