From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Richard Henderson" <richard.henderson@linaro.org>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [PULL 05/23] ui/vnc: Fix crash when specifying [vnc] without id in the config file
Date: Tue, 9 Sep 2025 15:51:29 +0200 [thread overview]
Message-ID: <20250909135147.612345-6-thuth@redhat.com> (raw)
In-Reply-To: <20250909135147.612345-1-thuth@redhat.com>
From: Thomas Huth <thuth@redhat.com>
QEMU currently crashes when there is a [vnc] section in the config
file that does not have an "id = ..." line:
$ echo "[vnc]" > /tmp/qemu.conf
$ ./qemu-system-x86_64 -readconfig /tmp/qemu.conf
qemu-system-x86_64: ../../devel/qemu/ui/vnc.c:4347: vnc_init_func:
Assertion `id' failed.
Aborted (core dumped)
The required "id" is only set up automatically while parsing the command
line, but not when reading the options from the config file.
Thus let's move code that automatically adds the id (if it does not
exist yet) to the init function that needs the id for the first time,
replacing the assert() statement there.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2836
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20250821145130.845104-1-thuth@redhat.com>
---
ui/vnc.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/ui/vnc.c b/ui/vnc.c
index 68ca4a68e7a..9054fc81253 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -4309,8 +4309,9 @@ void vnc_display_add_client(const char *id, int csock, bool skipauth)
}
}
-static void vnc_auto_assign_id(QemuOptsList *olist, QemuOpts *opts)
+static char *vnc_auto_assign_id(QemuOpts *opts)
{
+ QemuOptsList *olist = qemu_find_opts("vnc");
int i = 2;
char *id;
@@ -4320,23 +4321,18 @@ static void vnc_auto_assign_id(QemuOptsList *olist, QemuOpts *opts)
id = g_strdup_printf("vnc%d", i++);
}
qemu_opts_set_id(opts, id);
+
+ return id;
}
void vnc_parse(const char *str)
{
QemuOptsList *olist = qemu_find_opts("vnc");
QemuOpts *opts = qemu_opts_parse_noisily(olist, str, !is_help_option(str));
- const char *id;
if (!opts) {
exit(1);
}
-
- id = qemu_opts_id(opts);
- if (!id) {
- /* auto-assign id if not present */
- vnc_auto_assign_id(olist, opts);
- }
}
int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp)
@@ -4344,7 +4340,11 @@ int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp)
Error *local_err = NULL;
char *id = (char *)qemu_opts_id(opts);
- assert(id);
+ if (!id) {
+ /* auto-assign id if not present */
+ id = vnc_auto_assign_id(opts);
+ }
+
vnc_display_init(id, &local_err);
if (local_err) {
error_propagate(errp, local_err);
--
2.51.0
next prev parent reply other threads:[~2025-09-09 13:58 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-09 13:51 [PULL 00/23] Functional tests and misc patches Thomas Huth
2025-09-09 13:51 ` [PULL 01/23] hw/display/bcm2835_fb: Move inclusion of console.h to the .c file Thomas Huth
2025-09-09 13:51 ` [PULL 02/23] Revert "meson.build: Disable -fzero-call-used-regs on OpenBSD" Thomas Huth
2025-09-09 13:51 ` [PULL 03/23] hw/mips/malta: Silence warning from ubsan Thomas Huth
2025-09-09 13:51 ` [PULL 04/23] system/physmem: " Thomas Huth
2025-09-15 16:17 ` Richard Henderson
2025-09-09 13:51 ` Thomas Huth [this message]
2025-09-09 13:51 ` [PULL 06/23] tests/functional/m68k: Avoid ResourceWarning in the nextcube test Thomas Huth
2025-09-09 13:51 ` [PULL 07/23] tests/functional: enable force refresh of cached assets Thomas Huth
2025-09-09 13:51 ` [PULL 08/23] tests/functional: fix formatting of exception args Thomas Huth
2025-09-09 13:51 ` [PULL 09/23] tests/functional: handle URLError when fetching assets Thomas Huth
2025-09-09 13:51 ` [PULL 10/23] tests/functional/arm: Update test ASPEED SDK v03.02 for AST1030 Thomas Huth
2025-09-09 13:51 ` [PULL 11/23] tests/functional/arm: Update test ASPEED SDK v09.07 for AST2500 Thomas Huth
2025-09-09 13:51 ` [PULL 12/23] tests/functional/arm: Update test ASPEED SDK v09.07 for AST2600 Thomas Huth
2025-09-09 13:51 ` [PULL 13/23] tests/functional/arm: Update test ASPEED SDK v09.07 for AST2700 vbootrom Thomas Huth
2025-09-09 13:51 ` [PULL 14/23] gitlab: replace avocado results files with meson results files Thomas Huth
2025-09-09 13:51 ` [PULL 15/23] gitlab: always include entire of meson-logs directory Thomas Huth
2025-09-09 13:51 ` [PULL 16/23] gitlab: include all junit XML files from meson Thomas Huth
2025-09-09 13:51 ` [PULL 17/23] gitlab: prevent duplicated meson log artifacts in test jobs Thomas Huth
2025-09-09 13:51 ` [PULL 18/23] tests/functional: return output from cmd.py helpers Thomas Huth
2025-09-09 13:51 ` [PULL 19/23] tests/functional: add vm param to " Thomas Huth
2025-09-09 13:51 ` [PULL 20/23] tests/functional: fix infinite loop on console EOF Thomas Huth
2025-09-09 13:51 ` [PULL 21/23] tests/functional: avoid duplicate messages on failures Thomas Huth
2025-09-09 13:51 ` [PULL 22/23] tests/functional: avoid tearDown failure when QEMU dies Thomas Huth
2025-09-09 13:51 ` [PULL 23/23] tests/functional: purge scratch dir on test startup Thomas Huth
2025-09-11 13:12 ` [PULL 00/23] Functional tests and misc patches 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=20250909135147.612345-6-thuth@redhat.com \
--to=thuth@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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).