Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2219980/?format=api
{ "id": 2219980, "url": "http://patchwork.ozlabs.org/api/patches/2219980/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260405-work-qmp-monitor-hotplug-v2-1-ad5bedd2917a@kernel.org/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260405-work-qmp-monitor-hotplug-v2-1-ad5bedd2917a@kernel.org>", "list_archive_url": null, "date": "2026-04-05T13:11:17", "name": "[v2,1/5] monitor: store monitor id and dynamic flag in Monitor struct", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "9220edae00bb32fd7c17d68c7c9e03bb38ce21d5", "submitter": { "id": 82326, "url": "http://patchwork.ozlabs.org/api/people/82326/?format=api", "name": "Christian Brauner", "email": "brauner@kernel.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260405-work-qmp-monitor-hotplug-v2-1-ad5bedd2917a@kernel.org/mbox/", "series": [ { "id": 498784, "url": "http://patchwork.ozlabs.org/api/series/498784/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=498784", "date": "2026-04-05T13:11:16", "name": "monitor: add dynamic QMP monitor hotplug support", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/498784/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2219980/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2219980/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=ku0Ams00;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fpXv66jdsz1xy1\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 05 Apr 2026 23:12:50 +1000 (AEST)", "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1w9NGV-0006Wd-JW; Sun, 05 Apr 2026 09:11:47 -0400", "from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <brauner@kernel.org>)\n id 1w9NGP-0006UN-HA\n for qemu-devel@nongnu.org; Sun, 05 Apr 2026 09:11:41 -0400", "from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <brauner@kernel.org>)\n id 1w9NGN-0006d4-IC\n for qemu-devel@nongnu.org; Sun, 05 Apr 2026 09:11:41 -0400", "from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58])\n by sea.source.kernel.org (Postfix) with ESMTP id EED2C43890;\n Sun, 5 Apr 2026 13:11:35 +0000 (UTC)", "by smtp.kernel.org (Postfix) with ESMTPSA id 5FF9EC116C6;\n Sun, 5 Apr 2026 13:11:33 +0000 (UTC)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n s=k20201202; t=1775394695;\n bh=Iiu1cUQv91hAV1L5+tULf8zTWFqn+vLV9HQtttoGHvU=;\n h=From:Date:Subject:References:In-Reply-To:To:Cc:From;\n b=ku0Ams00pFmGdgZVctYWmz9Q/l3vI6XbsiRILxxw+7ElA7OSDpE8vUjwjg0kRsnI5\n FoxQRY0ccxBhy+npGxKh71tZ+zlj147bOandVZT03/uZh+6cBsLp7Yv5nxnOk7W3UK\n Uz6IREIEaBpFMtP7Cm9N9Bju4WD/dIfNiN9iSE5Ms31XjDLYV02TKPGSYQ5+C6aGOQ\n fJaw+MTZRBOvNvCUfn9z1ZFWgaxZQ4RI815NC0ljFLolIwYkG9rEas1rRICZovwYov\n drM1ImFycFiiD3hsP5PTmkOvYsE7pibxuIDPrFzSDUNu8Rzeuaw3TEC5r1GoxnOsNv\n wLsuG4mXOmKTQ==", "From": "Christian Brauner <brauner@kernel.org>", "Date": "Sun, 05 Apr 2026 15:11:17 +0200", "Subject": "[PATCH v2 1/5] monitor: store monitor id and dynamic flag in\n Monitor struct", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "7bit", "Message-Id": "<20260405-work-qmp-monitor-hotplug-v2-1-ad5bedd2917a@kernel.org>", "References": "<20260405-work-qmp-monitor-hotplug-v2-0-ad5bedd2917a@kernel.org>", "In-Reply-To": "<20260405-work-qmp-monitor-hotplug-v2-0-ad5bedd2917a@kernel.org>", "To": "qemu-devel@nongnu.org", "Cc": "Markus Armbruster <armbru@redhat.com>, Eric Blake <eblake@redhat.com>,\n Fabiano Rosas <farosas@suse.de>, Laurent Vivier <lvivier@redhat.com>,\n Paolo Bonzini <pbonzini@redhat.com>, Thomas Huth <th.huth+qemu@posteo.eu>,\n\t=?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <philmd@linaro.org>, =?utf-8?q?Dani?=\n\t=?utf-8?q?el_P=2E_Berrang=C3=A9?= <berrange@redhat.com>,\n Christian Brauner <brauner@kernel.org>", "X-Mailer": "b4 0.16-dev", "X-Developer-Signature": "v=1; a=openpgp-sha256; l=7269; i=brauner@kernel.org;\n h=from:subject:message-id; bh=Iiu1cUQv91hAV1L5+tULf8zTWFqn+vLV9HQtttoGHvU=;\n b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWReim/8zL3z2R8b9p+Hlr/3+z9N+oTOYjfHvn2/JGYeV\n /km53VzRkcpC4MYF4OsmCKLQ7tJuNxynorNRpkaMHNYmUCGMHBxCsBELicwMiwKFjK/1sn8SqRB\n JHzCnd9M7j+lNATi5hpp+Auo71KomsDwz+K4Q6Hr2rvFG1S/cygpf1r8Yb+32tzM3C/zTm4I2Hl\n biBkA", "X-Developer-Key": "i=brauner@kernel.org; a=openpgp;\n fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624", "Received-SPF": "pass client-ip=2600:3c0a:e001:78e:0:1991:8:25;\n envelope-from=brauner@kernel.org; helo=sea.source.kernel.org", "X-Spam_score_int": "-25", "X-Spam_score": "-2.6", "X-Spam_bar": "--", "X-Spam_report": "(-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.54,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no", "X-Spam_action": "no action", "X-BeenThere": "qemu-devel@nongnu.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "qemu development <qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org" }, "content": "Add 'id', 'dynamic', and 'dead' fields to struct Monitor. The id field\nstores the monitor identifier from MonitorOptions which was previously\nparsed but discarded. The dynamic flag marks monitors created at runtime\nvia the upcoming monitor-add command, and the dead flag will be used for\ndeferred destruction during monitor-remove.\n\nExtend monitor_init_qmp() to accept id and dynamic parameters so these\nare set before the monitor is added to mon_list.\n\nFor iothread monitors, move monitor_list_append() from the setup BH to\nthe caller so monitor_find_by_id() can detect duplicates immediately.\nWithout this, two concurrent monitor-add calls could both pass the\nduplicate check before either BH runs. This means the monitor is now\nvisible in mon_list before its chardev handlers are set up, which was\nnot the case before. This is safe because the request queue is still\nempty (no chardev handlers means no monitor_qmp_read(), so the\ndispatcher finds nothing to dispatch) and event broadcast is handled\nbelow.\n\nThis requires initializing mon->commands = &qmp_cap_negotiation_commands\nbefore monitor_list_append(). Without it, commands is NULL (from\ng_new0) and monitor_qapi_event_emit() would not skip the monitor during\nevent broadcast -- its check is specifically for the\nqmp_cap_negotiation_commands pointer, so a NULL falls through to\nqmp_send_response() on an uninitialized monitor. CHR_EVENT_OPENED sets\ncommands to the same value again later.\n\nAdd monitor_find_by_id() to look up monitors by identifier. The lookup\ntakes monitor_lock to serialize with the I/O thread BH that modifies\nmon_list, but releases it before returning. The caller must hold the\nBQL to ensure the returned pointer remains valid since only BQL holders\ncan destroy monitors.\n\nFree the id string in monitor_data_destroy().\n\nSigned-off-by: Christian Brauner (Amutable) <brauner@kernel.org>\n---\n include/monitor/monitor.h | 3 ++-\n monitor/monitor-internal.h | 5 +++++\n monitor/monitor.c | 21 ++++++++++++++++++++-\n monitor/qmp.c | 11 ++++++++---\n 4 files changed, 35 insertions(+), 5 deletions(-)", "diff": "diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h\nindex 296690e1f1..7a2bb603e4 100644\n--- a/include/monitor/monitor.h\n+++ b/include/monitor/monitor.h\n@@ -19,7 +19,8 @@ bool monitor_cur_is_qmp(void);\n \n void monitor_init_globals(void);\n void monitor_init_globals_core(void);\n-void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp);\n+void monitor_init_qmp(Chardev *chr, bool pretty, const char *id,\n+ bool dynamic, Error **errp);\n void monitor_init_hmp(Chardev *chr, bool use_readline, Error **errp);\n int monitor_init(MonitorOptions *opts, bool allow_hmp, Error **errp);\n int monitor_init_opts(QemuOpts *opts, Error **errp);\ndiff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h\nindex feca111ae3..8f5fe7c111 100644\n--- a/monitor/monitor-internal.h\n+++ b/monitor/monitor-internal.h\n@@ -98,7 +98,10 @@ struct Monitor {\n bool is_qmp;\n bool skip_flush;\n bool use_io_thread;\n+ bool dynamic; /* true if created via monitor-add */\n+ bool dead; /* true if monitor-remove called, awaiting drain */\n \n+ char *id; /* Monitor identifier (NULL for unnamed CLI monitors) */\n char *mon_cpu_path;\n QTAILQ_ENTRY(Monitor) entry;\n \n@@ -181,6 +184,8 @@ void monitor_data_destroy_qmp(MonitorQMP *mon);\n void coroutine_fn monitor_qmp_dispatcher_co(void *data);\n void qmp_dispatcher_co_wake(void);\n \n+Monitor *monitor_find_by_id(const char *id);\n+\n int get_monitor_def(Monitor *mon, int64_t *pval, const char *name);\n void handle_hmp_command(MonitorHMP *mon, const char *cmdline);\n int hmp_compare_cmd(const char *name, const char *list);\ndiff --git a/monitor/monitor.c b/monitor/monitor.c\nindex 00b93ed612..7144255e12 100644\n--- a/monitor/monitor.c\n+++ b/monitor/monitor.c\n@@ -622,6 +622,7 @@ void monitor_data_init(Monitor *mon, bool is_qmp, bool skip_flush,\n \n void monitor_data_destroy(Monitor *mon)\n {\n+ g_free(mon->id);\n g_free(mon->mon_cpu_path);\n qemu_chr_fe_deinit(&mon->chr, false);\n if (monitor_is_qmp(mon)) {\n@@ -633,6 +634,24 @@ void monitor_data_destroy(Monitor *mon)\n qemu_mutex_destroy(&mon->mon_lock);\n }\n \n+/*\n+ * Look up a monitor by its id. The monitor_lock is released before\n+ * returning, so the caller must hold the BQL to ensure the returned\n+ * pointer remains valid (only BQL holders can destroy monitors).\n+ */\n+Monitor *monitor_find_by_id(const char *id)\n+{\n+ Monitor *mon;\n+\n+ QEMU_LOCK_GUARD(&monitor_lock);\n+ QTAILQ_FOREACH(mon, &mon_list, entry) {\n+ if (mon->id && strcmp(mon->id, id) == 0) {\n+ return mon;\n+ }\n+ }\n+ return NULL;\n+}\n+\n void monitor_cleanup(void)\n {\n /*\n@@ -732,7 +751,7 @@ int monitor_init(MonitorOptions *opts, bool allow_hmp, Error **errp)\n \n switch (opts->mode) {\n case MONITOR_MODE_CONTROL:\n- monitor_init_qmp(chr, opts->pretty, errp);\n+ monitor_init_qmp(chr, opts->pretty, opts->id, false, errp);\n break;\n case MONITOR_MODE_READLINE:\n if (!allow_hmp) {\ndiff --git a/monitor/qmp.c b/monitor/qmp.c\nindex 687019811f..afbe2283d6 100644\n--- a/monitor/qmp.c\n+++ b/monitor/qmp.c\n@@ -510,10 +510,10 @@ static void monitor_qmp_setup_handlers_bh(void *opaque)\n qemu_chr_fe_set_handlers(&mon->common.chr, monitor_can_read,\n monitor_qmp_read, monitor_qmp_event,\n NULL, &mon->common, context, true);\n- monitor_list_append(&mon->common);\n }\n \n-void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp)\n+void monitor_init_qmp(Chardev *chr, bool pretty, const char *id,\n+ bool dynamic, Error **errp)\n {\n MonitorQMP *mon = g_new0(MonitorQMP, 1);\n \n@@ -527,12 +527,16 @@ void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp)\n monitor_data_init(&mon->common, true, false,\n qemu_chr_has_feature(chr, QEMU_CHAR_FEATURE_GCONTEXT));\n \n+ mon->common.id = g_strdup(id);\n+ mon->common.dynamic = dynamic;\n mon->pretty = pretty;\n \n qemu_mutex_init(&mon->qmp_queue_lock);\n mon->qmp_requests = g_queue_new();\n \n json_message_parser_init(&mon->parser, handle_qmp_command, mon, NULL);\n+ /* Prevent event broadcast to an uninitialized monitor. */\n+ mon->commands = &qmp_cap_negotiation_commands;\n if (mon->common.use_io_thread) {\n /*\n * Make sure the old iowatch is gone. It's possible when\n@@ -551,7 +555,8 @@ void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp)\n */\n aio_bh_schedule_oneshot(iothread_get_aio_context(mon_iothread),\n monitor_qmp_setup_handlers_bh, mon);\n- /* The bottom half will add @mon to @mon_list */\n+ /* Synchronous insert for immediate duplicate detection. */\n+ monitor_list_append(&mon->common);\n } else {\n qemu_chr_fe_set_handlers(&mon->common.chr, monitor_can_read,\n monitor_qmp_read, monitor_qmp_event,\n", "prefixes": [ "v2", "1/5" ] }