From: Aaron Lo <aaronlo0929@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
David Hildenbrand <david@kernel.org>,
qemu-trivial@nongnu.org, Aaron Lo <aaronlo0929@gmail.com>
Subject: [PATCH] virtio-balloon: only create statsq when VIRTIO_BALLOON_F_STATS_VQ exists
Date: Thu, 11 Dec 2025 03:05:49 -0600 [thread overview]
Message-ID: <20251211-balloon-check-stats-feature-v1-1-ae8951957b80@gmail.com> (raw)
The VirtIO specification (section 5.5.2) states that the stats queue
is only present if the VIRTIO_BALLOON_F_STATS_VQ feature is
negotiated. QEMU currently creates the statsq unconditionally.
This patch guards statsq creation so it occurs only when the
feature bit is enabled.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3188
Signed-off-by: Aaron Lo <aaronlo0929@gmail.com>
---
hw/virtio/virtio-balloon.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index 02cdd807d7..f5d4d5f60c 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -892,7 +892,10 @@ static void virtio_balloon_device_realize(DeviceState *dev, Error **errp)
s->ivq = virtio_add_queue(vdev, 128, virtio_balloon_handle_output);
s->dvq = virtio_add_queue(vdev, 128, virtio_balloon_handle_output);
- s->svq = virtio_add_queue(vdev, 128, virtio_balloon_receive_stats);
+
+ if (virtio_has_feature(s->host_features, VIRTIO_BALLOON_F_STATS_VQ)) {
+ s->svq = virtio_add_queue(vdev, 128, virtio_balloon_receive_stats);
+ }
if (virtio_has_feature(s->host_features, VIRTIO_BALLOON_F_FREE_PAGE_HINT)) {
s->free_page_vq = virtio_add_queue(vdev, VIRTQUEUE_MAX_SIZE,
@@ -932,7 +935,9 @@ static void virtio_balloon_device_unrealize(DeviceState *dev)
virtio_delete_queue(s->ivq);
virtio_delete_queue(s->dvq);
- virtio_delete_queue(s->svq);
+ if (s->svq) {
+ virtio_delete_queue(s->svq);
+ }
if (s->free_page_vq) {
virtio_delete_queue(s->free_page_vq);
}
---
base-commit: 9c23f2a7b0b45277693a14074b1aaa827eecdb92
change-id: 20251211-balloon-check-stats-feature-7ea658e038ce
Best regards,
--
Aaron Lo <aaronlo0929@gmail.com>
next reply other threads:[~2025-12-11 14:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-11 9:05 Aaron Lo [this message]
2025-12-11 13:14 ` [PATCH] virtio-balloon: only create statsq when VIRTIO_BALLOON_F_STATS_VQ exists Michael S. Tsirkin
2025-12-11 14:22 ` Daniel P. Berrangé
2025-12-11 20:15 ` Aaron Lo
2025-12-11 22:18 ` Michael S. Tsirkin
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=20251211-balloon-check-stats-feature-v1-1-ae8951957b80@gmail.com \
--to=aaronlo0929@gmail.com \
--cc=david@kernel.org \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).