All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Vivier <lvivier@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>, qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Kevin Wolf" <kwolf@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	virtio-fs@lists.linux.dev, "Hanna Reitz" <hreitz@redhat.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Milan Zamazal" <mzamazal@redhat.com>,
	"Christian Schoenebeck" <qemu_oss@crudebyte.com>,
	"Dmitry Osipenko" <dmitry.osipenko@collabora.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>,
	"Dorjoy Chowdhury" <dorjoychy111@gmail.com>,
	"Gonglei (Arei)" <arei.gonglei@huawei.com>,
	"Alexander Graf" <graf@amazon.com>,
	"Jason Wang" <jasowangio@gmail.com>,
	"David Hildenbrand" <david@kernel.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Fam Zheng" <fam@euphon.net>,
	"Akihiko Odaki" <odaki@rsg.ci.i.u-tokyo.ac.jp>,
	qemu-block@nongnu.org, "Greg Kurz" <groug@kaod.org>,
	"Raphael Norwitz" <rnorwitz@nvidia.com>,
	"Eric Auger" <eric.auger@redhat.com>,
	"Stefano Garzarella" <sgarzare@redhat.com>,
	"Kuan-Wei Chiu" <visitorckw@gmail.com>,
	"Amit Shah" <amit@kernel.org>
Subject: Re: [PATCH v2 1/2] virtio: make virtio_add_queue() queue_size an unsigned int
Date: Fri, 31 Jul 2026 08:32:40 +0200	[thread overview]
Message-ID: <bb1bb4da-cc0e-4f14-a7a0-eb4252925d0c@redhat.com> (raw)
In-Reply-To: <20260730205846.19479-2-stefanha@redhat.com>

On 7/30/26 22:58, Stefan Hajnoczi wrote:
> virtio_add_queue()'s queue_size argument is a signed int. The
> vdev->vq[i].vring.num and num_default fields are already declared as
> unsigned int, so change the virtio_add_queue() argument's type for
> consistency.
> 
> A note on consistency: the VIRTIO specification defines queue size as an
> unsigned 16-bit value. QEMU's device models variously use uint16_t,
> uint32_t, and other unsigned types for queue size qdev properties.
> virtio_add_queue() limits queue size to the much smaller
> VIRTQUEUE_MAX_SIZE (1024) constant, so the different widths don't really
> matter.
> 
> I have checked that all callers of virtio_add_queue() pass an unsigned
> queue size.
> 
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>   include/hw/virtio/virtio.h | 2 +-
>   hw/virtio/virtio.c         | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Laurent Vivier <lvivier@redhat.com>

> 
> diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
> index c99cb19d886..ff7f837fb92 100644
> --- a/include/hw/virtio/virtio.h
> +++ b/include/hw/virtio/virtio.h
> @@ -302,7 +302,7 @@ void virtio_device_set_child_bus_name(VirtIODevice *vdev, char *bus_name);
>   
>   typedef void (*VirtIOHandleOutput)(VirtIODevice *, VirtQueue *);
>   
> -VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
> +VirtQueue *virtio_add_queue(VirtIODevice *vdev, unsigned int queue_size,
>                               VirtIOHandleOutput handle_output);
>   
>   void virtio_del_queue(VirtIODevice *vdev, int n);
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index daa5607338c..e1210f024c6 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -2564,7 +2564,7 @@ void virtio_queue_set_vector(VirtIODevice *vdev, int n, uint16_t vector)
>       }
>   }
>   
> -VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
> +VirtQueue *virtio_add_queue(VirtIODevice *vdev, unsigned int queue_size,
>                               VirtIOHandleOutput handle_output)
>   {
>       int i;


  reply	other threads:[~2026-07-31  6:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-30 20:58 [PATCH v2 0/2] virtio: fix virtio_add_queue() queue size Coverity issue Stefan Hajnoczi
2026-07-30 20:58 ` [PATCH v2 1/2] virtio: make virtio_add_queue() queue_size an unsigned int Stefan Hajnoczi
2026-07-31  6:32   ` Laurent Vivier [this message]
2026-07-31  8:35   ` Philippe Mathieu-Daudé
2026-07-31  8:38     ` Philippe Mathieu-Daudé
2026-07-31  8:59     ` Peter Maydell
2026-07-30 20:58 ` [PATCH v2 2/2] virtio: use Error for queue size validation in virtio_add_queue() Stefan Hajnoczi
2026-07-31  6:58   ` Laurent Vivier
2026-07-31  8:03   ` Kevin Wolf
2026-07-31  8:58   ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bb1bb4da-cc0e-4f14-a7a0-eb4252925d0c@redhat.com \
    --to=lvivier@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=amit@kernel.org \
    --cc=arei.gonglei@huawei.com \
    --cc=david@kernel.org \
    --cc=dmitry.osipenko@collabora.com \
    --cc=dorjoychy111@gmail.com \
    --cc=eric.auger@redhat.com \
    --cc=fam@euphon.net \
    --cc=graf@amazon.com \
    --cc=groug@kaod.org \
    --cc=hreitz@redhat.com \
    --cc=jasowangio@gmail.com \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=manos.pitsidianakis@linaro.org \
    --cc=marcandre.lureau@redhat.com \
    --cc=mst@redhat.com \
    --cc=mzamazal@redhat.com \
    --cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu_oss@crudebyte.com \
    --cc=rnorwitz@nvidia.com \
    --cc=sgarzare@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=virtio-fs@lists.linux.dev \
    --cc=visitorckw@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.