From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202508 header.b=otjVA2Zb; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 88F225A027C for ; Mon, 08 Sep 2025 04:00:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202508; t=1757296826; bh=ULztXPOEyQNbBMFNtcAu3BaQh9s5piTSM68rmERF7xU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=otjVA2ZbIcyRZ7dFC6YplL4PTzCHJ4tF+mgaxuCzfJI//vwFm0IhXjVeXjSjCHtxk NUpIUtQrEsHe8cT0bfW1v7vLsXwCjfYOFTLvCyB12Ccyr1tyhOIh72djQ5cBPZ2jkh 5IoRJPezjTNuv0JqaY5uHw4ShGSofGkt7QVA7h204PnISAbfMFqDAszvGmGj+d7llj fj0i8MvY2sSt9aXo3qUP+OGg1/6HTAcJcZ+yv4dGo2niY/r3Pz5uHLbvOxHduY6M+M e/g29KqH1xpv+oWIHo7w4ZyO3K+S5EhI43TJO6ovZTgyaEfkMkCCF1H0/T6sbBTbCp DBs1YkMnI8fgA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4cKqsk25cDz4wBH; Mon, 8 Sep 2025 12:00:26 +1000 (AEST) Date: Mon, 8 Sep 2025 11:58:42 +1000 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH 1/3] vhost-user: Fix VHOST_USER_GET_QUEUE_NUM to return number of queues Message-ID: References: <20250905154935.389634-1-lvivier@redhat.com> <20250905154935.389634-2-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="mk6JM0fIffxU/M5a" Content-Disposition: inline In-Reply-To: <20250905154935.389634-2-lvivier@redhat.com> Message-ID-Hash: SFDUFLOCCWVHWN4XYA2YYT6EZN3GV56K X-Message-ID-Hash: SFDUFLOCCWVHWN4XYA2YYT6EZN3GV56K X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --mk6JM0fIffxU/M5a Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Sep 05, 2025 at 05:49:33PM +0200, Laurent Vivier wrote: > The vhost-user specification states that VHOST_USER_GET_QUEUE_NUM should > return the maximum number of queues supported by the back-end, not the > number of virtqueues. Since each queue pair consists of RX and TX > virtqueues, we need to divide VHOST_USER_MAX_QUEUES by 2 to get the > correct queue count. >=20 > Also rename VHOST_USER_MAX_QUEUES to VHOST_USER_MAX_VQS throughout the > codebase to better reflect that it represents the maximum number of > virtqueues, not queue pairs. >=20 > Signed-off-by: Laurent Vivier Reviewed-by: David Gibson > --- > vhost_user.c | 16 +++++++++------- > virtio.h | 4 ++-- > 2 files changed, 11 insertions(+), 9 deletions(-) >=20 > diff --git a/vhost_user.c b/vhost_user.c > index f97ec6064cac..fa343a86fac2 100644 > --- a/vhost_user.c > +++ b/vhost_user.c > @@ -345,7 +345,7 @@ static void vu_set_enable_all_rings(struct vu_dev *vd= ev, bool enable) > { > uint16_t i; > =20 > - for (i =3D 0; i < VHOST_USER_MAX_QUEUES; i++) > + for (i =3D 0; i < VHOST_USER_MAX_VQS; i++) > vdev->vq[i].enable =3D enable; > } > =20 > @@ -477,7 +477,7 @@ static bool vu_set_mem_table_exec(struct vu_dev *vdev, > close(vmsg->fds[i]); > } > =20 > - for (i =3D 0; i < VHOST_USER_MAX_QUEUES; i++) { > + for (i =3D 0; i < VHOST_USER_MAX_VQS; i++) { > if (vdev->vq[i].vring.desc) { > if (map_ring(vdev, &vdev->vq[i])) > die("remapping queue %d during setmemtable", i); > @@ -770,7 +770,7 @@ static void vu_check_queue_msg_file(struct vhost_user= _msg *vmsg) > bool nofd =3D vmsg->payload.u64 & VHOST_USER_VRING_NOFD_MASK; > int idx =3D vmsg->payload.u64 & VHOST_USER_VRING_IDX_MASK; > =20 > - if (idx >=3D VHOST_USER_MAX_QUEUES) > + if (idx >=3D VHOST_USER_MAX_VQS) > die("Invalid vhost-user queue index: %u", idx); > =20 > if (nofd) { > @@ -939,7 +939,9 @@ static bool vu_get_queue_num_exec(struct vu_dev *vdev, > { > (void)vdev; > =20 > - vmsg_set_reply_u64(vmsg, VHOST_USER_MAX_QUEUES); > + vmsg_set_reply_u64(vmsg, VHOST_USER_MAX_VQS / 2); > + > + debug("VHOST_USER_MAX_VQS %u", VHOST_USER_MAX_VQS / 2); > =20 > return true; > } > @@ -960,7 +962,7 @@ static bool vu_set_vring_enable_exec(struct vu_dev *v= dev, > debug("State.index: %u", idx); > debug("State.enable: %u", enable); > =20 > - if (idx >=3D VHOST_USER_MAX_QUEUES) > + if (idx >=3D VHOST_USER_MAX_VQS) > die("Invalid vring_enable index: %u", idx); > =20 > vdev->vq[idx].enable =3D enable; > @@ -1052,7 +1054,7 @@ void vu_init(struct ctx *c) > =20 > c->vdev =3D &vdev_storage; > c->vdev->context =3D c; > - for (i =3D 0; i < VHOST_USER_MAX_QUEUES; i++) { > + for (i =3D 0; i < VHOST_USER_MAX_VQS; i++) { > c->vdev->vq[i] =3D (struct vu_virtq){ > .call_fd =3D -1, > .kick_fd =3D -1, > @@ -1075,7 +1077,7 @@ void vu_cleanup(struct vu_dev *vdev) > { > unsigned int i; > =20 > - for (i =3D 0; i < VHOST_USER_MAX_QUEUES; i++) { > + for (i =3D 0; i < VHOST_USER_MAX_VQS; i++) { > struct vu_virtq *vq =3D &vdev->vq[i]; > =20 > vq->started =3D false; > diff --git a/virtio.h b/virtio.h > index b55cc4042521..12caaa0b6def 100644 > --- a/virtio.h > +++ b/virtio.h > @@ -88,7 +88,7 @@ struct vu_dev_region { > uint64_t mmap_addr; > }; > =20 > -#define VHOST_USER_MAX_QUEUES 2 > +#define VHOST_USER_MAX_VQS 2 > =20 > /* > * Set a reasonable maximum number of ram slots, which will be supported= by > @@ -121,7 +121,7 @@ struct vdev_memory { > struct vu_dev { > struct ctx *context; > struct vdev_memory memory; > - struct vu_virtq vq[VHOST_USER_MAX_QUEUES]; > + struct vu_virtq vq[VHOST_USER_MAX_VQS]; > uint64_t features; > uint64_t protocol_features; > int log_call_fd; > --=20 > 2.50.1 >=20 --=20 David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson --mk6JM0fIffxU/M5a Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmi+OFEACgkQzQJF27ox 2GemkA//dS21T4h8/I0R7dzM5iYqNvbX2xWApVP57HeK7Z44SQhCaFG9uS81k73Q S9GRWbgGasJ2cCc1TdyXfI5mBaZIUfqgL1gfksdPnH0AnnVgxFrZItTRlss9Lhl5 dvziW/g5yBb/x+X1lc15CVfJSkCnqi6fACXCqMZCvBnBS2001YcR8pDvF3r0x9YC 02fPNO6DcqgnYQXW+Z9BcmNpIn18lXXUx7qJ9m3jTznXAufn4IC1xbJao/mDMEeF eL/SQiz7oWgMFzf6GL5IdbxA244mZoM2xZRgZ7sIjJ9FeotW7vAmFGL1V5SmDb0V 9xVd//qUvJYubeLKSbFyBsmxYTS9pjwt05YU0kKZbH4tHeiszkEwMuxhBZnNitTn QD/G+nm0j8vk87gJ5A+opeOSN7zXrdl9qaNVeYDILchRFtvJOmlwyOZ3emFcxeyf 6jHI98YHqqlze8/G1VwTDp4OWy9djtxJeUA64NzTwASdo5psbBol9fDmqfYvGQNc iW38Twv3WTkaXMfGLvNnrWpLUyhK6Rety6foHJk2aIsaCFpc5jztkiEB9kfZ86Pd qYMiQtZT/BcAs7CRK4YDTU2MF9OGbBAFLKS89SRzGKeI6H4lzoBpYQWVwmOcrNrx 8kjbjscaszj1EWHMt29ihk3Eqa9u1n+9BqSoEibQxaDSD9dlhSc= =B6zQ -----END PGP SIGNATURE----- --mk6JM0fIffxU/M5a--