All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Hanna Czenczek <hreitz@redhat.com>
Cc: "Connor Kite" <connorkite@gmail.com>,
	qemu-devel@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>,
	"Stefano Garzarella" <sgarzare@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Viresh Kumar" <viresh.kumar@linaro.org>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Mathieu Poirier" <mathieu.poirier@linaro.org>,
	"Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>,
	"Haixu Cui" <quic_haixcui@quicinc.com>,
	"Raphael Norwitz" <rnorwitz@nvidia.com>,
	"Kevin Wolf" <kwolf@redhat.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Fam Zheng" <fam@euphon.net>,
	"Milan Zamazal" <mzamazal@redhat.com>,
	"Akihiko Odaki" <odaki@rsg.ci.i.u-tokyo.ac.jp>,
	"Dmitry Osipenko" <dmitry.osipenko@collabora.com>,
	qemu-block@nongnu.org, virtio-fs@lists.linux.dev,
	"Gonglei (Arei)" <arei.gonglei@huawei.com>,
	"zhenwei pi" <zhenwei.pi@linux.dev>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Eric Blake" <eblake@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Jason Wang" <jasowangio@gmail.com>,
	"Peter Xu" <peterx@redhat.com>,
	"Eugenio Pérez" <eperezma@redhat.com>,
	"Alyssa Ross" <hi@alyssa.is>,
	"Demi Marie Obenour" <demiobenour@gmail.com>
Subject: Re: [PATCH RFC 11/15] hw/virtio/vhost-user: create isolation region
Date: Tue, 4 Aug 2026 14:23:40 -0400	[thread overview]
Message-ID: <20260804182340.GC488200@fedora> (raw)
In-Reply-To: <b6bc052c-1bf5-449b-85d0-e1c4624a5d99@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1156 bytes --]

On Mon, Aug 03, 2026 at 03:25:19PM +0200, Hanna Czenczek wrote:
> > +    for (int i = 0; i < buffer_regions->len; i++) {
> > +        map = &g_array_index(buffer_regions, DMAMap, i);
> 
> God, I *really*, *really* hate this, and find it really disgusting that the
> documentation actually recommends doing this (`&g_array_index()`) instead of
> just offering a separate macro to get a reference.
> 
> And existing qemu code does it all over the place, too.
> 
> So I cannot really fault you for it.
> 
> Still. Too ugly for me to keep completely silent about it.
> 
> </rant>

Do we need GArray here, maybe just allocate a C array with g_new()
instead?

The reason I didn't say anything was because I expected GArray to
perform bounds checking. Plain C arrays don't offer that. After reading
your comment and looking at the glib source, I realized it does not.
There is no way to handle an error and glib does not abort() when the
index is invalid.

GArray still has the advantage of allowing elements to be added
dynamically, but in this case we know the number of elements ahead of
time and don't need that feature.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  parent reply	other threads:[~2026-08-04 18:23 UTC|newest]

Thread overview: 96+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-23 22:29 [PATCH RFC 00/15] vhost-user: isolated memory ConKite
2026-07-23 22:30 ` [PATCH RFC 01/15] vhost-user: Consolidate chardev property definitions ConKite
2026-07-24  6:09   ` Markus Armbruster
2026-07-23 22:30 ` [PATCH RFC 02/15] vhost-user: Add memory-isolation qdev property to vhost-user devices ConKite
2026-07-24 10:56   ` Akihiko Odaki
2026-07-28 18:30     ` Connor Kite
2026-08-03 12:21   ` Hanna Czenczek
2026-08-03 20:32     ` Connor Kite
2026-08-04 10:46       ` Hanna Czenczek
2026-08-06  4:28         ` Connor Kite
2026-07-23 22:30 ` [PATCH RFC 03/15] backends/cryptodev-vhost-user: add memory isolation bool Connor Kite
2026-07-24  6:06   ` Markus Armbruster
2026-07-27 18:43     ` Stefan Hajnoczi
2026-07-28  5:26       ` Connor Kite
2026-07-24 11:03   ` Akihiko Odaki
2026-07-23 22:30 ` [PATCH RFC 04/15] net/vhost-user: add memory isolation Connor Kite
2026-07-27 18:48   ` Stefan Hajnoczi
2026-08-03 12:27   ` Hanna Czenczek
2026-08-05 23:43     ` Connor Kite
2026-07-23 22:30 ` [PATCH RFC 05/15] vhost-user: add memory_isolation to VhostUserState Connor Kite
2026-07-24 11:09   ` Akihiko Odaki
2026-07-27 19:06   ` Stefan Hajnoczi
2026-07-30 21:28     ` Connor Kite
2026-08-03 12:29   ` Hanna Czenczek
2026-08-05 23:45     ` Connor Kite
2026-07-23 22:30 ` [PATCH RFC 06/15] util/iova-tree: g_tree_foreach wrapper Connor Kite
2026-07-27 19:07   ` Stefan Hajnoczi
2026-07-28 18:24     ` Connor Kite
2026-08-03 12:36   ` Hanna Czenczek
2026-08-03 21:13     ` Connor Kite
2026-08-04 11:04       ` Hanna Czenczek
2026-07-23 22:30 ` [PATCH RFC 07/15] hw/virtio: iova_tree_foreach wrapper Connor Kite
2026-07-24 11:14   ` Akihiko Odaki
2026-07-31  0:51     ` Connor Kite
2026-07-23 22:30 ` [PATCH RFC 08/15] hw/virtio/vhost-shadow-virtqueue: used handler Connor Kite
2026-07-24 11:29   ` Akihiko Odaki
2026-07-28 15:06   ` Stefan Hajnoczi
2026-08-03 12:41   ` Hanna Czenczek
2026-08-06  2:50     ` Connor Kite
2026-08-06 10:28       ` Hanna Czenczek
2026-08-06 15:05         ` Connor Kite
2026-07-23 22:30 ` [PATCH RFC 09/15] hw/virtio/vhost-shadow-virtqueue: specified vring placement Connor Kite
2026-07-24 12:19   ` Akihiko Odaki
2026-08-06 15:29     ` Connor Kite
2026-08-06 15:56       ` Akihiko Odaki
2026-07-28 15:23   ` Stefan Hajnoczi
2026-08-07 19:49     ` Connor Kite
2026-08-03 12:48   ` Hanna Czenczek
2026-08-07 19:49     ` Connor Kite
2026-07-23 22:30 ` [PATCH RFC 10/15] hw/virtio/vhost-shadow-virtqueue: range boundary in translation Connor Kite
2026-07-24 12:31   ` Akihiko Odaki
2026-07-28 15:34   ` Stefan Hajnoczi
2026-08-03 12:56   ` Hanna Czenczek
2026-08-08  5:52     ` Connor Kite
2026-08-11 11:04       ` Hanna Czenczek
2026-07-23 22:30 ` [PATCH RFC 11/15] hw/virtio/vhost-user: create isolation region Connor Kite
2026-07-24 12:53   ` Akihiko Odaki
2026-08-03  1:28     ` Connor Kite
2026-07-28 17:59   ` Stefan Hajnoczi
2026-08-03 18:26     ` Connor Kite
2026-08-04 18:16       ` Stefan Hajnoczi
2026-08-09  1:12         ` Connor Kite
2026-08-03 13:25   ` Hanna Czenczek
2026-08-03 19:31     ` Connor Kite
2026-08-04 11:03       ` Hanna Czenczek
2026-08-09  0:36         ` Connor Kite
2026-08-04 18:23     ` Stefan Hajnoczi [this message]
2026-07-23 22:30 ` [PATCH RFC 12/15] hw/virtio/vhost-user: send isolation regions to device Connor Kite
2026-07-24 13:33   ` Akihiko Odaki
2026-08-10 17:40     ` Connor Kite
2026-08-10 21:12       ` Connor Kite
2026-07-28 19:16   ` Stefan Hajnoczi
2026-08-10 18:34     ` Connor Kite
2026-08-03 13:46   ` Hanna Czenczek
2026-08-10 22:16     ` Connor Kite
2026-07-23 22:30 ` [PATCH RFC 13/15] hw/virtio/vhost-user: add shadow virtqueues and eventfd intercepts Connor Kite
2026-07-24 13:45   ` Akihiko Odaki
2026-08-10 23:54     ` Connor Kite
2026-07-28 19:41   ` Stefan Hajnoczi
2026-08-11  1:39     ` Connor Kite
2026-08-03 13:52   ` Hanna Czenczek
2026-08-11  2:32     ` Connor Kite
2026-08-11 11:42       ` Hanna Czenczek
2026-07-23 22:30 ` [PATCH RFC 14/15] hw/virtio/vhost-user: handle data movement with shadow vqs Connor Kite
2026-07-24 15:20   ` Akihiko Odaki
2026-08-11  6:28     ` Connor Kite
2026-07-28 20:57   ` Stefan Hajnoczi
2026-08-11  6:28     ` Connor Kite
2026-08-03 14:10   ` Hanna Czenczek
2026-07-23 22:30 ` [PATCH RFC 15/15] hw/virtio/vhost-user: shadow vq cleanup Connor Kite
2026-07-24 15:22   ` Akihiko Odaki
2026-07-25  0:15 ` [PATCH RFC 00/15] vhost-user: isolated memory Demi Marie Obenour
2026-07-25  3:45 ` Akihiko Odaki
2026-07-27 18:23   ` Stefan Hajnoczi
2026-07-28  7:07 ` Demi Marie Obenour
2026-07-28 14:50   ` Connor Kite

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=20260804182340.GC488200@fedora \
    --to=stefanha@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=arei.gonglei@huawei.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=connorkite@gmail.com \
    --cc=demiobenour@gmail.com \
    --cc=dmitry.osipenko@collabora.com \
    --cc=eblake@redhat.com \
    --cc=eperezma@redhat.com \
    --cc=fam@euphon.net \
    --cc=hi@alyssa.is \
    --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=mathieu.poirier@linaro.org \
    --cc=mst@redhat.com \
    --cc=mzamazal@redhat.com \
    --cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=quic_haixcui@quicinc.com \
    --cc=rnorwitz@nvidia.com \
    --cc=sgarzare@redhat.com \
    --cc=viresh.kumar@linaro.org \
    --cc=virtio-fs@lists.linux.dev \
    --cc=zhenwei.pi@linux.dev \
    /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.