From nobody Tue Aug 25 01:42:06 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1781168882; cv=none; d=zohomail.com; s=zohoarc; b=bxtc5CfTw2V2lgynGq53aQOzX3BRwzAacmj/OFjxhV1/zwtdCU3CBgTlMCm8Z6vJKjegUnGbMa06cVD704QXsW1mm6Yi6gaL67fPHhCA8oYJV8fPpSseNe3T8vEOknK1bzzvF3grhJAvf2+IAn+79NOKqMP5LT4ylrqTxbm6z0A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781168882; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xbxN/mAMtJtduNKSGnc8CLMOmhvQhZe+7JMf8JBpoeE=; b=CSmAML0W3lTS82kMGHLoUUoUL0fKr1iY2zpwHM1iKrTMSq95HNbmSQtw9b+b4E6hAMteljB7rKELLNVMaEqhmyBQY6zKeaaaVSYw5tibDP1Dh7xdLiwwV8y0Wp5IVM0KXuzzcmNquUAwb7GrJadBjf6gc8fFnCKCHqJxUdWTf14= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781168882583799.4670169739086; Thu, 11 Jun 2026 02:08:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXbNI-0006ux-8N; Thu, 11 Jun 2026 05:06:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbNG-0006l8-Nj for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:06:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXbNE-0005Rl-Cl for qemu-devel@nongnu.org; Thu, 11 Jun 2026 05:06:54 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-376-qJQVMabLMcKHmRY_jFsaZA-1; Thu, 11 Jun 2026 05:06:50 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 608ED1977000; Thu, 11 Jun 2026 09:06:49 +0000 (UTC) Received: from localhost (unknown [10.44.24.21]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2C36D180029C; Thu, 11 Jun 2026 09:06:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781168811; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xbxN/mAMtJtduNKSGnc8CLMOmhvQhZe+7JMf8JBpoeE=; b=gMB++L5BXMa26agA+/IgIhByv7WscCZVUlHF+x04qZDEjmpfUDipuKPO/01T80vdOWp0Uf FlBGaRrphqVjfDUltkmd5A0wOFH22PiImrRTzd6dvEdpxq5JSk+u7xSQt/gWHLMK2u6J1B csBkprj3iuiURfU76qhqcRfqQybFSdY= X-MC-Unique: qJQVMabLMcKHmRY_jFsaZA-1 X-Mimecast-MFC-AGG-ID: qJQVMabLMcKHmRY_jFsaZA_1781168809 From: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Date: Thu, 11 Jun 2026 13:03:50 +0400 Subject: [PATCH v3 35/35] tests/qtest: add D-Bus display hotplug test MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260611-b4-ui-v3-35-72bcbbea0fae@redhat.com> References: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> In-Reply-To: <20260611-b4-ui-v3-0-72bcbbea0fae@redhat.com> To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Pierrick Bouvier , Fabiano Rosas , Laurent Vivier , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Maydell , Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Developer-Signature: v=1; a=openpgp-sha256; l=4986; i=marcandre.lureau@redhat.com; h=from:subject:message-id; bh=Qj9RcQ/RNJdYxcuio5b6l1xNzAqRshVBUlgn/gQCRCY=; b=owEBbQKS/ZANAwAKAdro4Ql1lpzlAcsmYgBqKnnikT97l5ywP8O8xqU6gZXikDy2DzgyrFnru uQF4EgyI42JAjMEAAEKAB0WIQSHqb2TP4fGBtJ29i3a6OEJdZac5QUCaip54gAKCRDa6OEJdZac 5W93D/41fK0YK2qNSFioSwH3D05vQDvqsho+2t7+xgROkKtTNHZRuXFwDgrUnHWg5PO4z8Ob0HA GW+zCEb75dNm8TS0XEsAiehpTvHOmXyYLAgl5zJlvH15FQ2iDT5hV6REKTdmPzet7M/PsUhKybY voS0PIybbA8n50ZQb8k/ejrxPuZb93Ryp/7BUdB5WbhYKZ6uBe8ATIUVuvrHeirRiXwTHJ/i1uu Xex0G9qE4A0L0UyBCFax5eqje6cw7IvH2bCzojCJaWnRh60t5JoMPOj0iRfzfdczKzpAH36FEvF 2yA7rvL2KntxeDvZxdPNNjImNuf73QZoH/xyqGBrIvKKrJh+7pFiA7m5HFwvzpGlYIXDdxe2w9R J9TOtUMxgOlZ8J7hb+zH441v2zxhimwasfsSc4ALFMXJiH56BJrUKBgSd48eG9u63f+AfjEBtrJ e7bkjLsHFXHrDkwBOjheb/SSZYmV4BXj6ahfys4r6EvvLwVJBvz0MqSf4uqIayWJM06w8PXnCYh VXtm6ZoMhe4MOFBUS8R0xq8KBDnvohvP5ifwLkTnqFDPCKfPeyQ+dbbhH37qOiYf9+1XCAzEoTa h5P7pozQOnKtrY4l4DqFh7CEFHxFqes+JJ1dMdw7nCB11B26z7P12i5v+pFFKMwdO3B1IfKu4X0 fAT6mn6nVFIbGYw== X-Developer-Key: i=marcandre.lureau@redhat.com; a=openpgp; fpr=87A9BD933F87C606D276F62DDAE8E10975969CE5 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 8 X-Spam_score: 0.8 X-Spam_bar: / X-Spam_report: (0.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1781168884697158500 Add a qtest that verifies display consoles are dynamically added and removed over D-Bus when a bochs-display device is hotplugged and unplugged on a q35 machine. The test plugs device_add a bochs-display, waits for the DEVICE_ADDED QMP event, and checks that the D-Bus VM interface reports a second console. It then device_del it, forces a system reset (q35 removal is ACPI-based and needs guest cooperation qtest cannot provide), waits for DEVICE_DELETED, and checks the console count again. Reviewed-by: Fabiano Rosas Signed-off-by: Marc-Andr=C3=A9 Lureau --- tests/qtest/dbus-display-test.c | 101 ++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 99 insertions(+), 2 deletions(-) diff --git a/tests/qtest/dbus-display-test.c b/tests/qtest/dbus-display-tes= t.c index 5773776cad5..7838ce7323f 100644 --- a/tests/qtest/dbus-display-test.c +++ b/tests/qtest/dbus-display-test.c @@ -7,6 +7,8 @@ #include #include #include "libqtest.h" +#include "qobject/qdict.h" +#include "qobject/qstring.h" #include "ui/dbus-display1.h" =20 static GDBusConnection* @@ -38,11 +40,11 @@ test_dbus_p2p_from_fd(int fd) } =20 static void -test_setup(QTestState **qts, GDBusConnection **conn) +test_setup_args(QTestState **qts, GDBusConnection **conn, const char *args) { int pair[2]; =20 - *qts =3D qtest_init("-display dbus,p2p=3Dyes -name dbus-test"); + *qts =3D qtest_init(args); =20 g_assert_cmpint(qemu_socketpair(AF_UNIX, SOCK_STREAM, 0, pair), =3D=3D= , 0); =20 @@ -52,6 +54,12 @@ test_setup(QTestState **qts, GDBusConnection **conn) g_dbus_connection_start_message_processing(*conn); } =20 +static void +test_setup(QTestState **qts, GDBusConnection **conn) +{ + test_setup_args(qts, conn, "-display dbus,p2p=3Dyes -name dbus-test"); +} + static void test_dbus_display_vm(void) { @@ -360,6 +368,92 @@ test_dbus_display_keyboard(void) qtest_quit(qts); } =20 +static gsize +get_console_ids_count(GDBusConnection *conn) +{ + g_autoptr(GError) err =3D NULL; + g_autoptr(QemuDBusDisplay1VMProxy) vm =3D NULL; + GVariant *console_ids; + gsize n_ids =3D 0; + + vm =3D QEMU_DBUS_DISPLAY1_VM_PROXY( + qemu_dbus_display1_vm_proxy_new_sync( + conn, + G_DBUS_PROXY_FLAGS_NONE, + NULL, + DBUS_DISPLAY1_ROOT "/VM", + NULL, + &err)); + g_assert_no_error(err); + + console_ids =3D qemu_dbus_display1_vm_get_console_ids( + QEMU_DBUS_DISPLAY1_VM(vm)); + if (console_ids) { + n_ids =3D g_variant_n_children(console_ids); + } + return n_ids; +} + +static void +wait_device_event(QTestState *qts, const char *event_name, const char *id) +{ + QDict *resp, *data; + QString *qstr; + + for (;;) { + resp =3D qtest_qmp_eventwait_ref(qts, event_name); + data =3D qdict_get_qdict(resp, "data"); + if (!data || !qdict_get(data, "device")) { + qobject_unref(resp); + continue; + } + qstr =3D qobject_to(QString, qdict_get(data, "device")); + if (!strcmp(qstring_get_str(qstr), id)) { + qobject_unref(resp); + break; + } + qobject_unref(resp); + } +} + +static void +test_dbus_display_hotplug(void) +{ + g_autoptr(GDBusConnection) conn =3D NULL; + QTestState *qts =3D NULL; + gsize n; + + test_setup_args(&qts, &conn, + "-machine q35" + " -device pcie-root-port,id=3Drp0" + " -display dbus,p2p=3Dyes" + " -name dbus-test"); + + n =3D get_console_ids_count(conn); + g_assert_cmpuint(n, =3D=3D, 1); + + qtest_qmp_device_add(qts, "bochs-display", "bochs0", + "{'bus': 'rp0'}"); + + n =3D get_console_ids_count(conn); + g_assert_cmpuint(n, =3D=3D, 2); + + /* + * On q35, PCI device removal is ACPI-based and requires guest + * acknowledgement. Since qtest has no guest OS, issue the delete + * request and force removal via system reset. + */ + qtest_qmp_device_del_send(qts, "bochs0"); + qtest_system_reset_nowait(qts); + wait_device_event(qts, "DEVICE_DELETED", "bochs0"); + + n =3D get_console_ids_count(conn); + g_assert_cmpuint(n, =3D=3D, 1); + + g_clear_object(&conn); + qtest_quit(qts); +} + int main(int argc, char **argv) { @@ -369,6 +463,9 @@ main(int argc, char **argv) qtest_add_data_func("/dbus-display/console", GINT_TO_POINTER(false), t= est_dbus_display_console); qtest_add_data_func("/dbus-display/console/map", GINT_TO_POINTER(true)= , test_dbus_display_console); qtest_add_func("/dbus-display/keyboard", test_dbus_display_keyboard); + if (qtest_has_machine("q35") && qtest_has_device("bochs-display")) { + qtest_add_func("/dbus-display/hotplug", test_dbus_display_hotplug); + } =20 return g_test_run(); } --=20 2.54.0