Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2219979/?format=api
{ "id": 2219979, "url": "http://patchwork.ozlabs.org/api/patches/2219979/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260405-work-qmp-monitor-hotplug-v2-5-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-5-ad5bedd2917a@kernel.org>", "list_archive_url": null, "date": "2026-04-05T13:11:21", "name": "[v2,5/5] tests/functional: add e2e test for dynamic QMP monitor hotplug", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "812b7f05cc0c594d77d312cd6cbd9cd957529b2b", "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-5-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/2219979/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2219979/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=AagrvpDX;\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 4fpXtz66PGz1xy1\n\tfor <incoming@patchwork.ozlabs.org>; Sun, 05 Apr 2026 23:12:43 +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 1w9NGu-0006ln-68; Sun, 05 Apr 2026 09:12:12 -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 1w9NGX-0006Z7-Q3\n for qemu-devel@nongnu.org; Sun, 05 Apr 2026 09:11:50 -0400", "from tor.source.kernel.org ([172.105.4.254])\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 1w9NGV-0006eT-Tx\n for qemu-devel@nongnu.org; Sun, 05 Apr 2026 09:11:49 -0400", "from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58])\n by tor.source.kernel.org (Postfix) with ESMTP id 346656001A;\n Sun, 5 Apr 2026 13:11:47 +0000 (UTC)", "by smtp.kernel.org (Postfix) with ESMTPSA id 95C50C19425;\n Sun, 5 Apr 2026 13:11:44 +0000 (UTC)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n s=k20201202; t=1775394706;\n bh=rGuDObTpmf98oV2ZmtxPCkCI9kEJVPL11Kaao5hwhXQ=;\n h=From:Date:Subject:References:In-Reply-To:To:Cc:From;\n b=AagrvpDXOijl9aLYUd8IM+C08U7TRDDDTBTEmDWQ/DyjO90Ub/tQ8j2ZZZSnzxKri\n HQyojvDvzLznbsOpkR91SjIBWNlCsKHjC529Hssq8dkLa2uX9emQ4BMaRcMRSRW8FC\n nhC4yOvLg3wNjbZwDhJyxX+m+g9jTjb6hV5el21vlkEbZfK3HPN9tvkNDhcc1RQvVv\n HRJBsEjRIBHoD0OQsmh7a6Q3o99ZymfvTbzVHeOIatkz1Hug/KkNvPCQcVxwJ4GWpo\n 5ZlgbQ9LgTkuUQS0OwnPiGACZFroB5a31Ykmlq7QpNHF/pAEzanzQi0rAnEDvcSHLA\n jSVkg5sqIXqNQ==", "From": "Christian Brauner <brauner@kernel.org>", "Date": "Sun, 05 Apr 2026 15:11:21 +0200", "Subject": "[PATCH v2 5/5] tests/functional: add e2e test for dynamic QMP\n monitor hotplug", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "7bit", "Message-Id": "<20260405-work-qmp-monitor-hotplug-v2-5-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=7861; i=brauner@kernel.org;\n h=from:subject:message-id; bh=rGuDObTpmf98oV2ZmtxPCkCI9kEJVPL11Kaao5hwhXQ=;\n b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWReim/y2Ht8Iue9GoZo/4N5zNPZmtNv/K3fJPa61Ls48\n MAeLf5PHaUsDGJcDLJiiiwO7Sbhcst5KjYbZWrAzGFlAhnCwMUpABMxWsrwh2fViwtrzrM+d7s4\n ofmhzuJZZy22vjDKPfv/9pIwj9+91lMYGVYsjH3XUWUt/it8VlDt42+7WM5otsSenllVXNHR271\n XjhcA", "X-Developer-Key": "i=brauner@kernel.org; a=openpgp;\n fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624", "Received-SPF": "pass client-ip=172.105.4.254; envelope-from=brauner@kernel.org;\n helo=tor.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 RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001,\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 functional tests that exercise dynamic monitor hotplug with real\nsocket connections:\n\n- Hotplug cycle: chardev-add a unix socket, monitor-add, connect to the\n socket, receive the QMP greeting, negotiate capabilities, send\n query-version, disconnect, remove the monitor and chardev, then repeat\n the entire cycle a second time to verify cleanup and reuse.\n\n- Self-removal: a dynamically-added monitor sends monitor-remove\n targeting itself, verifying that the response is delivered before\n the connection drops and that the monitor is gone afterwards.\n\n- Large response: send query-qmp-schema on a dynamic monitor to\n exercise the output buffer flush path with a large response payload.\n\n- Events after negotiation: trigger STOP/RESUME events via the main\n monitor and verify they are delivered on the dynamic monitor.\n\nThis complements the qtest unit tests by verifying that a real QMP\nclient can connect to a dynamically-added monitor and exchange messages.\n\nSigned-off-by: Christian Brauner (Amutable) <brauner@kernel.org>\n---\n tests/functional/generic/meson.build | 1 +\n tests/functional/generic/test_monitor_hotplug.py | 183 +++++++++++++++++++++++\n 2 files changed, 184 insertions(+)", "diff": "diff --git a/tests/functional/generic/meson.build b/tests/functional/generic/meson.build\nindex 09763c5d22..c94105c62e 100644\n--- a/tests/functional/generic/meson.build\n+++ b/tests/functional/generic/meson.build\n@@ -4,6 +4,7 @@ tests_generic_system = [\n 'empty_cpu_model',\n 'info_usernet',\n 'linters',\n+ 'monitor_hotplug',\n 'version',\n 'vnc',\n ]\ndiff --git a/tests/functional/generic/test_monitor_hotplug.py b/tests/functional/generic/test_monitor_hotplug.py\nnew file mode 100644\nindex 0000000000..d65d33c2f6\n--- /dev/null\n+++ b/tests/functional/generic/test_monitor_hotplug.py\n@@ -0,0 +1,183 @@\n+#!/usr/bin/env python3\n+#\n+# Functional test for dynamic QMP monitor hotplug\n+#\n+# Copyright (c) 2026 Christian Brauner\n+#\n+# This work is licensed under the terms of the GNU GPL, version 2 or\n+# later. See the COPYING file in the top-level directory.\n+\n+import os\n+import tempfile\n+\n+from qemu.qmp.legacy import QEMUMonitorProtocol\n+\n+from qemu_test import QemuSystemTest\n+\n+\n+class MonitorHotplug(QemuSystemTest):\n+\n+ def setUp(self):\n+ super().setUp()\n+ # Use /tmp to avoid UNIX socket path length limit (108 bytes).\n+ # The scratch_file() path is too deep for socket names.\n+ fd, self._sock_path = tempfile.mkstemp(\n+ prefix='qemu-mon-', suffix='.sock')\n+ os.close(fd)\n+ os.unlink(self._sock_path)\n+\n+ def tearDown(self):\n+ try:\n+ os.unlink(self._sock_path)\n+ except FileNotFoundError:\n+ pass\n+ super().tearDown()\n+\n+ def _add_monitor(self):\n+ \"\"\"Create a chardev + monitor and return the socket path.\"\"\"\n+ sock = self._sock_path\n+ self.vm.cmd('chardev-add', id='hotplug-chr', backend={\n+ 'type': 'socket',\n+ 'data': {\n+ 'addr': {\n+ 'type': 'unix',\n+ 'data': {'path': sock}\n+ },\n+ 'server': True,\n+ 'wait': False,\n+ }\n+ })\n+ self.vm.cmd('monitor-add', id='hotplug-mon',\n+ chardev='hotplug-chr')\n+ return sock\n+\n+ def _remove_monitor(self):\n+ \"\"\"Remove the monitor + chardev.\"\"\"\n+ self.vm.cmd('monitor-remove', id='hotplug-mon')\n+ self.vm.cmd('chardev-remove', id='hotplug-chr')\n+\n+ def _connect_and_handshake(self, sock_path):\n+ \"\"\"\n+ Connect to the dynamic monitor socket, perform the QMP\n+ greeting and capability negotiation, send a command, then\n+ disconnect.\n+ \"\"\"\n+ qmp = QEMUMonitorProtocol(sock_path)\n+\n+ # connect(negotiate=True) receives the greeting, validates it,\n+ # and sends qmp_capabilities automatically.\n+ greeting = qmp.connect(negotiate=True)\n+ self.assertIn('QMP', greeting)\n+ self.assertIn('version', greeting['QMP'])\n+ self.assertIn('capabilities', greeting['QMP'])\n+\n+ # Send a real command to prove the session is fully functional\n+ resp = qmp.cmd_obj({'execute': 'query-version'})\n+ self.assertIn('return', resp)\n+ self.assertIn('qemu', resp['return'])\n+\n+ qmp.close()\n+\n+ def test_hotplug_cycle(self):\n+ \"\"\"\n+ Hotplug a monitor, do the full QMP handshake, unplug it,\n+ then repeat the whole cycle a second time.\n+ \"\"\"\n+ self.set_machine('none')\n+ self.vm.add_args('-nodefaults')\n+ self.vm.launch()\n+\n+ # First cycle\n+ sock = self._add_monitor()\n+ self._connect_and_handshake(sock)\n+ self._remove_monitor()\n+\n+ # Second cycle -- same ids, same path, must work\n+ sock = self._add_monitor()\n+ self._connect_and_handshake(sock)\n+ self._remove_monitor()\n+\n+ def test_self_removal(self):\n+ \"\"\"\n+ A dynamically-added monitor sends monitor-remove targeting\n+ itself. Verify the response is delivered before the\n+ connection drops, and that the monitor is gone afterwards.\n+ \"\"\"\n+ self.set_machine('none')\n+ self.vm.add_args('-nodefaults')\n+ self.vm.launch()\n+\n+ sock = self._add_monitor()\n+\n+ qmp = QEMUMonitorProtocol(sock)\n+ greeting = qmp.connect(negotiate=True)\n+ self.assertIn('QMP', greeting)\n+\n+ # Self-removal: the dynamic monitor removes itself\n+ resp = qmp.cmd_obj({'execute': 'monitor-remove',\n+ 'arguments': {'id': 'hotplug-mon'}})\n+ self.assertIn('return', resp)\n+\n+ qmp.close()\n+\n+ # The main monitor should no longer list the removed monitor\n+ monitors = self.vm.cmd('query-monitors')\n+ for m in monitors:\n+ self.assertNotEqual(m.get('id'), 'hotplug-mon')\n+\n+ # Clean up the chardev\n+ self.vm.cmd('chardev-remove', id='hotplug-chr')\n+\n+ def test_large_response(self):\n+ \"\"\"\n+ Send a command with a large response (query-qmp-schema) on a\n+ dynamically-added monitor to exercise the output buffer flush\n+ path.\n+ \"\"\"\n+ self.set_machine('none')\n+ self.vm.add_args('-nodefaults')\n+ self.vm.launch()\n+\n+ sock = self._add_monitor()\n+\n+ qmp = QEMUMonitorProtocol(sock)\n+ qmp.connect(negotiate=True)\n+\n+ resp = qmp.cmd_obj({'execute': 'query-qmp-schema'})\n+ self.assertIn('return', resp)\n+ self.assertIsInstance(resp['return'], list)\n+ self.assertGreater(len(resp['return']), 0)\n+\n+ qmp.close()\n+ self._remove_monitor()\n+\n+ def test_events_after_negotiation(self):\n+ \"\"\"\n+ Verify that QMP events are delivered on a dynamically-added\n+ monitor after capability negotiation completes.\n+ \"\"\"\n+ self.set_machine('none')\n+ self.vm.add_args('-nodefaults')\n+ self.vm.launch()\n+\n+ sock = self._add_monitor()\n+\n+ qmp = QEMUMonitorProtocol(sock)\n+ qmp.connect(negotiate=True)\n+\n+ # Trigger a STOP event via the main monitor, then read it\n+ # from the dynamic monitor.\n+ self.vm.cmd('stop')\n+ resp = qmp.pull_event(wait=True)\n+ self.assertEqual(resp['event'], 'STOP')\n+\n+ self.vm.cmd('cont')\n+ resp = qmp.pull_event(wait=True)\n+ self.assertEqual(resp['event'], 'RESUME')\n+\n+ qmp.close()\n+ self._remove_monitor()\n+\n+\n+if __name__ == '__main__':\n+ QemuSystemTest.main()\n", "prefixes": [ "v2", "5/5" ] }