From nobody Mon May 25 20:37:28 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=1778346904; cv=none; d=zohomail.com; s=zohoarc; b=bCoOmTUldgfQWweTMFPtvXuwP+Zms/EB/elzKtMTY9jDe5n7N3Jy98TcYcnxGRVs1pWSB7za2b6hP8/vA4TowkIiwRUsTKkl7Q0QSI5qKk+OIXcXUsIJGUSFvTs+FVnG1mgy7Fji1RyQEkiqMiWeu+cJCaqTiVJo2Oa29FCQTVk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778346904; 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=OcCC3z+riZQvSpqKsnPiN5LbEl+xDrQhhXWVurattKQ=; b=REThX2aVWUTpX7cmwxm4AyFpYOHgKWcBkfisqbMx0yMrW6lCcX8a2FVJ3q1/Uo3/iI0775tJTUARrLEOX77/oSwszJ2HlwvBv9G+bLiLgApwNDVigkPHWQ33gjRjTFajZpEboOfszn+DIYpf6BP5WCkXrpxjsdmFke0MEN6AYa8= 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 1778346904436435.590356953277; Sat, 9 May 2026 10:15:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlFp-0002YD-MA; Sat, 09 May 2026 13:14:17 -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 1wLlFo-0002Xp-Ip for qemu-devel@nongnu.org; Sat, 09 May 2026 13:14:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wLlFm-0004cm-Id for qemu-devel@nongnu.org; Sat, 09 May 2026 13:14:16 -0400 Received: from mx-prod-mc-05.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-679-neP_sWa3NGG5mbIcL5P0aQ-1; Sat, 09 May 2026 13:14:11 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C4AD0195608A; Sat, 9 May 2026 17:14:10 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6F9033002D30; Sat, 9 May 2026 17:14:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778346853; 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=OcCC3z+riZQvSpqKsnPiN5LbEl+xDrQhhXWVurattKQ=; b=hvzcFyFcvLHxP1w8+XnCP4XctUVbEZnUi3vCCnH6PN/qdwvp9xv2y+FVmqI96vtYVcLE0s 3L6lyG9J8M3DKZsX6qpMpI2UQEcQ+cxamWiVoZdjcQTEPJKv1buCLduwvsjVpLViUhyQnV gUZ2qsgkhiZkUY0ZNGRQl2Rol4+7BKk= X-MC-Unique: neP_sWa3NGG5mbIcL5P0aQ-1 X-Mimecast-MFC-AGG-ID: neP_sWa3NGG5mbIcL5P0aQ_1778346851 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Fabiano Rosas , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Laurent Vivier , Paolo Bonzini Subject: [PULL v2 01/33] tests/qtest/dbus-vmstate: Bring the test up-to-date Date: Sat, 9 May 2026 21:13:22 +0400 Message-ID: <20260509171356.1157879-2-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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.129.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_H4=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: 1778346906508154100 From: Fabiano Rosas The dbus-vmstate-test has been disabled for years. Here's the things that have changed in the meantime and how to update the test: - Migration tests got new headers. Update the includes. - migrate_qmp got new parameters. Update the caller. - migrate_incoming_qmp is now used instead of -incoming URL. Use -incoming defer. - Tests expecting failure should not check non-zero return code. Check for failed migration state instead. - The test result enum was introduced. Replace the migration_fail flag with the enum. - The DEVICE state was added. Replace wait_for_migration_complete with migration_event_wait, which won't trip on intermediary states. - Migration completion was reworked. Explicitly wait for the RESUME event before asserting runstate is RUNNING to avoid checking too quickly and seeing FINISH_MIGRATE instead. - The FAILING state was added. Wait for it before waiting for the RESUME event. - Sanity checks were added to migration_get_env(). Start calling that function in main. - qtest_add_func now has a wrapper. Replace qtest_add_func with migration_test_add. Update tests' signatures to take MigrationCommon, although it's unused. - meson now sets up G_TEST_DBUS_DAEMON. Remove the logic around it. Signed-off-by: Fabiano Rosas Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260429190550.20122-2-farosas@suse.de> --- tests/qtest/dbus-vmstate-test.c | 71 +++++++++++++++++++-------------- tests/qtest/meson.build | 7 +++- 2 files changed, 46 insertions(+), 32 deletions(-) diff --git a/tests/qtest/dbus-vmstate-test.c b/tests/qtest/dbus-vmstate-tes= t.c index 0a82cc9f935..90c050b4480 100644 --- a/tests/qtest/dbus-vmstate-test.c +++ b/tests/qtest/dbus-vmstate-test.c @@ -2,8 +2,8 @@ #include #include #include "libqtest.h" +#include "migration/migration-qmp.h" #include "dbus-vmstate1.h" -#include "migration-helpers.h" =20 static char *workdir; =20 @@ -29,7 +29,7 @@ typedef struct TestServer { =20 typedef struct Test { const char *id_list; - bool migrate_fail; + int result; bool without_dst_b; TestServer srcA; TestServer dstA; @@ -190,6 +190,7 @@ test_dbus_vmstate(Test *test) g_autofree char *uri =3D NULL; QTestState *src_qemu =3D NULL, *dst_qemu =3D NULL; guint ownsrcA, ownsrcB, owndstA, owndstB; + QTestMigrationState src_state =3D { }; =20 uri =3D g_strdup_printf("unix:%s/migsocket", workdir); =20 @@ -224,17 +225,33 @@ test_dbus_vmstate(Test *test) =20 src_qemu =3D qtest_init(src_qemu_args); dst_qemu =3D qtest_init(dst_qemu_args); + + migrate_set_capability(src_qemu, "events", true); + qtest_qmp_set_event_callback(src_qemu, migrate_watch_for_events, + &src_state); + set_id_list(test, src_qemu); set_id_list(test, dst_qemu); =20 thread =3D g_thread_new("dbus-vmstate-thread", dbus_vmstate_thread, lo= op); =20 migrate_incoming_qmp(dst_qemu, uri, NULL, "{}"); - migrate_qmp(src_qemu, uri, "{}"); + migrate_ensure_converge(src_qemu); + migrate_qmp(src_qemu, NULL, uri, NULL, "{}"); test->src_qemu =3D src_qemu; - if (test->migrate_fail) { - wait_for_migration_fail(src_qemu, true); - qtest_set_expected_status(dst_qemu, EXIT_FAILURE); + + if (test->result !=3D MIG_TEST_SUCCEED) { + QDict *rsp; + + migration_event_wait(src_qemu, "failing"); + wait_for_resume(src_qemu, &src_state); + migration_event_wait(src_qemu, "failed"); + + rsp =3D qtest_qmp_assert_success_ref(src_qemu, + "{ 'execute': 'query-status' }"= ); + g_assert(qdict_haskey(rsp, "running")); + g_assert(qdict_get_bool(rsp, "running")); + qobject_unref(rsp); } else { wait_for_migration_complete(src_qemu); } @@ -270,7 +287,7 @@ check_migrated(TestServer *s, TestServer *d) } =20 static void -test_dbus_vmstate_without_list(void) +test_dbus_vmstate_without_list(char *name, MigrateCommon *args) { Test test =3D { 0, }; =20 @@ -281,7 +298,7 @@ test_dbus_vmstate_without_list(void) } =20 static void -test_dbus_vmstate_with_list(void) +test_dbus_vmstate_with_list(char *name, MigrateCommon *args) { Test test =3D { .id_list =3D "idA,idB" }; =20 @@ -292,7 +309,7 @@ test_dbus_vmstate_with_list(void) } =20 static void -test_dbus_vmstate_only_a(void) +test_dbus_vmstate_only_a(char *name, MigrateCommon *args) { Test test =3D { .id_list =3D "idA" }; =20 @@ -303,9 +320,10 @@ test_dbus_vmstate_only_a(void) } =20 static void -test_dbus_vmstate_missing_src(void) +test_dbus_vmstate_missing_src(char *name, MigrateCommon *args) { - Test test =3D { .id_list =3D "idA,idC", .migrate_fail =3D true }; + Test test =3D { .id_list =3D "idA,idC", + .result =3D MIG_TEST_FAIL }; =20 /* run in subprocess to silence QEMU error reporting */ if (g_test_subprocess()) { @@ -320,11 +338,11 @@ test_dbus_vmstate_missing_src(void) } =20 static void -test_dbus_vmstate_missing_dst(void) +test_dbus_vmstate_missing_dst(char *name, MigrateCommon *args) { Test test =3D { .id_list =3D "idA,idB", .without_dst_b =3D true, - .migrate_fail =3D true }; + .result =3D MIG_TEST_FAIL }; =20 /* run in subprocess to silence QEMU error reporting */ if (g_test_subprocess()) { @@ -343,15 +361,8 @@ int main(int argc, char **argv) { GError *err =3D NULL; - g_autofree char *dbus_daemon =3D NULL; int ret; =20 - dbus_daemon =3D g_build_filename(G_STRINGIFY(SRCDIR), - "tests", - "dbus-vmstate-daemon.sh", - NULL); - g_setenv("G_TEST_DBUS_DAEMON", dbus_daemon, true); - g_test_init(&argc, &argv, NULL); =20 workdir =3D g_dir_make_tmp("dbus-vmstate-test-XXXXXX", &err); @@ -362,16 +373,16 @@ main(int argc, char **argv) =20 g_setenv("DBUS_VMSTATE_TEST_TMPDIR", workdir, true); =20 - qtest_add_func("/dbus-vmstate/without-list", - test_dbus_vmstate_without_list); - qtest_add_func("/dbus-vmstate/with-list", - test_dbus_vmstate_with_list); - qtest_add_func("/dbus-vmstate/only-a", - test_dbus_vmstate_only_a); - qtest_add_func("/dbus-vmstate/missing-src", - test_dbus_vmstate_missing_src); - qtest_add_func("/dbus-vmstate/missing-dst", - test_dbus_vmstate_missing_dst); + migration_test_add("/dbus-vmstate/without-list", + test_dbus_vmstate_without_list); + migration_test_add("/dbus-vmstate/with-list", + test_dbus_vmstate_with_list); + migration_test_add("/dbus-vmstate/only-a", + test_dbus_vmstate_only_a); + migration_test_add("/dbus-vmstate/missing-src", + test_dbus_vmstate_missing_src); + migration_test_add("/dbus-vmstate/missing-dst", + test_dbus_vmstate_missing_dst); =20 ret =3D g_test_run(); =20 diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 43f83ffd3aa..ba890c2b554 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -128,10 +128,12 @@ if dbus_daemon.found() and gdbus_codegen.found() # Temporarily disabled due to Patchew failures: #qtests_i386 +=3D ['dbus-vmstate-test'] dbus_vmstate1 =3D custom_target('dbus-vmstate description', - output: ['dbus-vmstate1.h', 'dbus-vmstate1= .c'], + build_by_default: true, + output: [ 'dbus-vmstate1.h', 'dbus-vmstate= 1.c'], input: meson.project_source_root() / 'back= ends/dbus-vmstate1.xml', command: [gdbus_codegen, '@INPUT@', '--interface-prefix', 'org.qemu', + '--output-directory', meson.curr= ent_build_dir(), '--generate-c-code', '@BASENAME@= ']).to_list() else dbus_vmstate1 =3D [] @@ -387,7 +389,8 @@ qtests =3D { 'bios-tables-test': [io, 'boot-sector.c', 'acpi-utils.c', 'tpm-emu.c'], 'cdrom-test': files('boot-sector.c'), 'dbus-vmstate-test': files('migration/migration-qmp.c', - 'migration/migration-util.c') + dbus_vmstate1, + 'migration/migration-util.c') + dbus_vmstate1= + + [gio], 'erst-test': files('erst-test.c'), 'ivshmem-test': [rt, '../../contrib/ivshmem-server/ivshmem-server.c'], 'migration-test': test_migration_files + migration_tls_files + migration= _colo_files, --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778346896; cv=none; d=zohomail.com; s=zohoarc; b=ctqhqL7kvM5fScGpYK9nTFqLkVZhv03Dt27dSAfNR/TkG8eakCzybOfLhN7Z/Jjylr4tztVzGlmUKX3mskDmHR082hyiG5x18y9Biby+pLFmqaovvHMTlYk5tUNCzjarfGb4GaXhicvNen2nRYoup1aMZIweKtp/xIN5qoltwzU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778346896; 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=Or9sAs8SR9br6GVeIhvDb9XD6TOVD7AUKbWB+HucyRs=; b=ndGQeQTOFGil9bITzlph7D1IMag2uqw0VfLTWgMND2Q4s5ckVtiyKQzru3KXsu3nkswIIDvzIIICQkVrAVk4AiZ74wYBZgC9+eMqGuiWCSV1ykA0SCdQykg6WlndcV7mMKQpByfFpHxlLPWLFLyqtY/WAqahcY7AL27HQSE0HAY= 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 177834689664614.260487360137972; Sat, 9 May 2026 10:14:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlFx-0002ZL-4N; Sat, 09 May 2026 13:14:25 -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 1wLlFv-0002Yj-8o for qemu-devel@nongnu.org; Sat, 09 May 2026 13:14:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wLlFt-0004dl-Kj for qemu-devel@nongnu.org; Sat, 09 May 2026 13:14:23 -0400 Received: from mx-prod-mc-01.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-39-jncvvPNPMi6YBiAOK_ItNQ-1; Sat, 09 May 2026 13:14:17 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5420E195608B; Sat, 9 May 2026 17:14:16 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2AAD81801A63; Sat, 9 May 2026 17:14:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778346860; 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=Or9sAs8SR9br6GVeIhvDb9XD6TOVD7AUKbWB+HucyRs=; b=CsTxt3WcLFA4sKBoomKbEpuyMwxJjz045WEQClWeTGLSi6ExA1ciKA8yPLiHic7qPVcd7n HuBKEv54o6jdLsoDKvi4DHWpdgn+E9OZ5Uv1DIoDSk6zVOsik2fF64Zghy0yN+YL9SlVnf RdAPNGSyqZMEHrOskcWNULdWLbYThfg= X-MC-Unique: jncvvPNPMi6YBiAOK_ItNQ-1 X-Mimecast-MFC-AGG-ID: jncvvPNPMi6YBiAOK_ItNQ_1778346856 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Fabiano Rosas , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Laurent Vivier , Paolo Bonzini Subject: [PULL v2 02/33] tests/qtest/dbus-vmstate: Mute Glib complaints about g_unsetenv thread-safety Date: Sat, 9 May 2026 21:13:23 +0400 Message-ID: <20260509171356.1157879-3-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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.129.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_H4=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: 1778346898751158500 From: Fabiano Rosas TLDR: GLib is bugged, the dbus-vmstate-test spams debug messages unconditionally. Mute them. GLib is trying to protect against the lack of thread-safety of setenv/unsetsenv functions by warning when those functions were invoked after a thread has been started. https://gitlab.gnome.org/GNOME/glib/issues/715 Unfortunately: 1) GLib itself starts a thread pool via _g_dbus_initialize when working around a bug in its type dependency chain. This happens in many places, but the test triggers it via g_dbus_address_get_for_bus_sync. https://bugzilla.gnome.org/show_bug.cgi?id=3D627724 2) GLib itself calls g_unsetenv after the test calls g_test_dbus_up. 3) The debug message at g_unsetenv is issued to the G_LOG_DOMAIN defined while compiling the library, i.e "GLib", but this domain is never initialized, so the log functions go into a fallback chain that results in ignoring the G_MESSAGES_DEBUG environment variable, causing the debug messages to not be suppressed when they should. Mute the messages by implementing a handler for G_LOG_LEVEL_DEBUG in the "GLib" log domain and honoring G_MESSAGES_DEBUG. Signed-off-by: Fabiano Rosas Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260429190550.20122-3-farosas@suse.de> --- tests/qtest/dbus-vmstate-test.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/qtest/dbus-vmstate-test.c b/tests/qtest/dbus-vmstate-tes= t.c index 90c050b4480..51c5fdb995a 100644 --- a/tests/qtest/dbus-vmstate-test.c +++ b/tests/qtest/dbus-vmstate-test.c @@ -357,12 +357,33 @@ test_dbus_vmstate_missing_dst(char *name, MigrateComm= on *args) g_test_trap_assert_passed(); } =20 +static void log_func(const gchar *log_domain, GLogLevelFlags log_level, + const gchar *message, gpointer user_data) +{ + const gchar *domains; + + assert(log_level & G_LOG_LEVEL_DEBUG); + + domains =3D getenv("G_MESSAGES_DEBUG"); + if (!domains || (!strstr(domains, "GLib") && !strstr(domains, "all")))= { + return; + } + g_log_default_handler("GLib", G_LOG_LEVEL_DEBUG, message, NULL); +} + int main(int argc, char **argv) { GError *err =3D NULL; int ret; =20 + /* + * GLib currently emits debug messages that ignore + * G_MESSAGES_DEBUG. Set a custom log handler to work around the + * issue. + */ + g_log_set_handler("GLib", G_LOG_LEVEL_DEBUG, log_func, NULL); + g_test_init(&argc, &argv, NULL); =20 workdir =3D g_dir_make_tmp("dbus-vmstate-test-XXXXXX", &err); --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778346959; cv=none; d=zohomail.com; s=zohoarc; b=fzpnlauZg6gTZEL7/s00OY3a0Kg7r7U5pBmVVGoDSDUfd1XbOldpev2TX6OXXWlOL9KBl3wokfSn98uPdJ3/+2B6xbkl4ljVuz2FXqGrg+iKRGMKp+sDb0Ik38aXn/zYluJsU2sSE0ztcXMz6tHsr+hI5tbf1O4zfwVxQC1NjvU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778346959; 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=ft7O6WQ69pApNehW/oK2r/bRdEodC47wXhhbmZXZ944=; b=RYDNJYH47a6RW3dL2UphNFutx6Hh/Q4UoLuDCJf45oufT+J7rkiDhxziG5JgSvPpICOkAh8Xut7LlZxxKHgnQ83FM1yMSJaRoFuEs1B9NbZDTi2sUSRIM9LVFvDWubwpNuav2WaVLD2II5aEeebJXYgSXNKI7zzBsXxh8yN6s5g= 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 1778346959291150.70749479896585; Sat, 9 May 2026 10:15:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlG1-0002Zu-Jm; Sat, 09 May 2026 13:14:29 -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 1wLlG0-0002Zd-GV for qemu-devel@nongnu.org; Sat, 09 May 2026 13:14:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wLlFz-0004ed-08 for qemu-devel@nongnu.org; Sat, 09 May 2026 13:14:28 -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-513-Mdetfjc6MYWBn1iyLuDfRA-1; Sat, 09 May 2026 13:14:22 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 95F3C19560B5; Sat, 9 May 2026 17:14:21 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9A6CA1800240; Sat, 9 May 2026 17:14:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778346866; 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=ft7O6WQ69pApNehW/oK2r/bRdEodC47wXhhbmZXZ944=; b=CrWVHTSBNDpYvLJjYQQ41tzbhWLD+SA6PleaAq6tyo0+Kc9KfGYf649LWISoGyKiAY+uc/ feU/p8CG8a37c/j5644q3glySqpsejVQH/c1aDdLutrdGvuh7v+D9cu0sjsMM3KCuLcrEN AukQA4RxZ9bpien8RAiYhhKw3jKY+2E= X-MC-Unique: Mdetfjc6MYWBn1iyLuDfRA-1 X-Mimecast-MFC-AGG-ID: Mdetfjc6MYWBn1iyLuDfRA_1778346861 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Fabiano Rosas , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Laurent Vivier , Paolo Bonzini Subject: [PULL v2 03/33] tests/qtest/dbus-vmstate: Honor QTEST_LOG env variable Date: Sat, 9 May 2026 21:13:24 +0400 Message-ID: <20260509171356.1157879-4-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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.129.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_H4=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: 1778346960506154100 From: Fabiano Rosas Don't hide QEMU error messages unconditionally, make the tests that expect to fail honor QTEST_LOG and show every output if the variable is set. Signed-off-by: Fabiano Rosas Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260429190550.20122-4-farosas@suse.de> --- tests/qtest/dbus-vmstate-test.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tests/qtest/dbus-vmstate-test.c b/tests/qtest/dbus-vmstate-tes= t.c index 51c5fdb995a..05e598a3e3c 100644 --- a/tests/qtest/dbus-vmstate-test.c +++ b/tests/qtest/dbus-vmstate-test.c @@ -324,17 +324,18 @@ test_dbus_vmstate_missing_src(char *name, MigrateComm= on *args) { Test test =3D { .id_list =3D "idA,idC", .result =3D MIG_TEST_FAIL }; + bool silent =3D !getenv("QTEST_LOG"); =20 /* run in subprocess to silence QEMU error reporting */ - if (g_test_subprocess()) { - test_dbus_vmstate(&test); - check_not_migrated(&test.srcA, &test.dstA); - check_not_migrated(&test.srcB, &test.dstB); + if (silent && !g_test_subprocess()) { + g_test_trap_subprocess(NULL, 0, 0); + g_test_trap_assert_passed(); return; } =20 - g_test_trap_subprocess(NULL, 0, 0); - g_test_trap_assert_passed(); + test_dbus_vmstate(&test); + check_not_migrated(&test.srcA, &test.dstA); + check_not_migrated(&test.srcB, &test.dstB); } =20 static void @@ -343,18 +344,19 @@ test_dbus_vmstate_missing_dst(char *name, MigrateComm= on *args) Test test =3D { .id_list =3D "idA,idB", .without_dst_b =3D true, .result =3D MIG_TEST_FAIL }; + bool silent =3D !getenv("QTEST_LOG"); =20 /* run in subprocess to silence QEMU error reporting */ - if (g_test_subprocess()) { - test_dbus_vmstate(&test); - assert(test.srcA.save_called); - assert(test.srcB.save_called); - assert(!test.dstB.save_called); + if (silent && !g_test_subprocess()) { + g_test_trap_subprocess(NULL, 0, 0); + g_test_trap_assert_passed(); return; } =20 - g_test_trap_subprocess(NULL, 0, 0); - g_test_trap_assert_passed(); + test_dbus_vmstate(&test); + assert(test.srcA.save_called); + assert(test.srcB.save_called); + assert(!test.dstB.save_called); } =20 static void log_func(const gchar *log_domain, GLogLevelFlags log_level, --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778346940; cv=none; d=zohomail.com; s=zohoarc; b=TtmESf+CNzvVi4+vKmjczIw5Cq3Jq/KUVKU8cMyITM/4MfqgmbIxyMRHxRl5qas0u/5jzXbBU8exJV4XJzuhaka6gCGxW4AkPmQdujGrcNG+SynqC9x4tPjJXvkpG9uMKKyTme+uFmNU8X8KWUQrUTUx0Jc/ni0kPNevSmdkq20= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778346940; 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=QbS1d5JewmVCOtucXf7jC4R6BSB9Zvti5ngus63o2fs=; b=INlh7OAdKcr6gWmEU/X2G0/RajnWowVWUSQaIwPzfE8ES4RwXEUdkCcYfLbR+bghWiszPlh2fPKH2L3XI11wTYORkwIz7a6FFST3AlzE4P5irTVSjP305AF4eshrVvKT2yvhoUB3/cEfS56sJ5YSU/Cf0Ekt0fhFKZXE3LDn878= 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 1778346940383263.64610283031755; Sat, 9 May 2026 10:15:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlG8-0002ar-AA; Sat, 09 May 2026 13:14:36 -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 1wLlG6-0002aY-AN for qemu-devel@nongnu.org; Sat, 09 May 2026 13:14:34 -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 1wLlG4-0004gw-VW for qemu-devel@nongnu.org; Sat, 09 May 2026 13:14:34 -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-690-xTwKLs77Ohml2GK93z9JXQ-1; Sat, 09 May 2026 13:14:28 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 9F34D19560AA; Sat, 9 May 2026 17:14:27 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5CE601800240; Sat, 9 May 2026 17:14:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778346872; 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=QbS1d5JewmVCOtucXf7jC4R6BSB9Zvti5ngus63o2fs=; b=RpN0Fjx5eMd4I2EwGWIPHuVjMdxAii9fEhUHKkkpPn6hkPywbkP9zyCcqGt6QOYK1rKUSQ bzLsnO9LpbPTvr+r3+cebcGHjsYBqlAa4CrwZuDuYDsHpaO6f/y+aWomkxRr6rRNfrBH/F gHij26Z9GEGnao01Gbk9n2fwaMsxUuA= X-MC-Unique: xTwKLs77Ohml2GK93z9JXQ-1 X-Mimecast-MFC-AGG-ID: xTwKLs77Ohml2GK93z9JXQ_1778346867 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Fabiano Rosas , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Laurent Vivier , Paolo Bonzini Subject: [PULL v2 04/33] tests/qtest/dbus-vmstate: Stop the daemons explicitly Date: Sat, 9 May 2026 21:13:25 +0400 Message-ID: <20260509171356.1157879-5-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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: 1778346942323154100 From: Fabiano Rosas The dbus-vmstate test is currently non-deterministically emitting a "cleaning up pid" message, followed by the PID of one of the dbus-daemon processes used during the test. This is due to a race between the GTestDBus g_autoptr destructor and a child process that does cleanup when the program ends. Add calls to g_test_dbus_down() to make the issuance of the SIGTERM to the dbus-daemon deterministic. Signed-off-by: Fabiano Rosas Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260429190550.20122-5-farosas@suse.de> --- tests/qtest/dbus-vmstate-test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/qtest/dbus-vmstate-test.c b/tests/qtest/dbus-vmstate-tes= t.c index 05e598a3e3c..15c35e7c0fa 100644 --- a/tests/qtest/dbus-vmstate-test.c +++ b/tests/qtest/dbus-vmstate-test.c @@ -260,11 +260,12 @@ test_dbus_vmstate(Test *test) qtest_quit(src_qemu); g_bus_unown_name(ownsrcA); g_bus_unown_name(ownsrcB); + g_test_dbus_down(srcbus); g_bus_unown_name(owndstA); if (!test->without_dst_b) { g_bus_unown_name(owndstB); } - + g_test_dbus_down(dstbus); g_main_loop_quit(test->loop); } =20 --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778346896; cv=none; d=zohomail.com; s=zohoarc; b=FUpDH/aGUJEzl51EqdBTexEzGzpzPp7CVKCV0vMUUUZYitdMPl1vFA3+wzKq+VrrzQRjUCnpGLZj6b2SjhgbxP6j4Zse5Ibwsmw2qx6h4YNzCQ8+YuqN4SnhiKz27aZzjYqHSZ8RYq2jJp7it3a/X/uSE36zxCeaTI568+MabPA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778346896; 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=KMUtoZHZikDGthKoSDXtFH9v35JqZddhYCFbNlV2KEk=; b=ZmS37RJsjcWkNpBV+cn39f02q9SAUGdvzNAre++jQuFluHzzcRoZ7YEnTZ6FINQA/ma01nzJLYKWv3t5K58xc5+ZDvZSEuqfmFIlfHD5iPLfmtr4u0vI5aiq/JUk/81rHm8CsgKQGeX8CWYpz4HZfS6JvTc11P7obpbXMExROwc= 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 1778346896246341.6156352880831; Sat, 9 May 2026 10:14:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlGC-0002bU-RL; Sat, 09 May 2026 13:14:40 -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 1wLlGB-0002bJ-4b for qemu-devel@nongnu.org; Sat, 09 May 2026 13:14:39 -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 1wLlG9-0004ha-PZ for qemu-devel@nongnu.org; Sat, 09 May 2026 13:14:38 -0400 Received: from mx-prod-mc-05.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-618-GUokpWiQP-mHkrQXzUC45w-1; Sat, 09 May 2026 13:14:34 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0259D1956080; Sat, 9 May 2026 17:14:33 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D25931801A63; Sat, 9 May 2026 17:14:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778346877; 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=KMUtoZHZikDGthKoSDXtFH9v35JqZddhYCFbNlV2KEk=; b=KE4IcTuOZ7nTOkIL+Shfk5fF4oudJSnAfocyH+ocqJgjrs8XrKAo3BFsCWOE73DP8kiOcF UHrfrVbHsZN61iUsz9WS8AGi64G8V0+4OLz630hL2gg31oxFQeMlosPg+nBGT4oUovXq+B GjTZRBLL4eq3KPDf5L5Z1mynDXiRScg= X-MC-Unique: GUokpWiQP-mHkrQXzUC45w-1 X-Mimecast-MFC-AGG-ID: GUokpWiQP-mHkrQXzUC45w_1778346873 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Fabiano Rosas , Laurent Vivier , Paolo Bonzini Subject: [PULL v2 05/33] tests/qtest/dbus-vmstate: Re-enable the test Date: Sat, 9 May 2026 21:13:26 +0400 Message-ID: <20260509171356.1157879-6-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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: 1778346898780158500 From: Fabiano Rosas Back in 2020, the dbus-vmstate test was disabled by commit d46f81cb74 ("tests: Disable dbus-vmstate-test") due to Patchew failures. We don't use Patchew anymore for CI, so re-enable the test. G_TEST_DBUS_DAEMON=3D../tests/dbus-vmstate-daemon.sh \ QTEST_QEMU_BINARY=3D./qemu-system-x86_64 \ ./tests/qtest/dbus-vmstate-test Signed-off-by: Fabiano Rosas Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260429190550.20122-6-farosas@suse.de> --- tests/qtest/meson.build | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index ba890c2b554..0067f767eea 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -125,8 +125,7 @@ endif =20 dbus_daemon =3D find_program('dbus-daemon', required: false) if dbus_daemon.found() and gdbus_codegen.found() - # Temporarily disabled due to Patchew failures: - #qtests_i386 +=3D ['dbus-vmstate-test'] + qtests_i386 +=3D ['dbus-vmstate-test'] dbus_vmstate1 =3D custom_target('dbus-vmstate description', build_by_default: true, output: [ 'dbus-vmstate1.h', 'dbus-vmstate= 1.c'], --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778347058; cv=none; d=zohomail.com; s=zohoarc; b=G8rxOBG/t4NhhKN7zNwVjnnate/j2F4xrTy9FcZ3JSnDdBd6Iv8Uiv8hHfH6AUovLOeCAOJQLspLk9I9iO9OzkWNWDL6pxmcQL6LXVEhFy21siGI7n1HkcR3dIKsTSyisNVxIxMLeBxS7X4rabuNVq7wig50PRyw84Oe7Z05fEo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778347058; 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=grtWLLb6LuzwS7TKPExXe7gH/Kt+8pLarkBdFZ3yg4Y=; b=Hf4ijZBamWrIGzeHOXZuk0WSae7iTyBCKuZcgnV3lgwdp8wn3Fa34fwJ1Lo2XtfXSJ2VjDomSmeMKPu8TF535hVCMG90E9wBIwn9wVDVemkcKsNL7aW4dO9qJTP4PU0dxaixlnaG4kT1iWObszzlJTSHYCn8o+4hbYsLtd5J164= 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 1778347058272714.3515003094559; Sat, 9 May 2026 10:17:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlGO-0002cW-EK; Sat, 09 May 2026 13:14:52 -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 1wLlGG-0002bm-7u for qemu-devel@nongnu.org; Sat, 09 May 2026 13:14:44 -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 1wLlGD-0004iG-T8 for qemu-devel@nongnu.org; Sat, 09 May 2026 13:14:43 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-196-kFRBH4a3Ml6YV51_9MwJzw-1; Sat, 09 May 2026 13:14:39 -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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8C7641800359; Sat, 9 May 2026 17:14:38 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3DC7F18004A3; Sat, 9 May 2026 17:14:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778346881; 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=grtWLLb6LuzwS7TKPExXe7gH/Kt+8pLarkBdFZ3yg4Y=; b=VNVIYfQDbcgZhQwvKQ1BaM1TnbfdjpzUjHtl8LRXuLKTYTl2XPbMOTKqpy2H3XAp0peHPG Hz23as+U+mNpdAjCPqeigIhx6Xt7q7ekgPmhyYTNtRntMzUahjcyNrphY9AId5GvD7pdi9 gJfx4B/WvBFUWvkmZ+U926RL29DVtxY= X-MC-Unique: kFRBH4a3Ml6YV51_9MwJzw-1 X-Mimecast-MFC-AGG-ID: kFRBH4a3Ml6YV51_9MwJzw_1778346878 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 06/33] ui/input: do not assert() when tracing invalid input Date: Sat, 9 May 2026 21:13:27 +0400 Message-ID: <20260509171356.1157879-7-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 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, SPF_HELO_PASS=-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 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: 1778347060536154100 From: Marc-Andr=C3=A9 Lureau It's possible to reach an assert() in the input tracing code by sending some out of range input values via D-Bus for ex: #0 0x00007fec8652186c in __pthread_kill_implementation () at /lib64/libc= .so.6 #1 0x00007fec864c648e in raise () at /lib64/libc.so.6 #2 0x00007fec864ad7b3 in abort () at /lib64/libc.so.6 #3 0x00007fec864ae804 in __libc_message_impl.cold () at /lib64/libc.so.6 #4 0x00007fec864be345 in __assert_fail () at /lib64/libc.so.6 #5 0x00005597964c551e in qapi_enum_lookup[cold] () #6 0x000055979650514a in qemu_input_event_send_impl () #7 0x0000559796505a4d in qemu_input_queue_btn () #8 0x00007fec85780c19 in dbus_mouse_press () at /usr/bin/../lib64/qemu/u= i-dbus.so #9 0x00007fec857912fc in _g_dbus_codegen_marshal_BOOLEAN__OBJECT_UINT.pa= rt.0 () at /usr/bin/../lib64/qemu/ui-dbus.so #10 0x00007fec874cce7c in g_closure_invoke () at /lib64/libgobject-2.0.so= .0 #11 0x00007fec874eb849 in signal_emit_unlocked_R.isra.0 () at /lib64/libg= object-2.0.so.0 #12 0x00007fec874ec66f in g_signal_emitv () at /lib64/libgobject-2.0.so.0 #13 0x00007fec85797e0a in _qemu_dbus_display1_mouse_skeleton_handle_metho= d_call () at /usr/bin/../lib64/qemu/ui-dbus.so Other paths in input code accept out-of-range values (qemu_input_key_value_to_number etc). Let it pass tracing. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/input.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/input.c b/ui/input.c index 57e7817878a..966023d4f4d 100644 --- a/ui/input.c +++ b/ui/input.c @@ -207,22 +207,22 @@ static void qemu_input_event_trace(QemuConsole *src, = InputEvent *evt) break; case INPUT_EVENT_KIND_BTN: btn =3D evt->u.btn.data; - name =3D InputButton_str(btn->button); + name =3D btn->button < INPUT_BUTTON__MAX ? InputButton_str(btn->bu= tton) : "invalid"; trace_input_event_btn(idx, name, btn->down); break; case INPUT_EVENT_KIND_REL: move =3D evt->u.rel.data; - name =3D InputAxis_str(move->axis); + name =3D move->axis < INPUT_AXIS__MAX ? InputAxis_str(move->axis) = : "invalid"; trace_input_event_rel(idx, name, move->value); break; case INPUT_EVENT_KIND_ABS: move =3D evt->u.abs.data; - name =3D InputAxis_str(move->axis); + name =3D move->axis < INPUT_AXIS__MAX ? InputAxis_str(move->axis) = : "invalid"; trace_input_event_abs(idx, name, move->value); break; case INPUT_EVENT_KIND_MTT: mtt =3D evt->u.mtt.data; - name =3D InputAxis_str(mtt->axis); + name =3D mtt->axis < INPUT_AXIS__MAX ? InputAxis_str(mtt->axis) : = "invalid"; trace_input_event_mtt(idx, name, mtt->value); break; case INPUT_EVENT_KIND__MAX: --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778346913; cv=none; d=zohomail.com; s=zohoarc; b=Fnd0D5VKab/sSobkgb4tcoEzesVAM0/Jgh2XZBKauuRv4ZJ4K7K1Tbrr1qs5VANjpTk46F7PMCcO3W8Ifj84peYx4ns3zf4JF+4mXBLfbV+BGrAy0WvM+P2UEHmhLEqPSMMMIBt2oYGJuaKTZE8tWOdHhrA5KqsJEZw8UAW/mEo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778346913; 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=BcxA8Rjc8dvnAqYFrgkKpy785FYBENS9NrbL2j6123s=; b=jHaisl2GcJBSCzJiPouQ7Ptsvh+5OAAI2v5dkQMx5hkOqjrd8gE6Ec3W+E8wEcFUy4G8Fm14UC4qB7vmrrzFpDrmkuflnWEQhwL+YwALFJ9iibgv7zIGNDmE0VtrFNYiVq4JkVbP74lUcQPJItRDE8uyRULC/aMJWBBMGfMJ+bM= 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 1778346913445921.317336631242; Sat, 9 May 2026 10:15:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlGU-0002dB-7c; Sat, 09 May 2026 13:14:58 -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 1wLlGO-0002ce-Ev for qemu-devel@nongnu.org; Sat, 09 May 2026 13:14:52 -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 1wLlGN-0004je-3R for qemu-devel@nongnu.org; Sat, 09 May 2026 13:14:52 -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-358-zMXA2nnJN_ydpFsNjWrN2g-1; Sat, 09 May 2026 13:14:45 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 1535019560AA; Sat, 9 May 2026 17:14:44 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BF52019560A2; Sat, 9 May 2026 17:14:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778346890; 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=BcxA8Rjc8dvnAqYFrgkKpy785FYBENS9NrbL2j6123s=; b=VLkMxk3i7k73Hlc3V8yKwtghTcav35aOhhN0lh9qL25ng7P//FTS2wNE5Lnk3VwCRXL9Ep k/FNMB5SfkHlTDEwpQLOh9v1TDN+HY2gdpTu9ZO7V+aIuVn8NhH0XknPadq3uH8pCx2cKf K6R1LekQhg7kfsbuy8Y1bx2OZs0ZLPo= X-MC-Unique: zMXA2nnJN_ydpFsNjWrN2g-1 X-Mimecast-MFC-AGG-ID: zMXA2nnJN_ydpFsNjWrN2g_1778346884 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Jind=C5=99ich=20Makovi=C4=8Dka?= , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 07/33] ui/gtk: Fix GTK assertion failure introduced with clipboard fixes Date: Sat, 9 May 2026 21:13:28 +0400 Message-ID: <20260509171356.1157879-8-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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: 1778346915099158500 From: Jind=C5=99ich Makovi=C4=8Dka gtk_clipboard_request_targets actually returns n_targets =3D=3D -1 when targets =3D=3D NULL instead of zero. This result in failed assertion within GTK: qemu: Gtk: gtk_targets_include_text: assertion 'targets !=3D NULL || n_targets =3D=3D 0' failed Extend the check to require non-null targets and positive n_targets. Signed-off-by: Jindrich Makovicka Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260501-clipboard-assert-fix-v1-1-e549243e4583@gmail.com> --- ui/gtk-clipboard.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/gtk-clipboard.c b/ui/gtk-clipboard.c index 463ed4e905b..ea9444be70f 100644 --- a/ui/gtk-clipboard.c +++ b/ui/gtk-clipboard.c @@ -175,7 +175,7 @@ static void gd_clipboard_owner_change_targets_received_= callback( { QemuClipboardInfo *info =3D (QemuClipboardInfo *)data; =20 - if (n_targets) { + if (targets && n_targets > 0) { if (gtk_targets_include_text(targets, n_targets)) { info->types[QEMU_CLIPBOARD_TYPE_TEXT].available =3D true; } --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778346923; cv=none; d=zohomail.com; s=zohoarc; b=kOIE+7zr9/eVqM0BgkiPGOC6X0W8KJzaIB3SuLG0J2E6stEV8tPpAQ1nXI5mUqYksg+ljbLbVspc7dfApbV0UufTiHxvhPsx0WRS8NZEUpUwwiDXqSj4sa5iaa6S9wfMDuwEJulmnUL1jzlHzh/THD2aEcU6oWNQHFUZ2eeo/ow= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778346923; 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=REM90bnGMI04PIkiWD1urso09P24aVgj43rB6ZAYNfU=; b=FPFHNa9QFVBf8MOWm6tdsXTKP8XGDg9VYJ7EV7IHw0TVmJ1FkjkW9SsZFBu4THAFG5bFOH7WTYl5uVNSYPYJqz5oDruvS3umpAQVCocPMKOS99UIsZShJqCa57VNbFRdDxPDMBfpQid7qyvJpp6N7N5LM1JM69gVA7c1wlnU9Yo= 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 1778346923397669.707751745829; Sat, 9 May 2026 10:15:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlGe-0002p7-0A; Sat, 09 May 2026 13:15:09 -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 1wLlGQ-0002dA-NU for qemu-devel@nongnu.org; Sat, 09 May 2026 13:14:56 -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 1wLlGO-0004jv-L8 for qemu-devel@nongnu.org; Sat, 09 May 2026 13:14:53 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-264-TaGotFl3MiK_9dafiLGexQ-1; Sat, 09 May 2026 13:14: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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6CCEF18005B6; Sat, 9 May 2026 17:14:49 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5A56F1800357; Sat, 9 May 2026 17:14:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778346892; 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=REM90bnGMI04PIkiWD1urso09P24aVgj43rB6ZAYNfU=; b=gf3oyZKXbbsKczAQrWxavW+6am6zPwithCmaAwT99bcKyagZqwheq/9Zo1Yq1/TNo8REg9 G+EhVEV8NiQ9oTCDKhn+zUxM4ogTFuL4Dnl9Pp+4HW07vgsW75LdBGtT5oKi9DVsDczii9 H3PDfxoxul/i3bfnO1Za9taUe0VWt5g= X-MC-Unique: TaGotFl3MiK_9dafiLGexQ-1 X-Mimecast-MFC-AGG-ID: TaGotFl3MiK_9dafiLGexQ_1778346889 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 08/33] qemu-options.hx: document -chardev vc backend-specific behavior Date: Sat, 9 May 2026 21:13:29 +0400 Message-ID: <20260509171356.1157879-9-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 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, SPF_HELO_PASS=-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 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: 1778346926128154100 From: Marc-Andr=C3=A9 Lureau The -chardev vc documentation only mentioned the built-in console with optional size parameters, but the actual behavior depends on the display backend. Document the GTK (libvte), D-Bus and spice-app cases. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- qemu-options.hx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/qemu-options.hx b/qemu-options.hx index 5566da41a36..e7842b10c8c 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -4286,8 +4286,17 @@ The available backends are: and hub devices is not supported as well. =20 ``-chardev vc,id=3Did[[,width=3Dwidth][,height=3Dheight]][[,cols=3Dcols][,= rows=3Drows]]`` - Connect to a QEMU text console. ``vc`` may optionally be given a - specific size. + Connect to a QEMU text console. The implementation and supported featu= re + set depend on the selected display backend. + + - The GTK backend uses libvte for the emulation and display (when avai= lable). + + - The D-Bus backend exports the character device as a Chardev object. + + - spice-app backend exports it as a Spice port. + + In other cases, QEMU uses its own emulated VT100, and ``vc`` may optio= nally be + given a specific size. =20 ``width`` and ``height`` specify the width and height respectively of the console, in pixels. --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778346937; cv=none; d=zohomail.com; s=zohoarc; b=Soznx4OfJrG9oCDLL1bllzJkJYwefVV5xwoONuODN+vH8kV8ucipwqf9fMW7d029EvDBHpHag9PObX4un5OaWhXiQynHt5ql1I7tfB5PCWPHbuAB7fAsFvd0D4GZZiaBOK7H1epP2x9G+LuiB5aDAgQsB6yUYcjc0h3X2sg7y6g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778346937; 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=9yhQ8bi1pXmggnmlXkH2JFNSXv4d8Zosy9pQKAaMwIQ=; b=W/u3D5gzpDBG/Rc5NkDFr3TRvdsAT89tRpERgdHxk9vpNmgDrQPfeEwuQS2YXQt9Qia3Q4SOG9qq7K1VmR11qPQF8LczrWmeQmwoNfBAzqG9xTJiTxr84ey1n3KqSFrMUIX/e29Q5NlOUw9TGv5hS5kbZ7i3TDUlTvBJSLUkbuc= 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 1778346937154666.9307706699789; Sat, 9 May 2026 10:15:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlGk-0002tl-6E; Sat, 09 May 2026 13:15:14 -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 1wLlGY-0002l1-HS for qemu-devel@nongnu.org; Sat, 09 May 2026 13:15:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wLlGX-0004m4-15 for qemu-devel@nongnu.org; Sat, 09 May 2026 13:15:02 -0400 Received: from mx-prod-mc-05.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-695-CSDO6l55PqiNiSPEB-Ruaw-1; Sat, 09 May 2026 13:14:56 -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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 525E81956089; Sat, 9 May 2026 17:14:55 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BDEF518004A3; Sat, 9 May 2026 17:14:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778346899; 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=9yhQ8bi1pXmggnmlXkH2JFNSXv4d8Zosy9pQKAaMwIQ=; b=KuX2KUJTrO6PoFVVJ+4VlzKuSD0rYAE9tq35H1tA7JWAU9BXtX8JRpi+L3+cAMZGnDPT7z GwtSwJCCj0FBLbVHRuiRbt5mg+KD5CKIcsKiNexAyYcKBmsZv1TzH/RaYFaBKOXGKwZM78 s1jfQgX1yXVuRPduPoBaeBhf5KLZy6I= X-MC-Unique: CSDO6l55PqiNiSPEB-Ruaw-1 X-Mimecast-MFC-AGG-ID: CSDO6l55PqiNiSPEB-Ruaw_1778346895 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Markus Armbruster Subject: [PULL v2 09/33] char: error out if given unhandled size options Date: Sat, 9 May 2026 21:13:30 +0400 Message-ID: <20260509171356.1157879-10-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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.129.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_H4=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: 1778346938453158500 From: Marc-Andr=C3=A9 Lureau This is a small help, because in fact all combined chardev options are accepted by qemu_chardev_opts[]. But given that a user may legitimately want to use the size options with a VC backend, we can report an error when we know the backend doesn't support it. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/chardev/char.h | 1 + include/qemu/option.h | 1 + chardev/char.c | 12 ++++++++++++ ui/console-vc.c | 1 + util/qemu-option.c | 13 +++++++++++++ 5 files changed, 28 insertions(+) diff --git a/include/chardev/char.h b/include/chardev/char.h index c2c42e4b7a3..51995f06a82 100644 --- a/include/chardev/char.h +++ b/include/chardev/char.h @@ -254,6 +254,7 @@ struct ChardevClass { =20 bool internal; /* TODO: eventually use TYPE_USER_CREATABLE */ bool supports_yank; + bool supports_size_opts; =20 /* parse command line options and populate QAPI @backend */ void (*chr_parse)(QemuOpts *opts, ChardevBackend *backend, Error **err= p); diff --git a/include/qemu/option.h b/include/qemu/option.h index 01e673ae03f..9a00ac0a356 100644 --- a/include/qemu/option.h +++ b/include/qemu/option.h @@ -73,6 +73,7 @@ struct QemuOptsList { =20 const char *qemu_opt_get(QemuOpts *opts, const char *name); char *qemu_opt_get_del(QemuOpts *opts, const char *name); +bool qemu_opt_has_any(QemuOpts *opts, const char * const *names); /** * qemu_opt_has_help_opt: * @opts: options to search for a help request diff --git a/chardev/char.c b/chardev/char.c index 48b326d57b9..55dce9725e8 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -639,6 +639,18 @@ ChardevBackend *qemu_chr_parse_opts(QemuOpts *opts, Er= ror **errp) return NULL; } =20 + if (!cc->supports_size_opts) { + const char * const invalid_opts[] =3D { + "width", "height", "cols", "rows", NULL + }; + + if (qemu_opt_has_any(opts, invalid_opts)) { + error_setg(errp, "chardev '%s' does not support size options", + qemu_opts_id(opts)); + return NULL; + } + } + backend =3D g_new0(ChardevBackend, 1); backend->type =3D CHARDEV_BACKEND_KIND_NULL; =20 diff --git a/ui/console-vc.c b/ui/console-vc.c index 6163e21d2c6..62a5e3caf57 100644 --- a/ui/console-vc.c +++ b/ui/console-vc.c @@ -1251,6 +1251,7 @@ static void char_vc_class_init(ObjectClass *oc, const= void *data) cc->chr_write =3D vc_chr_write; cc->chr_accept_input =3D vc_chr_accept_input; cc->chr_set_echo =3D vc_chr_set_echo; + cc->supports_size_opts =3D true; } =20 static const TypeInfo char_vc_type_info =3D { diff --git a/util/qemu-option.c b/util/qemu-option.c index 770300dff12..9fbf425f86e 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -271,6 +271,19 @@ const char *qemu_opt_get(QemuOpts *opts, const char *n= ame) return opt->str; } =20 +bool qemu_opt_has_any(QemuOpts *opts, const char * const *names) +{ + int it; + + for (it =3D 0; names[it]; it++) { + if (qemu_opt_get(opts, names[it])) { + return true; + } + } + return false; +} + + void qemu_opt_iter_init(QemuOptsIter *iter, QemuOpts *opts, const char *na= me) { iter->opts =3D opts; --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778347088; cv=none; d=zohomail.com; s=zohoarc; b=nt1VaOkKrPu8IJDgHVQD+nTmv6Novbbrl4os9ElR5feCUwjOFQw3sSZ9GM+80nY0DcFG1ZKUdjKzZGxyr8Jmc6oxPCWYc5W2RH8BKu4T2yh1oCt+pXXi38ByaHYIaRvJHo5ppeRE5CComlbZyZsU18vfp03bTjD1Lc1B0eNV3B4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778347088; 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=uFqFOdBPTXj3qPbkJjte8Lp4ALTwKucYG2bEikuwAdg=; b=doLkylZjot6LtLnLBXEV7LGRm+TDVV+TDH5gFlmf6UPmJCxytRbOoCAHRoEGHnVkJUYkmPoVWLhhJyK5JyjtjVii9xzRtzpxHfmAx9SA+pGB5/7eyY9q+dxXVOSuT7tWv1qt132Xe+PyW4QcEw6x+YsBbTsBgaHzFKwQ8mDcw1Y= 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 1778347088294223.7507411665764; Sat, 9 May 2026 10:18:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlGs-00033y-QD; Sat, 09 May 2026 13:15:26 -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 1wLlGf-0002qr-GZ for qemu-devel@nongnu.org; Sat, 09 May 2026 13:15:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wLlGd-0004y6-Mz for qemu-devel@nongnu.org; Sat, 09 May 2026 13:15:09 -0400 Received: from mx-prod-mc-01.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-567-GkYxOSC_MImiJhi4j7mv8g-1; Sat, 09 May 2026 13:15:02 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 47106195608F; Sat, 9 May 2026 17:15:01 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 079AA19560A2; Sat, 9 May 2026 17:14:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778346905; 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=uFqFOdBPTXj3qPbkJjte8Lp4ALTwKucYG2bEikuwAdg=; b=XWMohpKdxr92EETlILFrpMoCXcJFYazLaFzkYJuI9iNrD4aZUhQcs7oTroVCPMYEnv5/n2 LFITvNh8Ch31pRmMcdsAbImD8DBOyRF9yJKVeOHQudCfFYnOHLEt339D8akVi3Ihk1oddN I2PdQPcD4ey9tK1hiYFHwSFu6opphAA= X-MC-Unique: GkYxOSC_MImiJhi4j7mv8g-1 X-Mimecast-MFC-AGG-ID: GkYxOSC_MImiJhi4j7mv8g_1778346901 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Eric Blake , Markus Armbruster Subject: [PULL v2 10/33] ui/console: add vc encoding=utf8/cp437 option Date: Sat, 9 May 2026 21:13:31 +0400 Message-ID: <20260509171356.1157879-11-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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.129.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_H4=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: 1778347090251158500 From: Marc-Andr=C3=A9 Lureau Expose a new "encoding" QemuOpt option. Add the corresponding QAPI type and properties. This is going to be wired in the following commits. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- qapi/char.json | 30 ++++++++++++++++++++++++++++-- include/chardev/char.h | 1 + chardev/char.c | 10 ++++++++++ ui/console-vc.c | 12 ++++++++++++ ui/dbus.c | 13 +++++++++++++ qemu-options.hx | 7 +++++-- 6 files changed, 69 insertions(+), 4 deletions(-) diff --git a/qapi/char.json b/qapi/char.json index a4abafa6803..aa5ee9ffcd0 100644 --- a/qapi/char.json +++ b/qapi/char.json @@ -377,6 +377,24 @@ 'base': 'ChardevCommon', 'if': 'CONFIG_SPICE' } =20 +## +# @ChardevVCEncoding: +# +# Character encoding expected from the guest on a virtual console. +# +# @cp437: CP437 (8-bit Extended ASCII / VGA). Every byte maps +# directly to a glyph; suitable for DOS or other guests that +# output raw CP437. +# +# @utf8: UTF-8. Multi-byte sequences are decoded and then mapped +# back to CP437 glyphs for display; unmappable codepoints are +# shown as '?'. Suitable for modern Linux guests. +# +# Since: 11.1 +## +{ 'enum': 'ChardevVCEncoding', + 'data': [ 'cp437', 'utf8' ] } + ## # @ChardevDBus: # @@ -384,10 +402,14 @@ # # @name: name of the channel (following docs/spice-port-fqdn.txt) # +# @encoding: character encoding the guest is expected to use +# (since 11.1) +# # Since: 7.0 ## { 'struct': 'ChardevDBus', - 'data': { 'name': 'str' }, + 'data': { 'name': 'str', + '*encoding': 'ChardevVCEncoding' }, 'base': 'ChardevCommon', 'if': 'CONFIG_DBUS_DISPLAY' } =20 @@ -404,6 +426,9 @@ # # @rows: console height, in chars # +# @encoding: character encoding the guest is expected to use +# (since 11.1) +# # .. note:: The options are only effective when the VNC or SDL # graphical display backend is active. They are ignored with the # GTK, Spice, VNC and D-Bus display backends. @@ -414,7 +439,8 @@ 'data': { '*width': 'int', '*height': 'int', '*cols': 'int', - '*rows': 'int' }, + '*rows': 'int', + '*encoding': 'ChardevVCEncoding' }, 'base': 'ChardevCommon' } =20 ## diff --git a/include/chardev/char.h b/include/chardev/char.h index 51995f06a82..f05e8dba0a9 100644 --- a/include/chardev/char.h +++ b/include/chardev/char.h @@ -255,6 +255,7 @@ struct ChardevClass { bool internal; /* TODO: eventually use TYPE_USER_CREATABLE */ bool supports_yank; bool supports_size_opts; + bool supports_encoding_opts; =20 /* parse command line options and populate QAPI @backend */ void (*chr_parse)(QemuOpts *opts, ChardevBackend *backend, Error **err= p); diff --git a/chardev/char.c b/chardev/char.c index 55dce9725e8..ca8b37ed8d7 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -650,6 +650,13 @@ ChardevBackend *qemu_chr_parse_opts(QemuOpts *opts, Er= ror **errp) return NULL; } } + if (!cc->supports_encoding_opts) { + if (qemu_opt_get(opts, "encoding")) { + error_setg(errp, "chardev '%s' does not support encoding optio= n", + qemu_opts_id(opts)); + return NULL; + } + } =20 backend =3D g_new0(ChardevBackend, 1); backend->type =3D CHARDEV_BACKEND_KIND_NULL; @@ -972,6 +979,9 @@ QemuOptsList qemu_chardev_opts =3D { },{ .name =3D "rows", .type =3D QEMU_OPT_NUMBER, + },{ + .name =3D "encoding", + .type =3D QEMU_OPT_STRING, },{ .name =3D "mux", .type =3D QEMU_OPT_BOOL, diff --git a/ui/console-vc.c b/ui/console-vc.c index 62a5e3caf57..7bb6a483753 100644 --- a/ui/console-vc.c +++ b/ui/console-vc.c @@ -1211,6 +1211,7 @@ static bool vc_chr_open(Chardev *chr, ChardevBackend = *backend, Error **errp) static void vc_chr_parse(QemuOpts *opts, ChardevBackend *backend, Error **= errp) { int val; + const char *str; ChardevVC *vc; =20 backend->type =3D CHARDEV_BACKEND_KIND_VC; @@ -1240,6 +1241,16 @@ static void vc_chr_parse(QemuOpts *opts, ChardevBack= end *backend, Error **errp) vc->has_rows =3D true; vc->rows =3D val; } + + str =3D qemu_opt_get(opts, "encoding"); + if (str) { + int cs =3D qapi_enum_parse(&ChardevVCEncoding_lookup, str, -1, err= p); + if (cs < 0) { + return; + } + vc->has_encoding =3D true; + vc->encoding =3D cs; + } } =20 static void char_vc_class_init(ObjectClass *oc, const void *data) @@ -1252,6 +1263,7 @@ static void char_vc_class_init(ObjectClass *oc, const= void *data) cc->chr_accept_input =3D vc_chr_accept_input; cc->chr_set_echo =3D vc_chr_set_echo; cc->supports_size_opts =3D true; + cc->supports_encoding_opts =3D true; } =20 static const TypeInfo char_vc_type_info =3D { diff --git a/ui/dbus.c b/ui/dbus.c index 794b65c4ada..721cc71d39b 100644 --- a/ui/dbus.c +++ b/ui/dbus.c @@ -471,6 +471,8 @@ dbus_vc_parse(QemuOpts *opts, ChardevBackend *backend, DBusVCClass *klass =3D DBUS_VC_CLASS(object_class_by_name(TYPE_CHARDEV= _VC)); const char *name =3D qemu_opt_get(opts, "name"); const char *id =3D qemu_opts_id(opts); + const char *str; + ChardevDBus *dbus; =20 if (name =3D=3D NULL) { if (g_str_has_prefix(id, "compat_monitor")) { @@ -486,6 +488,16 @@ dbus_vc_parse(QemuOpts *opts, ChardevBackend *backend, } =20 klass->parent_parse(opts, backend, errp); + dbus =3D backend->u.dbus.data; + str =3D qemu_opt_get(opts, "encoding"); + if (str) { + int cs =3D qapi_enum_parse(&ChardevVCEncoding_lookup, str, -1, err= p); + if (cs < 0) { + return; + } + dbus->has_encoding =3D true; + dbus->encoding =3D cs; + } } =20 static void @@ -496,6 +508,7 @@ dbus_vc_class_init(ObjectClass *oc, const void *data) =20 klass->parent_parse =3D cc->chr_parse; cc->chr_parse =3D dbus_vc_parse; + cc->supports_encoding_opts =3D true; } =20 static const TypeInfo dbus_vc_type_info =3D { diff --git a/qemu-options.hx b/qemu-options.hx index e7842b10c8c..5387bcd751b 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -4053,7 +4053,7 @@ DEF("chardev", HAS_ARG, QEMU_OPTION_chardev, " [,logfile=3DPATH][,logappend=3Don|off]\n" "-chardev msmouse,id=3Did[,mux=3Don|off][,logfile=3DPATH][,logappend= =3Don|off]\n" "-chardev vc,id=3Did[[,width=3Dwidth][,height=3Dheight]][[,cols=3Dcols= ][,rows=3Drows]]\n" - " [,mux=3Don|off][,logfile=3DPATH][,logappend=3Don|off]\n" + " [,mux=3Don|off][,logfile=3DPATH][,logappend=3Don|off][,encod= ing=3DENCODING]\n" "-chardev ringbuf,id=3Did[,size=3Dsize][,logfile=3DPATH][,logappend=3D= on|off]\n" "-chardev file,id=3Did,path=3Dpath[,input-path=3Dinput-file][,mux=3Don= |off][,logfile=3DPATH][,logappend=3Don|off]\n" "-chardev pipe,id=3Did,path=3Dpath[,mux=3Don|off][,logfile=3DPATH][,lo= gappend=3Don|off]\n" @@ -4285,7 +4285,7 @@ The available backends are: Several frontend devices is not supported. Stacking of multiplexers and hub devices is not supported as well. =20 -``-chardev vc,id=3Did[[,width=3Dwidth][,height=3Dheight]][[,cols=3Dcols][,= rows=3Drows]]`` +``-chardev vc,id=3Did[[,width=3Dwidth][,height=3Dheight]][[,cols=3Dcols][,= rows=3Drows]][,encoding=3DENCODING]`` Connect to a QEMU text console. The implementation and supported featu= re set depend on the selected display backend. =20 @@ -4304,6 +4304,9 @@ The available backends are: ``cols`` and ``rows`` specify that the console be sized to fit a text console with the given dimensions. =20 + ``encoding`` specifies the character set expected from the guest: + ``utf8`` or ``cp437`` (8-bit Extended ASCII / VGA). + ``-chardev ringbuf,id=3Did[,size=3Dsize]`` Create a ring buffer with fixed size ``size``. size must be a power of two and defaults to ``64K``. --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778346956; cv=none; d=zohomail.com; s=zohoarc; b=nvNdN+tha0bv+3ULN9yQKo7CYAEtp90QI0KvoBqt+zyGRQgNm30e6KkAr3EB/VfLFkYGQEuVffj82gn6CVY7ERd6ma/poB32fkU8k+FHKBAbxH1tlDiTSyAAMrTTtayhAqWOsZd/vJD8+jPvL8IyyHhu3hms4S1sJ+O5dapk8sQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778346956; 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=54iThH2Cm0QinJj4SluTXmSoZWdMrvyznhXb0YHV5TA=; b=Hhaq3wNku4cn5xwyX/MiEgs64iQfyJ7bfFQOnsjdX88TFzAUL/lyhSAfLp6Khj9Pm7qU9OCFn9YFOW/WUBswxX5Jg7tU3PH/On/VL0d49TPpd6jdiSHya70xA2iGkBg0htCiGscI6DKXFwddU8zgnTcyuwM0/rXaIQ7Yb7KI9+g= 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 1778346956046924.5804960437166; Sat, 9 May 2026 10:15:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlHK-0003rW-0A; Sat, 09 May 2026 13:15:50 -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 1wLlGk-0002xF-Ie for qemu-devel@nongnu.org; Sat, 09 May 2026 13:15:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wLlGi-0004zM-JU for qemu-devel@nongnu.org; Sat, 09 May 2026 13:15:14 -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-657-wtBtzNcUNb-uxwqwH4GUlQ-1; Sat, 09 May 2026 13:15:08 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 4E62119560B2; Sat, 9 May 2026 17:15:07 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E67C01953952; Sat, 9 May 2026 17:15:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778346911; 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=54iThH2Cm0QinJj4SluTXmSoZWdMrvyznhXb0YHV5TA=; b=E1RbdNzWY72ySxZVPHVYdOpWfaOslPI0nEhO13ygIdIOmy5PEB35UZp/aRn8tm+hlRkO3U YqWeNIZpolcudhWujmqEDo/Xp3A8YRjwVIEWUO5i2gUD93Na5GXikQf7E33ZVzoyFiTYaz 9fUwpkJwGkoTW6wI1f7/2zgqfNcPM/M= X-MC-Unique: wtBtzNcUNb-uxwqwH4GUlQ-1 X-Mimecast-MFC-AGG-ID: wtBtzNcUNb-uxwqwH4GUlQ_1778346907 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Zhao Liu , Paolo Bonzini Subject: [PULL v2 11/33] ui/console: default vc encoding to cp437 for machine < 11.1 Date: Sat, 9 May 2026 21:13:32 +0400 Message-ID: <20260509171356.1157879-12-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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.129.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_H4=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: 1778346958663154100 From: Marc-Andr=C3=A9 Lureau Add a QOM "encoding" enum property to some chardev-vc backends (console-vc & dbus - gtk and spice don't make use of it) so that the machine compat mechanism can override the default. For machine versions prior to 11.1, the charset defaults to cp437 (raw 8-bit VGA) instead of utf8, preserving the historical behaviour. The following commits are going to wire this to VT100 emulation code and an extra exported D-Bus property. Note that GTK libvte uses utf8 unconditionally, and Spice doesn't have a way to set the encoding, and typically just use libvte in client too. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/chardev/char.h | 19 +++++++++++++++++++ hw/core/machine.c | 4 +++- ui/console-vc.c | 18 ++++++++++++++++++ ui/dbus.c | 40 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 1 deletion(-) diff --git a/include/chardev/char.h b/include/chardev/char.h index f05e8dba0a9..7377d8e60a0 100644 --- a/include/chardev/char.h +++ b/include/chardev/char.h @@ -332,4 +332,23 @@ void resume_mux_open(void); char *qemu_chr_get_pty_name(Chardev *chr); char *qemu_chr_get_filename(Chardev *chr); =20 +#define CHARDEV_VC_ENCODING_PROPERTY_DEFINE(cast_func) \ +static int get_encoding(Object *obj, Error **errp) \ +{ \ + return cast_func(obj)->encoding; \ +} \ + \ +static void set_encoding(Object *obj, int value, Error **errp) \ +{ \ + cast_func(obj)->encoding =3D value; \ +} + +static inline void chardev_vc_add_encoding_prop(ObjectClass *oc, + int (*get)(Object *, Error **), + void (*set)(Object *, int, Error **)) +{ + object_class_property_add_enum(oc, "encoding", "ChardevVCEncoding", + &ChardevVCEncoding_lookup, get, set); +} + #endif diff --git a/hw/core/machine.c b/hw/core/machine.c index 1b661fd36ae..63baff859f3 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -39,7 +39,9 @@ #include "hw/acpi/generic_event_device.h" #include "qemu/audio.h" =20 -GlobalProperty hw_compat_11_0[] =3D {}; +GlobalProperty hw_compat_11_0[] =3D { + { "chardev-vc", "encoding", "cp437" }, +}; const size_t hw_compat_11_0_len =3D G_N_ELEMENTS(hw_compat_11_0); =20 GlobalProperty hw_compat_10_2[] =3D { diff --git a/ui/console-vc.c b/ui/console-vc.c index 7bb6a483753..fd7e6fb7b06 100644 --- a/ui/console-vc.c +++ b/ui/console-vc.c @@ -9,6 +9,7 @@ #include "qemu/fifo8.h" #include "qemu/option.h" #include "qemu/queue.h" +#include "qom/compat-properties.h" #include "ui/console.h" #include "ui/vgafont.h" =20 @@ -109,6 +110,7 @@ struct VCChardev { TextAttributes t_attrib; /* currently active text attributes */ TextAttributes t_attrib_saved; int x_saved, y_saved; + ChardevVCEncoding encoding; }; typedef struct VCChardev VCChardev; =20 @@ -1189,6 +1191,9 @@ static bool vc_chr_open(Chardev *chr, ChardevBackend = *backend, Error **errp) =20 s->chr =3D chr; drv->console =3D s; + if (vc->has_encoding) { + drv->encoding =3D vc->encoding; + } =20 /* set current text attributes to default */ drv->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; @@ -1253,6 +1258,8 @@ static void vc_chr_parse(QemuOpts *opts, ChardevBacke= nd *backend, Error **errp) } } =20 +CHARDEV_VC_ENCODING_PROPERTY_DEFINE(VC_CHARDEV) + static void char_vc_class_init(ObjectClass *oc, const void *data) { ChardevClass *cc =3D CHARDEV_CLASS(oc); @@ -1264,12 +1271,23 @@ static void char_vc_class_init(ObjectClass *oc, con= st void *data) cc->chr_set_echo =3D vc_chr_set_echo; cc->supports_size_opts =3D true; cc->supports_encoding_opts =3D true; + + chardev_vc_add_encoding_prop(oc, get_encoding, set_encoding); +} + +static void char_vc_init(Object *obj) +{ + VCChardev *vc =3D VC_CHARDEV(obj); + + vc->encoding =3D CHARDEV_VC_ENCODING_UTF8; } =20 static const TypeInfo char_vc_type_info =3D { .name =3D TYPE_CHARDEV_VC, .parent =3D TYPE_CHARDEV, .instance_size =3D sizeof(VCChardev), + .instance_init =3D char_vc_init, + .instance_post_init =3D object_apply_compat_props, .class_init =3D char_vc_class_init, }; =20 diff --git a/ui/dbus.c b/ui/dbus.c index 721cc71d39b..59b73e0aa94 100644 --- a/ui/dbus.c +++ b/ui/dbus.c @@ -28,6 +28,7 @@ #include "qemu/main-loop.h" #include "qemu/option.h" #include "qom/object_interfaces.h" +#include "qapi-types-char.h" #include "system/system.h" #include "ui/dbus-module.h" #ifdef CONFIG_OPENGL @@ -455,12 +456,20 @@ dbus_display_class_init(ObjectClass *oc, const void *= data) =20 #define TYPE_CHARDEV_VC "chardev-vc" =20 +typedef struct DBusVCChardev { + DBusChardev parent; + + ChardevVCEncoding encoding; +} DBusVCChardev; + typedef struct DBusVCClass { DBusChardevClass parent_class; =20 void (*parent_parse)(QemuOpts *opts, ChardevBackend *b, Error **errp); } DBusVCClass; =20 +DECLARE_INSTANCE_CHECKER(DBusVCChardev, DBUS_VC_CHARDEV, + TYPE_CHARDEV_VC) DECLARE_CLASS_CHECKERS(DBusVCClass, DBUS_VC, TYPE_CHARDEV_VC) =20 @@ -500,6 +509,23 @@ dbus_vc_parse(QemuOpts *opts, ChardevBackend *backend, } } =20 +CHARDEV_VC_ENCODING_PROPERTY_DEFINE(DBUS_VC_CHARDEV) + +static bool +dbus_vc_open(Chardev *chr, ChardevBackend *backend, Error **errp) +{ + DBusVCChardev *vc =3D DBUS_VC_CHARDEV(chr); + ChardevClass *parent =3D + CHARDEV_CLASS(object_class_by_name(TYPE_CHARDEV_DBUS)); + ChardevDBus *be =3D backend->u.dbus.data; + + if (be->has_encoding) { + vc->encoding =3D be->encoding; + } + + return parent->chr_open(chr, backend, errp); +} + static void dbus_vc_class_init(ObjectClass *oc, const void *data) { @@ -508,12 +534,26 @@ dbus_vc_class_init(ObjectClass *oc, const void *data) =20 klass->parent_parse =3D cc->chr_parse; cc->chr_parse =3D dbus_vc_parse; + cc->chr_open =3D dbus_vc_open; cc->supports_encoding_opts =3D true; + + chardev_vc_add_encoding_prop(oc, get_encoding, set_encoding); +} + +static void +dbus_vc_init(Object *obj) +{ + DBusVCChardev *vc =3D DBUS_VC_CHARDEV(obj); + + vc->encoding =3D CHARDEV_VC_ENCODING_UTF8; } =20 static const TypeInfo dbus_vc_type_info =3D { .name =3D TYPE_CHARDEV_VC, .parent =3D TYPE_CHARDEV_DBUS, + .instance_size =3D sizeof(DBusVCChardev), + .instance_init =3D dbus_vc_init, + .instance_post_init =3D object_apply_compat_props, .class_size =3D sizeof(DBusVCClass), .class_init =3D dbus_vc_class_init, }; --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778346969; cv=none; d=zohomail.com; s=zohoarc; b=ltFjzH0mX7eeQp4SKzY/bm9JGlhvg8zwl5x3nm35BhV/ZTYC/Rf1kfbFndj6FVbHvuPybmQFUZHgytE3SGaeSLqBHMAyL8s0gRUFBwKqDkzZDlsj2uKX7U8wOULp3yTXp/f1xmYFE2qq4A0MuCHDXgOUaLEYX2FXLDY06KSCgOE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778346969; 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=xI/X402CtmtDzIEVp/khfjIWs7e18AEbTBGOXmkqZYM=; b=FQPItBF8nGNW3voV8VGshFMI4SsfVP1MhCbOzK4kxF6qf221oBJh8EWzzQsl6uj5CHoe2GJJoThM9q/j2kIdyABEzGKCMb7vK+3rPBsLZjzF0VzfokAePf2ds27jRSo1BHerQnljensct9PnD1YjpYgYVk+HR9oZbdKqNxJb1Kc= 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 177834696990326.629726054313892; Sat, 9 May 2026 10:16:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlHJ-0003qf-SL; Sat, 09 May 2026 13:15:49 -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 1wLlGs-0003IA-AC for qemu-devel@nongnu.org; Sat, 09 May 2026 13:15:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wLlGq-00052o-3k for qemu-devel@nongnu.org; Sat, 09 May 2026 13:15:21 -0400 Received: from mx-prod-mc-01.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-253-VTM4AlTYNNqdzq2mqTRUyQ-1; Sat, 09 May 2026 13:15:14 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 401D21956094; Sat, 9 May 2026 17:15:13 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 922AA3002D30; Sat, 9 May 2026 17:15:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778346917; 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=xI/X402CtmtDzIEVp/khfjIWs7e18AEbTBGOXmkqZYM=; b=iFdzBfjhiAgeHfBPOUxDiPvx0ciebhN9Ji/2+ORjYQzCYxdysba/gQFJCVUdGElpc++0A+ v4FifoFKC4QHFbLYeJalRhUXgVLwGfXTDV3Z3omuRHeeTml0lRpXs0HO/OeChhYkhAQeY3 B3MIqbspV1Afz9AIZ5Itxn/GVwJFa00= X-MC-Unique: VTM4AlTYNNqdzq2mqTRUyQ-1 X-Mimecast-MFC-AGG-ID: VTM4AlTYNNqdzq2mqTRUyQ_1778346913 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 12/33] ui/dbus: expose vc encoding via D-Bus Chardev.VCEncoding interface Date: Sat, 9 May 2026 21:13:33 +0400 Message-ID: <20260509171356.1157879-13-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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.129.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_H4=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: 1778346970473158500 From: Marc-Andr=C3=A9 Lureau When a D-Bus VC chardev is instantiated, export an extra org.qemu.Display1.Chardev.VCEncoding interface on the chardev object. This lets D-Bus display clients discover the encoding (cp437 or utf8) in use by the virtual console. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/dbus.h | 1 + ui/dbus-chardev.c | 10 ++++++++++ ui/dbus.c | 6 ++++++ ui/dbus-display1.xml | 18 ++++++++++++++++++ 4 files changed, 35 insertions(+) diff --git a/ui/dbus.h b/ui/dbus.h index 986d7774601..e4e78590b49 100644 --- a/ui/dbus.h +++ b/ui/dbus.h @@ -126,6 +126,7 @@ typedef struct DBusChardev { =20 bool exported; QemuDBusDisplay1Chardev *iface; + QemuDBusDisplay1ChardevVCEncoding *iface_vc_encoding; } DBusChardev; =20 DECLARE_INSTANCE_CHECKER(DBusChardev, DBUS_CHARDEV, TYPE_CHARDEV_DBUS) diff --git a/ui/dbus-chardev.c b/ui/dbus-chardev.c index 9442b475517..55117029acc 100644 --- a/ui/dbus-chardev.c +++ b/ui/dbus-chardev.c @@ -53,6 +53,15 @@ dbus_display_chardev_export(DBusDisplay *dpy, DBusCharde= v *chr) sk =3D g_dbus_object_skeleton_new(path); g_dbus_object_skeleton_add_interface( sk, G_DBUS_INTERFACE_SKELETON(chr->iface)); + if (chr->iface_vc_encoding) { + const char *interfaces[] =3D { + "org.qemu.Display1.Chardev.VCEncoding", + NULL + }; + g_dbus_object_skeleton_add_interface( + sk, G_DBUS_INTERFACE_SKELETON(chr->iface_vc_encoding)); + g_object_set(chr->iface, "interfaces", interfaces, NULL); + } g_dbus_object_manager_server_export(dpy->server, sk); chr->exported =3D true; } @@ -290,6 +299,7 @@ char_dbus_finalize(Object *obj) }; =20 dbus_display_notify(&event); + g_clear_object(&dc->iface_vc_encoding); g_clear_object(&dc->iface); } =20 diff --git a/ui/dbus.c b/ui/dbus.c index 59b73e0aa94..e02a94df2f3 100644 --- a/ui/dbus.c +++ b/ui/dbus.c @@ -514,6 +514,7 @@ CHARDEV_VC_ENCODING_PROPERTY_DEFINE(DBUS_VC_CHARDEV) static bool dbus_vc_open(Chardev *chr, ChardevBackend *backend, Error **errp) { + DBusChardev *dc =3D DBUS_CHARDEV(chr); DBusVCChardev *vc =3D DBUS_VC_CHARDEV(chr); ChardevClass *parent =3D CHARDEV_CLASS(object_class_by_name(TYPE_CHARDEV_DBUS)); @@ -522,6 +523,11 @@ dbus_vc_open(Chardev *chr, ChardevBackend *backend, Er= ror **errp) if (be->has_encoding) { vc->encoding =3D be->encoding; } + dc->iface_vc_encoding =3D + qemu_dbus_display1_chardev_vcencoding_skeleton_new(); + qemu_dbus_display1_chardev_vcencoding_set_encoding( + dc->iface_vc_encoding, + qapi_enum_lookup(&ChardevVCEncoding_lookup, vc->encoding)); =20 return parent->chr_open(chr, backend, errp); } diff --git a/ui/dbus-display1.xml b/ui/dbus-display1.xml index 4a41a7e0f34..d96bae2ed64 100644 --- a/ui/dbus-display1.xml +++ b/ui/dbus-display1.xml @@ -1141,4 +1141,22 @@ --> + + + + + + --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778346999; cv=none; d=zohomail.com; s=zohoarc; b=SY3u0xD5EBo/vYXgwyNciqFZcfqYptCA9RBiuRzK1TIZ7yPlpzUQUZTg5N6M4Hj8u0zFM/oX7SgYKZ0iMRWJ8d1+UsT6YXx5fHy/WyA28J3jWvDzIh1XAVm0Hk1yRYiR2fGkV/MrH+fWjHZp6NqDOYQQN7juab/akIXU9hS9vws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778346999; 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=+2ysQV5au2Xxa5toxOCRIzgfVdxOEs6Gt0a3VIiak14=; b=Gk58QckKqLkdRqNHbvnEhMM3MVEVhnNUaJoqYUMAykMSZ3BGvD4u5fkVMuwLaMaIPx5RQlc+VcmuFK2HjSntwEinlCOR9Fi51g26oMwC3Tn0+jwaXb5FtsVr9flT6ue8udc9/VCJizNaayhtAo20PeHFqnMQzKL3sEWiFsrOMJg= 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 1778346999680762.1931357888627; Sat, 9 May 2026 10:16:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlHM-00045i-Nj; Sat, 09 May 2026 13:15:52 -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 1wLlGy-0003Ra-0X for qemu-devel@nongnu.org; Sat, 09 May 2026 13:15:30 -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 1wLlGv-00054A-Bb for qemu-devel@nongnu.org; Sat, 09 May 2026 13:15:27 -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-204-MDwDkfZINwOiF5xV0I-lvw-1; Sat, 09 May 2026 13:15:20 -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 3FDAA19560AA; Sat, 9 May 2026 17:15:19 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5998718004A3; Sat, 9 May 2026 17:15:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778346924; 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=+2ysQV5au2Xxa5toxOCRIzgfVdxOEs6Gt0a3VIiak14=; b=OT98HSNt+SYNMToLqEi8vNdq9xkBcY9QxrO4leliaBiJIzB9CTdctvEI/50aIVF+t9bV3M 5ArhQ+DtAhruw5X1Uli8H+EzM5GvAP4xzXWrEK4+cejLVAvuUHVjEqRGaJvs5fIZzwxG75 ffHFu6b+4wGHf0gt64MxzIrsCWubbS8= X-MC-Unique: MDwDkfZINwOiF5xV0I-lvw-1 X-Mimecast-MFC-AGG-ID: MDwDkfZINwOiF5xV0I-lvw_1778346919 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 13/33] ui/console-vc: add UTF-8 input decoding with CP437 rendering Date: Sat, 9 May 2026 21:13:34 +0400 Message-ID: <20260509171356.1157879-14-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: 1778347000577158500 From: Marc-Andr=C3=A9 Lureau The text console receives bytes that may be UTF-8 encoded (e.g. from a guest running a modern distro), but currently treats each byte as a raw character index into the VGA/CP437 font, producing garbled output for any multi-byte sequence. Add a UTF-8 decoder using Bjoern Hoehrmann's DFA. The DFA inherently rejects overlong encodings, surrogates, and codepoints above U+10FFFF. Completed codepoints are then mapped to CP437, unmappable characters are displayed as '?'. Note that QEMU has a "buffered" utf8 decoder in util/unicode.c, but it is not a good fit for byte-per-byte decoding. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/cp437.h | 13 +++ ui/console-vc.c | 59 ++++++++++++++ ui/cp437.c | 205 ++++++++++++++++++++++++++++++++++++++++++++++++ ui/meson.build | 2 +- 4 files changed, 278 insertions(+), 1 deletion(-) create mode 100644 ui/cp437.h create mode 100644 ui/cp437.c diff --git a/ui/cp437.h b/ui/cp437.h new file mode 100644 index 00000000000..81ace8317c7 --- /dev/null +++ b/ui/cp437.h @@ -0,0 +1,13 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * + * Copyright (c) QEMU contributors + */ +#ifndef QEMU_CP437_H +#define QEMU_CP437_H + +#include + +int unicode_to_cp437(uint32_t codepoint); + +#endif /* QEMU_CP437_H */ diff --git a/ui/console-vc.c b/ui/console-vc.c index fd7e6fb7b06..42d642afebb 100644 --- a/ui/console-vc.c +++ b/ui/console-vc.c @@ -12,6 +12,7 @@ #include "qom/compat-properties.h" #include "ui/console.h" #include "ui/vgafont.h" +#include "ui/cp437.h" =20 #include "pixman.h" #include "trace.h" @@ -107,6 +108,8 @@ struct VCChardev { enum TTYState state; int esc_params[MAX_ESC_PARAMS]; int nb_esc_params; + uint32_t utf8_state; /* UTF-8 DFA decoder state */ + uint32_t utf8_codepoint; /* accumulated UTF-8 code point */ TextAttributes t_attrib; /* currently active text attributes */ TextAttributes t_attrib_saved; int x_saved, y_saved; @@ -624,6 +627,46 @@ static void vc_clear_xy(VCChardev *vc, int x, int y) vc_update_xy(vc, x, y); } =20 +/* + * UTF-8 DFA decoder by Bjoern Hoehrmann. + * Copyright (c) 2008-2010 Bjoern Hoehrmann + * See https://github.com/polijan/utf8_decode for details. + * + * SPDX-License-Identifier: MIT + */ +#define BH_UTF8_ACCEPT 0 +#define BH_UTF8_REJECT 12 + +static uint32_t bh_utf8_decode(uint32_t *state, uint32_t *codep, uint32_t = byte) +{ + static const uint8_t utf8d[] =3D { + /* character class lookup */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, + 10,3,3,3,3,3,3,3,3,3,3,3,3,4,3,3, 11,6,6,6,5,8,8,8,8,8,8,8,8,8,8,8, + + /* state transition lookup */ + 0,12,24,36,60,96,84,12,12,12,48,72, 12,12,12,12,12,12,12,12,12,12,= 12,12, + 12, 0,12,12,12,12,12, 0,12, 0,12,12, 12,24,12,12,12,12,12,24,12,24= ,12,12, + 12,12,12,12,12,12,12,24,12,12,12,12, 12,24,12,12,12,12,12,12,12,24= ,12,12, + 12,12,12,12,12,12,12,36,12,36,12,12, 12,36,12,12,12,12,12,36,12,36= ,12,12, + 12,36,12,12,12,12,12,12,12,12,12,12, + }; + uint32_t type =3D utf8d[byte]; + + *codep =3D (*state !=3D BH_UTF8_ACCEPT) ? + (byte & 0x3fu) | (*codep << 6) : + (0xffu >> type) & (byte); + + *state =3D utf8d[256 + *state + type]; + return *state; +} + static void vc_put_one(VCChardev *vc, int ch) { QemuTextConsole *s =3D vc->console; @@ -787,6 +830,22 @@ static void vc_putchar(VCChardev *vc, int ch) =20 switch(vc->state) { case TTY_STATE_NORM: + if (ch >=3D 0x80 && vc->encoding =3D=3D CHARDEV_VC_ENCODING_UTF8) { + switch (bh_utf8_decode(&vc->utf8_state, &vc->utf8_codepoint, c= h)) { + case BH_UTF8_ACCEPT: + vc_put_one(vc, unicode_to_cp437(vc->utf8_codepoint)); + break; + case BH_UTF8_REJECT: + vc->utf8_state =3D BH_UTF8_ACCEPT; + break; + default: + /* Need more bytes */ + break; + } + break; + } + /* ASCII byte: abort any pending UTF-8 sequence */ + vc->utf8_state =3D BH_UTF8_ACCEPT; switch(ch) { case '\r': /* carriage return */ vt->x =3D 0; diff --git a/ui/cp437.c b/ui/cp437.c new file mode 100644 index 00000000000..8ec38b73419 --- /dev/null +++ b/ui/cp437.c @@ -0,0 +1,205 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * + * Copyright (c) QEMU contributors + */ +#include "qemu/osdep.h" +#include "cp437.h" + +/* + * Unicode to CP437 page tables. + * + * Borrowed from the Linux kernel (fs/nls/nls_cp437.c, "Dual BSD/GPL"), + * generated from the Unicode Organization tables (www.unicode.org). + */ +static const unsigned char uni2cp437_page00[256] =3D { + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00-0x07 */ + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08-0x0f */ + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10-0x17 */ + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18-0x1f */ + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20-0x27 */ + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28-0x2f */ + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* 0x30-0x37 */ + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 0x38-0x3f */ + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* 0x40-0x47 */ + 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, /* 0x48-0x4f */ + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, /* 0x50-0x57 */ + 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, /* 0x58-0x5f */ + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 0x60-0x67 */ + 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, /* 0x68-0x6f */ + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, /* 0x70-0x77 */ + 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, /* 0x78-0x7f */ + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ + 0xff, 0xad, 0x9b, 0x9c, 0x00, 0x9d, 0x00, 0x00, /* 0xa0-0xa7 */ + 0x00, 0x00, 0xa6, 0xae, 0xaa, 0x00, 0x00, 0x00, /* 0xa8-0xaf */ + 0xf8, 0xf1, 0xfd, 0x00, 0x00, 0xe6, 0x00, 0xfa, /* 0xb0-0xb7 */ + 0x00, 0x00, 0xa7, 0xaf, 0xac, 0xab, 0x00, 0xa8, /* 0xb8-0xbf */ + 0x00, 0x00, 0x00, 0x00, 0x8e, 0x8f, 0x92, 0x80, /* 0xc0-0xc7 */ + 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8-0xcf */ + 0x00, 0xa5, 0x00, 0x00, 0x00, 0x00, 0x99, 0x00, /* 0xd0-0xd7 */ + 0x00, 0x00, 0x00, 0x00, 0x9a, 0x00, 0x00, 0xe1, /* 0xd8-0xdf */ + 0x85, 0xa0, 0x83, 0x00, 0x84, 0x86, 0x91, 0x87, /* 0xe0-0xe7 */ + 0x8a, 0x82, 0x88, 0x89, 0x8d, 0xa1, 0x8c, 0x8b, /* 0xe8-0xef */ + 0x00, 0xa4, 0x95, 0xa2, 0x93, 0x00, 0x94, 0xf6, /* 0xf0-0xf7 */ + 0x00, 0x97, 0xa3, 0x96, 0x81, 0x00, 0x00, 0x98, /* 0xf8-0xff */ +}; + +static const unsigned char uni2cp437_page01[256] =3D { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */ + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ + 0x00, 0x00, 0x9f, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ +}; + +static const unsigned char uni2cp437_page03[256] =3D { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */ + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ + 0x00, 0x00, 0x00, 0xe2, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ + 0xe9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ + 0x00, 0x00, 0x00, 0xe4, 0x00, 0x00, 0xe8, 0x00, /* 0xa0-0xa7 */ + 0x00, 0xea, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8-0xaf */ + 0x00, 0xe0, 0x00, 0x00, 0xeb, 0xee, 0x00, 0x00, /* 0xb0-0xb7 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8-0xbf */ + 0xe3, 0x00, 0x00, 0xe5, 0xe7, 0x00, 0xed, 0x00, /* 0xc0-0xc7 */ +}; + +static const unsigned char uni2cp437_page20[256] =3D { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60-0x67 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68-0x6f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, /* 0x78-0x7f */ + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80-0x87 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88-0x8f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9e, /* 0xa0-0xa7 */ +}; + +static const unsigned char uni2cp437_page22[256] =3D { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ + 0x00, 0xf9, 0xfb, 0x00, 0x00, 0x00, 0xec, 0x00, /* 0x18-0x1f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ + 0x00, 0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28-0x2f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30-0x37 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38-0x3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */ + 0xf7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50-0x57 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58-0x5f */ + 0x00, 0xf0, 0x00, 0x00, 0xf3, 0xf2, 0x00, 0x00, /* 0x60-0x67 */ +}; + +static const unsigned char uni2cp437_page23[256] =3D { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x08-0x0f */ + 0xa9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10-0x17 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18-0x1f */ + 0xf4, 0xf5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20-0x27 */ +}; + +static const unsigned char uni2cp437_page25[256] =3D { + 0xc4, 0x00, 0xb3, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00-0x07 */ + 0x00, 0x00, 0x00, 0x00, 0xda, 0x00, 0x00, 0x00, /* 0x08-0x0f */ + 0xbf, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, /* 0x10-0x17 */ + 0xd9, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, /* 0x18-0x1f */ + 0x00, 0x00, 0x00, 0x00, 0xb4, 0x00, 0x00, 0x00, /* 0x20-0x27 */ + 0x00, 0x00, 0x00, 0x00, 0xc2, 0x00, 0x00, 0x00, /* 0x28-0x2f */ + 0x00, 0x00, 0x00, 0x00, 0xc1, 0x00, 0x00, 0x00, /* 0x30-0x37 */ + 0x00, 0x00, 0x00, 0x00, 0xc5, 0x00, 0x00, 0x00, /* 0x38-0x3f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40-0x47 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48-0x4f */ + 0xcd, 0xba, 0xd5, 0xd6, 0xc9, 0xb8, 0xb7, 0xbb, /* 0x50-0x57 */ + 0xd4, 0xd3, 0xc8, 0xbe, 0xbd, 0xbc, 0xc6, 0xc7, /* 0x58-0x5f */ + 0xcc, 0xb5, 0xb6, 0xb9, 0xd1, 0xd2, 0xcb, 0xcf, /* 0x60-0x67 */ + 0xd0, 0xca, 0xd8, 0xd7, 0xce, 0x00, 0x00, 0x00, /* 0x68-0x6f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70-0x77 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78-0x7f */ + + 0xdf, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00, /* 0x80-0x87 */ + 0xdb, 0x00, 0x00, 0x00, 0xdd, 0x00, 0x00, 0x00, /* 0x88-0x8f */ + 0xde, 0xb0, 0xb1, 0xb2, 0x00, 0x00, 0x00, 0x00, /* 0x90-0x97 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98-0x9f */ + 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0-0xa7 */ +}; + +static const unsigned char *const uni2cp437_page[256] =3D { + [0x00] =3D uni2cp437_page00, [0x01] =3D uni2cp437_page01, + [0x03] =3D uni2cp437_page03, [0x20] =3D uni2cp437_page20, + [0x22] =3D uni2cp437_page22, [0x23] =3D uni2cp437_page23, + [0x25] =3D uni2cp437_page25, +}; + +/* + * Convert a Unicode code point to its CP437 equivalent for + * rendering with the VGA font. + * Returns '?' for characters that cannot be mapped. + */ +int unicode_to_cp437(uint32_t codepoint) +{ + const unsigned char *page; + unsigned char hi =3D (codepoint >> 8) & 0xff; + unsigned char lo =3D codepoint & 0xff; + + if (codepoint > 0xffff) { + return '?'; + } + + page =3D uni2cp437_page[hi]; + if (page && page[lo]) { + return page[lo]; + } + + return '?'; +} diff --git a/ui/meson.build b/ui/meson.build index ceaf110683d..d69eebfdaf1 100644 --- a/ui/meson.build +++ b/ui/meson.build @@ -18,7 +18,7 @@ system_ss.add(files( 'util.c', 'vgafont.c', )) -system_ss.add(when: pixman, if_true: files('console-vc.c'), if_false: file= s('console-vc-stubs.c')) +system_ss.add(when: pixman, if_true: files('console-vc.c', 'cp437.c'), if_= false: files('console-vc-stubs.c')) if dbus_display system_ss.add(files('dbus-module.c')) endif --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778346999; cv=none; d=zohomail.com; s=zohoarc; b=jFiKAoJXy95ejg6rZ0Lao43cKoP23GBso9MWtxmhhlN7ZOoMdlRZc4dkrnsgUEJlATGelXgmpGHB+OO0GnH9v++k9V5yC3PrQNv+38KDyFHuYjeWS6TbGJRd8PA5HQpLssKrnHlazx/xnECXk49axMjlHPGwKH6TA6D9/XnNbbg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778346999; 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=GIN3fH5K8YG/CeuEI18lPsKtXONRV8pHsPAR4kROB4M=; b=fVmH+TKusUsyNCEGQoOF42wG+mNrRyHlk4OLH/UinGKGTZVQRDtjh5jFez+9Qn2YdFXd7AgCOHzRh35fK0sXej+0cjtOG4mvmSQex5GAcnC8XD2ae3Bt3ntfWEtM0jWWyoG7Ir+0kFbpzzS6KJifbZC5Pw33DOI1yu6/n+Guo34= 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 1778346999703347.5780589262523; Sat, 9 May 2026 10:16:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlHM-00045L-Kd; Sat, 09 May 2026 13:15:52 -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 1wLlH3-0003Zh-UP for qemu-devel@nongnu.org; Sat, 09 May 2026 13:15:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wLlH0-00055Y-MP for qemu-devel@nongnu.org; Sat, 09 May 2026 13:15:33 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-649-hpO3y5U1PcmflKpKY2x72Q-1; Sat, 09 May 2026 13:15:26 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AFCF218005BA; Sat, 9 May 2026 17:15:25 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BEF0E1800240; Sat, 9 May 2026 17:15:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778346930; 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=GIN3fH5K8YG/CeuEI18lPsKtXONRV8pHsPAR4kROB4M=; b=fmT1DFfNCpy1RJxixAZdXZjfA4A7CF7m9tfQgSbVconVgS34K29slQgAxlPlAMmLwEuDm9 yf9Zwal6+JWorqtMNz/zYqgemEwAPQdlb7TVYvpqabaHPNYceDr7FlbizWSBXSIabIds/H Uy9Yl/AwNx92lIfSLZHNnVy9kZ2LS3s= X-MC-Unique: hpO3y5U1PcmflKpKY2x72Q-1 X-Mimecast-MFC-AGG-ID: hpO3y5U1PcmflKpKY2x72Q_1778346925 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 14/33] ui/console-vc: move VT100 state machine and output FIFO into QemuVT100 Date: Sat, 9 May 2026 21:13:35 +0400 Message-ID: <20260509171356.1157879-15-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 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: 1778347000715158500 From: Marc-Andr=C3=A9 Lureau Move the terminal escape sequence parser state (TTYState, esc_params, text attributes, saved cursor position) and the output FIFO from VCChardev/QemuTextConsole into QemuVT100. Rename the corresponding functions from vc_* to vt100_* to reflect they now operate on the VT100 layer directly, removing the indirection through vc->console->vt. Add an out_flush callback to QemuVT100 so vt100_write() can flush output without knowing about QemuTextConsole, and move FIFO/VT100 initialization from qemu_text_console_init() to vc_chr_open() where the callback can be wired up. This continues the decoupling of VT100 terminal emulation from the chardev layer, making QemuVT100 a self-contained terminal emulator. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- ui/console-vc.c | 382 +++++++++++++++++++++++------------------------- 1 file changed, 184 insertions(+), 198 deletions(-) diff --git a/ui/console-vc.c b/ui/console-vc.c index 42d642afebb..cf1adfc3c71 100644 --- a/ui/console-vc.c +++ b/ui/console-vc.c @@ -58,6 +58,7 @@ struct QemuVT100 { pixman_image_t *image; void (*image_update)(QemuVT100 *vt, int x, int y, int width, int heigh= t); =20 + ChardevVCEncoding encoding; int width; int height; int total_height; @@ -74,6 +75,18 @@ struct QemuVT100 { int update_x1; int update_y1; =20 + enum TTYState state; + int esc_params[MAX_ESC_PARAMS]; + int nb_esc_params; + uint32_t utf8_state; /* UTF-8 DFA decoder state */ + uint32_t utf8_codepoint; /* accumulated UTF-8 code point */ + TextAttributes t_attrib; /* currently active text attributes */ + TextAttributes t_attrib_saved; + int x_saved, y_saved; + /* fifo for key pressed */ + Fifo8 out_fifo; + void (*out_flush)(QemuVT100 *vt); + QTAILQ_ENTRY(QemuVT100) list; }; =20 @@ -85,8 +98,6 @@ typedef struct QemuTextConsole { =20 QemuVT100 vt; Chardev *chr; - /* fifo for key pressed */ - Fifo8 out_fifo; } QemuTextConsole; =20 typedef QemuConsoleClass QemuTextConsoleClass; @@ -103,17 +114,9 @@ OBJECT_DEFINE_TYPE(QemuFixedTextConsole, qemu_fixed_te= xt_console, QEMU_FIXED_TEX =20 struct VCChardev { Chardev parent; - QemuTextConsole *console; =20 - enum TTYState state; - int esc_params[MAX_ESC_PARAMS]; - int nb_esc_params; - uint32_t utf8_state; /* UTF-8 DFA decoder state */ - uint32_t utf8_codepoint; /* accumulated UTF-8 code point */ - TextAttributes t_attrib; /* currently active text attributes */ - TextAttributes t_attrib_saved; - int x_saved, y_saved; ChardevVCEncoding encoding; + QemuTextConsole *console; }; typedef struct VCChardev VCChardev; =20 @@ -302,36 +305,35 @@ static void vt100_scroll(QemuVT100 *vt, int ydelta) vt100_refresh(vt); } =20 -static void qemu_text_console_flush(QemuTextConsole *s) +static void qemu_text_console_out_flush(QemuTextConsole *s) { uint32_t len, avail; =20 len =3D qemu_chr_be_can_write(s->chr); - avail =3D fifo8_num_used(&s->out_fifo); + avail =3D fifo8_num_used(&s->vt.out_fifo); while (len > 0 && avail > 0) { const uint8_t *buf; uint32_t size; =20 - buf =3D fifo8_pop_bufptr(&s->out_fifo, MIN(len, avail), &size); + buf =3D fifo8_pop_bufptr(&s->vt.out_fifo, MIN(len, avail), &size); qemu_chr_be_write(s->chr, buf, size); len =3D qemu_chr_be_can_write(s->chr); avail -=3D size; } } =20 -static void qemu_text_console_write(QemuTextConsole *s, const void *buf, s= ize_t len) +static void vt100_write(QemuVT100 *vt, const void *buf, size_t len) { uint32_t num_free; =20 - num_free =3D fifo8_num_free(&s->out_fifo); - fifo8_push_all(&s->out_fifo, buf, MIN(num_free, len)); - qemu_text_console_flush(s); + num_free =3D fifo8_num_free(&vt->out_fifo); + fifo8_push_all(&vt->out_fifo, buf, MIN(num_free, len)); + vt->out_flush(vt); } =20 /* called when an ascii key is pressed */ void qemu_text_console_handle_keysym(QemuTextConsole *s, int keysym) { - QemuVT100 *vt =3D &s->vt; uint8_t buf[16], *q; int c; =20 @@ -363,16 +365,16 @@ void qemu_text_console_handle_keysym(QemuTextConsole = *s, int keysym) *q++ =3D '\033'; *q++ =3D '['; *q++ =3D keysym & 0xff; - } else if (vt->echo && (keysym =3D=3D '\r' || keysym =3D=3D '\n'))= { + } else if (s->vt.echo && (keysym =3D=3D '\r' || keysym =3D=3D '\n'= )) { qemu_chr_write(s->chr, (uint8_t *)"\r", 1, true); *q++ =3D '\n'; } else { *q++ =3D keysym; } - if (vt->echo) { + if (s->vt.echo) { qemu_chr_write(s->chr, buf, q - buf, true); } - qemu_text_console_write(s, buf, q - buf); + vt100_write(&s->vt, buf, q - buf); break; } } @@ -380,30 +382,29 @@ void qemu_text_console_handle_keysym(QemuTextConsole = *s, int keysym) static void text_console_update(void *opaque, console_ch_t *chardata) { QemuTextConsole *s =3D QEMU_TEXT_CONSOLE(opaque); - QemuVT100 *vt =3D &s->vt; int i, j, src; =20 - if (vt->text_x[0] <=3D vt->text_x[1]) { - src =3D (vt->y_base + vt->text_y[0]) * vt->width; - chardata +=3D vt->text_y[0] * vt->width; - for (i =3D vt->text_y[0]; i <=3D vt->text_y[1]; i ++) - for (j =3D 0; j < vt->width; j++, src++) { + if (s->vt.text_x[0] <=3D s->vt.text_x[1]) { + src =3D (s->vt.y_base + s->vt.text_y[0]) * s->vt.width; + chardata +=3D s->vt.text_y[0] * s->vt.width; + for (i =3D s->vt.text_y[0]; i <=3D s->vt.text_y[1]; i ++) + for (j =3D 0; j < s->vt.width; j++, src++) { console_write_ch(chardata ++, - ATTR2CHTYPE(vt->cells[src].ch, - vt->cells[src].t_attrib.fgcol, - vt->cells[src].t_attrib.bgcol, - vt->cells[src].t_attrib.bold)= ); + ATTR2CHTYPE(s->vt.cells[src].ch, + s->vt.cells[src].t_attrib.fgc= ol, + s->vt.cells[src].t_attrib.bgc= ol, + s->vt.cells[src].t_attrib.bol= d)); } - dpy_text_update(QEMU_CONSOLE(s), vt->text_x[0], vt->text_y[0], - vt->text_x[1] - vt->text_x[0], i - vt->text_y[0]); - vt->text_x[0] =3D vt->width; - vt->text_y[0] =3D vt->height; - vt->text_x[1] =3D 0; - vt->text_y[1] =3D 0; + dpy_text_update(QEMU_CONSOLE(s), s->vt.text_x[0], s->vt.text_y[0], + s->vt.text_x[1] - s->vt.text_x[0], i - s->vt.text_= y[0]); + s->vt.text_x[0] =3D s->vt.width; + s->vt.text_y[0] =3D s->vt.height; + s->vt.text_x[1] =3D 0; + s->vt.text_y[1] =3D 0; } - if (vt->cursor_invalidate) { - dpy_text_cursor(QEMU_CONSOLE(s), vt->x, vt->y); - vt->cursor_invalidate =3D 0; + if (s->vt.cursor_invalidate) { + dpy_text_cursor(QEMU_CONSOLE(s), s->vt.x, s->vt.y); + s->vt.cursor_invalidate =3D 0; } } =20 @@ -492,103 +493,101 @@ static void vt100_put_lf(QemuVT100 *vt) * NOTE: I know this code is not very efficient (checking every color for = it * self) but it is more readable and better maintainable. */ -static void vc_handle_escape(VCChardev *vc) +static void vt100_handle_escape(QemuVT100 *vt) { int i; =20 - for (i =3D 0; i < vc->nb_esc_params; i++) { - switch (vc->esc_params[i]) { + for (i =3D 0; i < vt->nb_esc_params; i++) { + switch (vt->esc_params[i]) { case 0: /* reset all console attributes to default */ - vc->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; + vt->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; break; case 1: - vc->t_attrib.bold =3D 1; + vt->t_attrib.bold =3D 1; break; case 4: - vc->t_attrib.uline =3D 1; + vt->t_attrib.uline =3D 1; break; case 5: - vc->t_attrib.blink =3D 1; + vt->t_attrib.blink =3D 1; break; case 7: - vc->t_attrib.invers =3D 1; + vt->t_attrib.invers =3D 1; break; case 8: - vc->t_attrib.unvisible =3D 1; + vt->t_attrib.unvisible =3D 1; break; case 22: - vc->t_attrib.bold =3D 0; + vt->t_attrib.bold =3D 0; break; case 24: - vc->t_attrib.uline =3D 0; + vt->t_attrib.uline =3D 0; break; case 25: - vc->t_attrib.blink =3D 0; + vt->t_attrib.blink =3D 0; break; case 27: - vc->t_attrib.invers =3D 0; + vt->t_attrib.invers =3D 0; break; case 28: - vc->t_attrib.unvisible =3D 0; + vt->t_attrib.unvisible =3D 0; break; /* set foreground color */ case 30: - vc->t_attrib.fgcol =3D QEMU_COLOR_BLACK; + vt->t_attrib.fgcol =3D QEMU_COLOR_BLACK; break; case 31: - vc->t_attrib.fgcol =3D QEMU_COLOR_RED; + vt->t_attrib.fgcol =3D QEMU_COLOR_RED; break; case 32: - vc->t_attrib.fgcol =3D QEMU_COLOR_GREEN; + vt->t_attrib.fgcol =3D QEMU_COLOR_GREEN; break; case 33: - vc->t_attrib.fgcol =3D QEMU_COLOR_YELLOW; + vt->t_attrib.fgcol =3D QEMU_COLOR_YELLOW; break; case 34: - vc->t_attrib.fgcol =3D QEMU_COLOR_BLUE; + vt->t_attrib.fgcol =3D QEMU_COLOR_BLUE; break; case 35: - vc->t_attrib.fgcol =3D QEMU_COLOR_MAGENTA; + vt->t_attrib.fgcol =3D QEMU_COLOR_MAGENTA; break; case 36: - vc->t_attrib.fgcol =3D QEMU_COLOR_CYAN; + vt->t_attrib.fgcol =3D QEMU_COLOR_CYAN; break; case 37: - vc->t_attrib.fgcol =3D QEMU_COLOR_WHITE; + vt->t_attrib.fgcol =3D QEMU_COLOR_WHITE; break; /* set background color */ case 40: - vc->t_attrib.bgcol =3D QEMU_COLOR_BLACK; + vt->t_attrib.bgcol =3D QEMU_COLOR_BLACK; break; case 41: - vc->t_attrib.bgcol =3D QEMU_COLOR_RED; + vt->t_attrib.bgcol =3D QEMU_COLOR_RED; break; case 42: - vc->t_attrib.bgcol =3D QEMU_COLOR_GREEN; + vt->t_attrib.bgcol =3D QEMU_COLOR_GREEN; break; case 43: - vc->t_attrib.bgcol =3D QEMU_COLOR_YELLOW; + vt->t_attrib.bgcol =3D QEMU_COLOR_YELLOW; break; case 44: - vc->t_attrib.bgcol =3D QEMU_COLOR_BLUE; + vt->t_attrib.bgcol =3D QEMU_COLOR_BLUE; break; case 45: - vc->t_attrib.bgcol =3D QEMU_COLOR_MAGENTA; + vt->t_attrib.bgcol =3D QEMU_COLOR_MAGENTA; break; case 46: - vc->t_attrib.bgcol =3D QEMU_COLOR_CYAN; + vt->t_attrib.bgcol =3D QEMU_COLOR_CYAN; break; case 47: - vc->t_attrib.bgcol =3D QEMU_COLOR_WHITE; + vt->t_attrib.bgcol =3D QEMU_COLOR_WHITE; break; } } } =20 -static void vc_update_xy(VCChardev *vc, int x, int y) +static void vt100_update_xy(QemuVT100 *vt, int x, int y) { - QemuTextConsole *s =3D vc->console; - QemuVT100 *vt =3D &s->vt; TextCell *c; int y1, y2; =20 @@ -609,14 +608,12 @@ static void vc_update_xy(VCChardev *vc, int x, int y) c =3D &vt->cells[y1 * vt->width + x]; vt100_putcharxy(vt, x, y2, c->ch, &(c->t_attrib)); - vt100_invalidate_xy(&s->vt, x, y2); + vt100_invalidate_xy(vt, x, y2); } } =20 -static void vc_clear_xy(VCChardev *vc, int x, int y) +static void vt100_clear_xy(QemuVT100 *vt, int x, int y) { - QemuTextConsole *s =3D vc->console; - QemuVT100 *vt =3D &s->vt; int y1 =3D (vt->y_base + y) % vt->total_height; if (x >=3D vt->width) { x =3D vt->width - 1; @@ -624,7 +621,7 @@ static void vc_clear_xy(VCChardev *vc, int x, int y) TextCell *c =3D &vt->cells[y1 * vt->width + x]; c->ch =3D ' '; c->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; - vc_update_xy(vc, x, y); + vt100_update_xy(vt, x, y); } =20 /* @@ -667,10 +664,8 @@ static uint32_t bh_utf8_decode(uint32_t *state, uint32= _t *codep, uint32_t byte) return *state; } =20 -static void vc_put_one(VCChardev *vc, int ch) +static void vt100_put_one(QemuVT100 *vt, int ch) { - QemuTextConsole *s =3D vc->console; - QemuVT100 *vt =3D &s->vt; TextCell *c; int y1; if (vt->x >=3D vt->width) { @@ -681,17 +676,14 @@ static void vc_put_one(VCChardev *vc, int ch) y1 =3D (vt->y_base + vt->y) % vt->total_height; c =3D &vt->cells[y1 * vt->width + vt->x]; c->ch =3D ch; - c->t_attrib =3D vc->t_attrib; - vc_update_xy(vc, vt->x, vt->y); + c->t_attrib =3D vt->t_attrib; + vt100_update_xy(vt, vt->x, vt->y); vt->x++; } =20 /* set cursor, checking bounds */ -static void vc_set_cursor(VCChardev *vc, int x, int y) +static void vt100_set_cursor(QemuVT100 *vt, int x, int y) { - QemuTextConsole *s =3D vc->console; - QemuVT100 *vt =3D &s->vt; - if (x < 0) { x =3D 0; } @@ -715,10 +707,8 @@ static void vc_set_cursor(VCChardev *vc, int x, int y) * characters between the cursor and right margin move to the * left. Character attributes move with the characters. */ -static void vc_csi_P(struct VCChardev *vc, unsigned int nr) +static void vt100_csi_P(QemuVT100 *vt, unsigned int nr) { - QemuTextConsole *s =3D vc->console; - QemuVT100 *vt =3D &s->vt; TextCell *c1, *c2; unsigned int x1, x2, y; unsigned int end, len; @@ -742,12 +732,12 @@ static void vc_csi_P(struct VCChardev *vc, unsigned i= nt nr) c2 =3D &vt->cells[y * vt->width + x2]; memmove(c1, c2, len * sizeof(*c1)); for (end =3D x1 + len; x1 < end; x1++) { - vc_update_xy(vc, x1, vt->y); + vt100_update_xy(vt, x1, vt->y); } } /* Clear the rest */ for (; x1 < vt->width; x1++) { - vc_clear_xy(vc, x1, vt->y); + vt100_clear_xy(vt, x1, vt->y); } } =20 @@ -757,10 +747,8 @@ static void vc_csi_P(struct VCChardev *vc, unsigned in= t nr) * blank characters. Text between the cursor and right margin moves to * the right. Characters scrolled past the right margin are lost. */ -static void vc_csi_at(struct VCChardev *vc, unsigned int nr) +static void vt100_csi_at(QemuVT100 *vt, unsigned int nr) { - QemuTextConsole *s =3D vc->console; - QemuVT100 *vt =3D &s->vt; TextCell *c1, *c2; unsigned int x1, x2, y; unsigned int end, len; @@ -784,59 +772,51 @@ static void vc_csi_at(struct VCChardev *vc, unsigned = int nr) c2 =3D &vt->cells[y * vt->width + x2]; memmove(c1, c2, len * sizeof(*c1)); for (end =3D x1 + len; x1 < end; x1++) { - vc_update_xy(vc, x1, vt->y); + vt100_update_xy(vt, x1, vt->y); } } /* Insert blanks */ for (x1 =3D vt->x; x1 < vt->x + nr; x1++) { - vc_clear_xy(vc, x1, vt->y); + vt100_clear_xy(vt, x1, vt->y); } } =20 /** - * vc_save_cursor() - saves cursor position and character attributes. + * vt100_save_cursor() - saves cursor position and character attributes. */ -static void vc_save_cursor(VCChardev *vc) +static void vt100_save_cursor(QemuVT100 *vt) { - QemuTextConsole *s =3D vc->console; - QemuVT100 *vt =3D &s->vt; - - vc->x_saved =3D vt->x; - vc->y_saved =3D vt->y; - vc->t_attrib_saved =3D vc->t_attrib; + vt->x_saved =3D vt->x; + vt->y_saved =3D vt->y; + vt->t_attrib_saved =3D vt->t_attrib; } =20 /** - * vc_restore_cursor() - restores cursor position and character + * vt100_restore_cursor() - restores cursor position and character * attributes from saved state. */ -static void vc_restore_cursor(VCChardev *vc) +static void vt100_restore_cursor(QemuVT100 *vt) { - QemuTextConsole *s =3D vc->console; - QemuVT100 *vt =3D &s->vt; - - vt->x =3D vc->x_saved; - vt->y =3D vc->y_saved; - vc->t_attrib =3D vc->t_attrib_saved; + vt->x =3D vt->x_saved; + vt->y =3D vt->y_saved; + vt->t_attrib =3D vt->t_attrib_saved; } =20 -static void vc_putchar(VCChardev *vc, int ch) +static void vt100_putchar(QemuVT100 *vt, int ch) { - QemuTextConsole *s =3D vc->console; - QemuVT100 *vt =3D &s->vt; int i; int x, y; g_autofree char *response =3D NULL; =20 - switch(vc->state) { + switch (vt->state) { case TTY_STATE_NORM: - if (ch >=3D 0x80 && vc->encoding =3D=3D CHARDEV_VC_ENCODING_UTF8) { - switch (bh_utf8_decode(&vc->utf8_state, &vc->utf8_codepoint, c= h)) { + if (ch >=3D 0x80 && vt->encoding =3D=3D CHARDEV_VC_ENCODING_UTF8) { + switch (bh_utf8_decode(&vt->utf8_state, &vt->utf8_codepoint, c= h)) { case BH_UTF8_ACCEPT: - vc_put_one(vc, unicode_to_cp437(vc->utf8_codepoint)); + vt100_put_one(vt, unicode_to_cp437(vt->utf8_codepoint)); break; case BH_UTF8_REJECT: - vc->utf8_state =3D BH_UTF8_ACCEPT; + vt->utf8_state =3D BH_UTF8_ACCEPT; break; default: /* Need more bytes */ @@ -844,14 +824,13 @@ static void vc_putchar(VCChardev *vc, int ch) } break; } - /* ASCII byte: abort any pending UTF-8 sequence */ - vc->utf8_state =3D BH_UTF8_ACCEPT; + vt->utf8_state =3D BH_UTF8_ACCEPT; switch(ch) { case '\r': /* carriage return */ vt->x =3D 0; break; case '\n': /* newline */ - vt100_put_lf(&s->vt); + vt100_put_lf(vt); break; case '\b': /* backspace */ if (vt->x > 0) @@ -875,95 +854,95 @@ static void vc_putchar(VCChardev *vc, int ch) /* SI (shift in), character set 0 (ignored) */ break; case 27: /* esc (introducing an escape sequence) */ - vc->state =3D TTY_STATE_ESC; + vt->state =3D TTY_STATE_ESC; break; default: - vc_put_one(vc, ch); + vt100_put_one(vt, ch); break; } break; case TTY_STATE_ESC: /* check if it is a terminal escape sequence */ if (ch =3D=3D '[') { for(i=3D0;iesc_params[i] =3D 0; - vc->nb_esc_params =3D 0; - vc->state =3D TTY_STATE_CSI; + vt->esc_params[i] =3D 0; + vt->nb_esc_params =3D 0; + vt->state =3D TTY_STATE_CSI; } else if (ch =3D=3D '(') { - vc->state =3D TTY_STATE_G0; + vt->state =3D TTY_STATE_G0; } else if (ch =3D=3D ')') { - vc->state =3D TTY_STATE_G1; + vt->state =3D TTY_STATE_G1; } else if (ch =3D=3D ']' || ch =3D=3D 'P' || ch =3D=3D 'X' || ch =3D=3D '^' || ch =3D=3D '_') { /* String sequences: OSC, DCS, SOS, PM, APC */ - vc->state =3D TTY_STATE_OSC; + vt->state =3D TTY_STATE_OSC; } else if (ch =3D=3D '7') { - vc_save_cursor(vc); - vc->state =3D TTY_STATE_NORM; + vt100_save_cursor(vt); + vt->state =3D TTY_STATE_NORM; } else if (ch =3D=3D '8') { - vc_restore_cursor(vc); - vc->state =3D TTY_STATE_NORM; + vt100_restore_cursor(vt); + vt->state =3D TTY_STATE_NORM; } else { - vc->state =3D TTY_STATE_NORM; + vt->state =3D TTY_STATE_NORM; } break; case TTY_STATE_CSI: /* handle escape sequence parameters */ if (ch >=3D '0' && ch <=3D '9') { - if (vc->nb_esc_params < MAX_ESC_PARAMS) { - int *param =3D &vc->esc_params[vc->nb_esc_params]; + if (vt->nb_esc_params < MAX_ESC_PARAMS) { + int *param =3D &vt->esc_params[vt->nb_esc_params]; int digit =3D (ch - '0'); =20 *param =3D (*param <=3D (INT_MAX - digit) / 10) ? *param * 10 + digit : INT_MAX; } } else { - if (vc->nb_esc_params < MAX_ESC_PARAMS) - vc->nb_esc_params++; + if (vt->nb_esc_params < MAX_ESC_PARAMS) + vt->nb_esc_params++; if (ch =3D=3D ';' || ch =3D=3D '?') { break; } - trace_console_putchar_csi(vc->esc_params[0], vc->esc_params[1], - ch, vc->nb_esc_params); - vc->state =3D TTY_STATE_NORM; + trace_console_putchar_csi(vt->esc_params[0], vt->esc_params[1], + ch, vt->nb_esc_params); + vt->state =3D TTY_STATE_NORM; switch(ch) { case 'A': /* move cursor up */ - if (vc->esc_params[0] =3D=3D 0) { - vc->esc_params[0] =3D 1; + if (vt->esc_params[0] =3D=3D 0) { + vt->esc_params[0] =3D 1; } - vc_set_cursor(vc, vt->x, vt->y - vc->esc_params[0]); + vt100_set_cursor(vt, vt->x, vt->y - vt->esc_params[0]); break; case 'B': /* move cursor down */ - if (vc->esc_params[0] =3D=3D 0) { - vc->esc_params[0] =3D 1; + if (vt->esc_params[0] =3D=3D 0) { + vt->esc_params[0] =3D 1; } - vc_set_cursor(vc, vt->x, vt->y + vc->esc_params[0]); + vt100_set_cursor(vt, vt->x, vt->y + vt->esc_params[0]); break; case 'C': /* move cursor right */ - if (vc->esc_params[0] =3D=3D 0) { - vc->esc_params[0] =3D 1; + if (vt->esc_params[0] =3D=3D 0) { + vt->esc_params[0] =3D 1; } - vc_set_cursor(vc, vt->x + vc->esc_params[0], vt->y); + vt100_set_cursor(vt, vt->x + vt->esc_params[0], vt->y); break; case 'D': /* move cursor left */ - if (vc->esc_params[0] =3D=3D 0) { - vc->esc_params[0] =3D 1; + if (vt->esc_params[0] =3D=3D 0) { + vt->esc_params[0] =3D 1; } - vc_set_cursor(vc, vt->x - vc->esc_params[0], vt->y); + vt100_set_cursor(vt, vt->x - vt->esc_params[0], vt->y); break; case 'G': /* move cursor to column */ - vc_set_cursor(vc, vc->esc_params[0] - 1, vt->y); + vt100_set_cursor(vt, vt->esc_params[0] - 1, vt->y); break; case 'f': case 'H': /* move cursor to row, column */ - vc_set_cursor(vc, vc->esc_params[1] - 1, vc->esc_params[0]= - 1); + vt100_set_cursor(vt, vt->esc_params[1] - 1, vt->esc_params= [0] - 1); break; case 'J': - switch (vc->esc_params[0]) { + switch (vt->esc_params[0]) { case 0: /* clear to end of screen */ for (y =3D vt->y; y < vt->height; y++) { @@ -971,7 +950,7 @@ static void vc_putchar(VCChardev *vc, int ch) if (y =3D=3D vt->y && x < vt->x) { continue; } - vc_clear_xy(vc, x, y); + vt100_clear_xy(vt, x, y); } } break; @@ -982,7 +961,7 @@ static void vc_putchar(VCChardev *vc, int ch) if (y =3D=3D vt->y && x > vt->x) { break; } - vc_clear_xy(vc, x, y); + vt100_clear_xy(vt, x, y); } } break; @@ -990,62 +969,62 @@ static void vc_putchar(VCChardev *vc, int ch) /* clear entire screen */ for (y =3D 0; y < vt->height; y++) { for (x =3D 0; x < vt->width; x++) { - vc_clear_xy(vc, x, y); + vt100_clear_xy(vt, x, y); } } break; } break; case 'K': - switch (vc->esc_params[0]) { + switch (vt->esc_params[0]) { case 0: /* clear to eol */ for(x =3D vt->x; x < vt->width; x++) { - vc_clear_xy(vc, x, vt->y); + vt100_clear_xy(vt, x, vt->y); } break; case 1: /* clear from beginning of line */ for (x =3D 0; x <=3D vt->x && x < vt->width; x++) { - vc_clear_xy(vc, x, vt->y); + vt100_clear_xy(vt, x, vt->y); } break; case 2: /* clear entire line */ for(x =3D 0; x < vt->width; x++) { - vc_clear_xy(vc, x, vt->y); + vt100_clear_xy(vt, x, vt->y); } break; } break; case 'P': - vc_csi_P(vc, vc->esc_params[0]); + vt100_csi_P(vt, vt->esc_params[0]); break; case 'm': - vc_handle_escape(vc); + vt100_handle_escape(vt); break; case 'n': - switch (vc->esc_params[0]) { + switch (vt->esc_params[0]) { case 5: /* report console status (always succeed)*/ - qemu_text_console_write(s, "\033[0n", 4); + vt100_write(vt, "\033[0n", 4); break; case 6: /* report cursor position */ response =3D g_strdup_printf("\033[%d;%dR", vt->y + 1, vt->x + 1); - qemu_text_console_write(s, response, strlen(response)); + vt100_write(vt, response, strlen(response)); break; } break; case 's': - vc_save_cursor(vc); + vt100_save_cursor(vt); break; case 'u': - vc_restore_cursor(vc); + vt100_restore_cursor(vt); break; case '@': - vc_csi_at(vc, vc->esc_params[0]); + vt100_csi_at(vt, vt->esc_params[0]); break; default: trace_console_putchar_unhandled(ch); @@ -1057,10 +1036,10 @@ static void vc_putchar(VCChardev *vc, int ch) case TTY_STATE_OSC: /* Operating System Command: ESC ] ... BEL/ST */ if (ch =3D=3D '\a') { /* BEL terminates OSC */ - vc->state =3D TTY_STATE_NORM; + vt->state =3D TTY_STATE_NORM; } else if (ch =3D=3D 27) { /* ESC might start ST (ESC \) */ - vc->state =3D TTY_STATE_ESC; + vt->state =3D TTY_STATE_ESC; } /* All other bytes are silently consumed */ break; @@ -1071,7 +1050,7 @@ static void vc_putchar(VCChardev *vc, int ch) /* Latin-1 map */ break; } - vc->state =3D TTY_STATE_NORM; + vt->state =3D TTY_STATE_NORM; break; } } @@ -1084,22 +1063,21 @@ static int vc_chr_write(Chardev *chr, const uint8_t= *buf, int len) { VCChardev *drv =3D VC_CHARDEV(chr); QemuTextConsole *s =3D drv->console; - QemuVT100 *vt =3D &s->vt; int i; =20 - vt->update_x0 =3D vt->width * FONT_WIDTH; - vt->update_y0 =3D vt->height * FONT_HEIGHT; - vt->update_x1 =3D 0; - vt->update_y1 =3D 0; - vt100_show_cursor(vt, 0); + s->vt.update_x0 =3D s->vt.width * FONT_WIDTH; + s->vt.update_y0 =3D s->vt.height * FONT_HEIGHT; + s->vt.update_x1 =3D 0; + s->vt.update_y1 =3D 0; + vt100_show_cursor(&s->vt, 0); for(i =3D 0; i < len; i++) { - vc_putchar(drv, buf[i]); + vt100_putchar(&s->vt, buf[i]); } - vt100_show_cursor(vt, 1); - if (vt->update_x0 < vt->update_x1) { - vt100_image_update(vt, vt->update_x0, vt->update_y0, - vt->update_x1 - vt->update_x0, - vt->update_y1 - vt->update_y0); + vt100_show_cursor(&s->vt, 1); + if (s->vt.update_x0 < s->vt.update_x1) { + vt100_image_update(&s->vt, s->vt.update_x0, s->vt.update_y0, + s->vt.update_x1 - s->vt.update_x0, + s->vt.update_y1 - s->vt.update_y0); } return len; } @@ -1168,9 +1146,6 @@ qemu_text_console_init(Object *obj) { QemuTextConsole *c =3D QEMU_TEXT_CONSOLE(obj); =20 - QTAILQ_INSERT_HEAD(&vt100s, &c->vt, list); - fifo8_create(&c->out_fifo, 16); - c->vt.total_height =3D DEFAULT_BACKSCROLL; QEMU_CONSOLE(c)->hw_ops =3D &text_console_ops; QEMU_CONSOLE(c)->hw =3D c; } @@ -1194,7 +1169,7 @@ static void vc_chr_accept_input(Chardev *chr) { VCChardev *drv =3D VC_CHARDEV(chr); =20 - qemu_text_console_flush(drv->console); + qemu_text_console_out_flush(drv->console); } =20 static void vc_chr_set_echo(Chardev *chr, bool echo) @@ -1216,6 +1191,13 @@ static void text_console_image_update(QemuVT100 *vt,= int x, int y, int width, in dpy_gfx_update(QEMU_CONSOLE(console), x, y, width, height); } =20 +static void text_console_out_flush(QemuVT100 *vt) +{ + QemuTextConsole *console =3D container_of(vt, QemuTextConsole, vt); + + qemu_text_console_out_flush(console); +} + static bool vc_chr_open(Chardev *chr, ChardevBackend *backend, Error **err= p) { ChardevVC *vc =3D backend->u.vc.data; @@ -1245,27 +1227,31 @@ static bool vc_chr_open(Chardev *chr, ChardevBacken= d *backend, Error **errp) s =3D QEMU_TEXT_CONSOLE(object_new(TYPE_QEMU_FIXED_TEXT_CONSOLE)); } =20 + QTAILQ_INSERT_HEAD(&vt100s, &s->vt, list); + fifo8_create(&s->vt.out_fifo, 16); + s->vt.total_height =3D DEFAULT_BACKSCROLL; dpy_gfx_replace_surface(QEMU_CONSOLE(s), qemu_create_displaysurface(wi= dth, height)); s->vt.image_update =3D text_console_image_update; + s->vt.out_flush =3D text_console_out_flush; =20 s->chr =3D chr; drv->console =3D s; if (vc->has_encoding) { - drv->encoding =3D vc->encoding; + drv->encoding =3D s->vt.encoding =3D vc->encoding; } =20 /* set current text attributes to default */ - drv->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; + s->vt.t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; vt100_set_image(&s->vt, QEMU_CONSOLE(s)->surface->image); =20 if (chr->label) { char *msg; =20 - drv->t_attrib.bgcol =3D QEMU_COLOR_BLUE; + s->vt.t_attrib.bgcol =3D QEMU_COLOR_BLUE; msg =3D g_strdup_printf("%s console\r\n", chr->label); qemu_chr_write(chr, (uint8_t *)msg, strlen(msg), true); g_free(msg); - drv->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; + s->vt.t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; } =20 qemu_chr_be_event(chr, CHR_EVENT_OPENED); --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778346960; cv=none; d=zohomail.com; s=zohoarc; b=Wflex8fl3Mqv+d3ffak2olgW9UQrRgOffodEu74wn2u9KDOKWp2znHwNbw8n9tP7V23AMxJexw1DYsUcsCYz5n1c1yYsAeEiLaophosbJF7pntuTpuwXGOlFXA5XVRAXyLMtiq5drTqATuGZEkDIGKuikpUa34cRu6AxXkvwwPs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778346960; 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=3iwc3OYHOoHTjXjkRX9blRiADAqmjvRfyL5oI3mbLZM=; b=k7/la3fRDPTF9a4OTej8wx4CIPWlvLoi4PXh92tbUSChc0qwkU02ZGee92dCaUN8a1AfOqd/3BYPV+GDhooS6fn9+ZKv+cXnPBi0FIjTHdh6B2XIJaQjdE/fB8u+Y9UDgu257DSyr1i5VBEQR5Tp7PrEpQGUFi/TQ7aGjXoWRPo= 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 1778346959994627.1149058359207; Sat, 9 May 2026 10:15:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlHN-0004HD-LG; Sat, 09 May 2026 13:15:53 -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 1wLlH7-0003gB-VQ for qemu-devel@nongnu.org; Sat, 09 May 2026 13:15:39 -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 1wLlH5-00056h-GS for qemu-devel@nongnu.org; Sat, 09 May 2026 13:15:36 -0400 Received: from mx-prod-mc-01.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-532-PEOP5W-6P4moTpGCtGRnKw-1; Sat, 09 May 2026 13:15:32 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5FCC5195608E; Sat, 9 May 2026 17:15:31 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4869A1800240; Sat, 9 May 2026 17:15:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778346933; 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=3iwc3OYHOoHTjXjkRX9blRiADAqmjvRfyL5oI3mbLZM=; b=cnnMwSnhGkJTUtMGjbPYcUaHAnndnV0ny73z+p576fZH/BwAbqEX3+n8ebMyb+T+R4sTnz 4n3YNyq1ZNgLeM6i/giex2jwS0KQIutwl9wItkbVsp/lzJB2SBcaGj0YeGitx/IPx+qOVL oFvkxWfj4ySjvy5dkiwVQH4BsxMs4d0= X-MC-Unique: PEOP5W-6P4moTpGCtGRnKw-1 X-Mimecast-MFC-AGG-ID: PEOP5W-6P4moTpGCtGRnKw_1778346931 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 15/33] ui/console-vc: extract vt100_input() from vc_chr_write() Date: Sat, 9 May 2026 21:13:36 +0400 Message-ID: <20260509171356.1157879-16-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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: 1778346962323158501 From: Marc-Andr=C3=A9 Lureau Move the VT100 input processing logic out of vc_chr_write() into a new vt100_input() function that operates on QemuVT100 directly, rather than going through the Chardev/VCChardev layers. This continues the effort to decouple the VT100 emulation from the chardev backend, making the VT100 layer self-contained and reusable. vc_chr_write() becomes a thin wrapper that extracts the QemuVT100 from the chardev and delegates to vt100_input(). Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/console-vc.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/ui/console-vc.c b/ui/console-vc.c index cf1adfc3c71..024ab277e0b 100644 --- a/ui/console-vc.c +++ b/ui/console-vc.c @@ -1059,29 +1059,35 @@ static void vt100_putchar(QemuVT100 *vt, int ch) DECLARE_INSTANCE_CHECKER(VCChardev, VC_CHARDEV, TYPE_CHARDEV_VC) =20 -static int vc_chr_write(Chardev *chr, const uint8_t *buf, int len) +static size_t vt100_input(QemuVT100 *vt, const uint8_t *buf, size_t len) { - VCChardev *drv =3D VC_CHARDEV(chr); - QemuTextConsole *s =3D drv->console; int i; =20 - s->vt.update_x0 =3D s->vt.width * FONT_WIDTH; - s->vt.update_y0 =3D s->vt.height * FONT_HEIGHT; - s->vt.update_x1 =3D 0; - s->vt.update_y1 =3D 0; - vt100_show_cursor(&s->vt, 0); + vt->update_x0 =3D vt->width * FONT_WIDTH; + vt->update_y0 =3D vt->height * FONT_HEIGHT; + vt->update_x1 =3D 0; + vt->update_y1 =3D 0; + vt100_show_cursor(vt, 0); for(i =3D 0; i < len; i++) { - vt100_putchar(&s->vt, buf[i]); + vt100_putchar(vt, buf[i]); } - vt100_show_cursor(&s->vt, 1); - if (s->vt.update_x0 < s->vt.update_x1) { - vt100_image_update(&s->vt, s->vt.update_x0, s->vt.update_y0, - s->vt.update_x1 - s->vt.update_x0, - s->vt.update_y1 - s->vt.update_y0); + vt100_show_cursor(vt, 1); + if (vt->update_x0 < vt->update_x1) { + vt100_image_update(vt, vt->update_x0, vt->update_y0, + vt->update_x1 - vt->update_x0, + vt->update_y1 - vt->update_y0); } return len; } =20 +static int vc_chr_write(Chardev *chr, const uint8_t *buf, int len) +{ + VCChardev *drv =3D VC_CHARDEV(chr); + QemuTextConsole *s =3D drv->console; + + return vt100_input(&s->vt, buf, len); +} + void vt100_update_cursor(void) { QemuVT100 *vt; --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778346992; cv=none; d=zohomail.com; s=zohoarc; b=WA1HXSIOSPhK1fHhf4HQstk1fSalN4QYE17rwd6qePg4GDps2EX45IuRBrpiiLO5EU1dNEm4MUeZRLsyu1ZLpJSKCs5yunT8UQ2/heYKykpquHZ83s0LeK3fpMstDSV8ZHzeByiKn3qvQLmtI0nT6ZDSGTBT8rbSM3SAc8Q1LPE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778346992; 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=TMekSOPI5rQd3UY/SVPKPlCnKO03Eg5wbvUG/hVtq7o=; b=K2wA0RLQKY+FO37aFuBFUl78mGfIdBa2WBrZ3yB07UWAARaqEvjriprGjN5l/HMcqHbm3R1UM5iRMDiVpGIajYjzkyFY9YSni4Hl1z9azcnvXcWwab27EH5u72v2abfwcIx2mPd7XVKG3m6zNiAE0NKbFfpSFCnstmK0Min6Rvo= 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 1778346992190245.54150674855703; Sat, 9 May 2026 10:16:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlHL-0003yA-1q; Sat, 09 May 2026 13:15:51 -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 1wLlHC-0003l0-8L for qemu-devel@nongnu.org; Sat, 09 May 2026 13:15:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wLlHA-00057T-Sq for qemu-devel@nongnu.org; Sat, 09 May 2026 13:15:41 -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-47-cpjM6WJZNbOErzJndFBvsw-1; Sat, 09 May 2026 13:15:38 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 6A9531956061; Sat, 9 May 2026 17:15:37 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 086401955D84; Sat, 9 May 2026 17:15:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778346940; 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=TMekSOPI5rQd3UY/SVPKPlCnKO03Eg5wbvUG/hVtq7o=; b=BhlO5U4IUaA4FWHibSW1GnDW1PQvLu1Hqjs1SGgtdvdtNgHDhryglO86czIF+tGK+Z6Aki zwPr3qCPGe18fLnNlTaWa692SmBVAmo6NT5eQe0+qk4CD6+euAE0Uy1ot22Be1q84J+H9y 5GXM7wME3Y0dpXHpRK8zerua64H4kkA= X-MC-Unique: cpjM6WJZNbOErzJndFBvsw-1 X-Mimecast-MFC-AGG-ID: cpjM6WJZNbOErzJndFBvsw_1778346937 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 16/33] ui/console-vc: extract vt100_keysym() from qemu_text_console_handle_keysym() Date: Sat, 9 May 2026 21:13:37 +0400 Message-ID: <20260509171356.1157879-17-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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.129.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_H4=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: 1778346999138154100 From: Marc-Andr=C3=A9 Lureau Move the keysym handling logic out of qemu_text_console_handle_keysym() into a new vt100_keysym() helper that operates on QemuVT100 directly, continuing the effort to decouple the VT100 layer from the console layer. The echo path is updated to call vt100_input() instead of qemu_chr_write(), since the function no longer has direct access to the chardev. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/console-vc.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/ui/console-vc.c b/ui/console-vc.c index 024ab277e0b..9f5f49413d2 100644 --- a/ui/console-vc.c +++ b/ui/console-vc.c @@ -331,24 +331,25 @@ static void vt100_write(QemuVT100 *vt, const void *bu= f, size_t len) vt->out_flush(vt); } =20 -/* called when an ascii key is pressed */ -void qemu_text_console_handle_keysym(QemuTextConsole *s, int keysym) +static int vt100_input(QemuVT100 *vt, const uint8_t *buf, int len); + +static void vt100_keysym(QemuVT100 *vt, int keysym) { uint8_t buf[16], *q; int c; =20 switch(keysym) { case QEMU_KEY_CTRL_UP: - vt100_scroll(&s->vt, -1); + vt100_scroll(vt, -1); break; case QEMU_KEY_CTRL_DOWN: - vt100_scroll(&s->vt, 1); + vt100_scroll(vt, 1); break; case QEMU_KEY_CTRL_PAGEUP: - vt100_scroll(&s->vt, -10); + vt100_scroll(vt, -10); break; case QEMU_KEY_CTRL_PAGEDOWN: - vt100_scroll(&s->vt, 10); + vt100_scroll(vt, 10); break; default: /* convert the QEMU keysym to VT100 key string */ @@ -365,18 +366,24 @@ void qemu_text_console_handle_keysym(QemuTextConsole = *s, int keysym) *q++ =3D '\033'; *q++ =3D '['; *q++ =3D keysym & 0xff; - } else if (s->vt.echo && (keysym =3D=3D '\r' || keysym =3D=3D '\n'= )) { - qemu_chr_write(s->chr, (uint8_t *)"\r", 1, true); + } else if (vt->echo && (keysym =3D=3D '\r' || keysym =3D=3D '\n'))= { + vt100_input(vt, (uint8_t *)"\r", 1); *q++ =3D '\n'; } else { *q++ =3D keysym; } - if (s->vt.echo) { - qemu_chr_write(s->chr, buf, q - buf, true); + if (vt->echo) { + vt100_input(vt, buf, q - buf); } - vt100_write(&s->vt, buf, q - buf); + vt100_write(vt, buf, q - buf); break; } + +} +/* called when an ascii key is pressed */ +void qemu_text_console_handle_keysym(QemuTextConsole *s, int keysym) +{ + vt100_keysym(&s->vt, keysym); } =20 static void text_console_update(void *opaque, console_ch_t *chardata) --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778346981; cv=none; d=zohomail.com; s=zohoarc; b=eNoVjo2ZIu9tKK5ln2ngo62tWR6448Bo8ZPqZ48aQvanNjrTWL/p+8pcWWjPZVXOFhXAvnjgMatC6OgrvgyUVFf3SgolW09LLqOx20zHdLWznZ5ejy4KSCvqLpWmgI3LGw0JA0qGC+5d/9Pp2vGH13cKhkG8UeyjWZqtPdf3K9E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778346981; 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=7Ew8EtolbjA1D7Hs4jgTfKrH6QjkTzcJn1UfbgtMMQk=; b=Zx9/+Nwm28y8cVzYvFUEkvWp6nb4+VK8A+BLVq76oF2QzigLM+AVe/27e1uZllQ2QGCg3EA07umAoUooJouRxAc7QfEzVbNPRSe3xja0KnwoXVTaUYu7cmd6cYoXT1/MmQ7Tcg5+mk1OSQIj0nD/nOBbfPuWlhkSblHuSDIxDk0= 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 1778346981599233.10624360012446; Sat, 9 May 2026 10:16:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlHO-0004OV-Bx; Sat, 09 May 2026 13:15:54 -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 1wLlHH-0003qE-Ms for qemu-devel@nongnu.org; Sat, 09 May 2026 13:15:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wLlHG-00059S-6i for qemu-devel@nongnu.org; Sat, 09 May 2026 13:15:47 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-179-aVfZwtckP7WDAgx4PhCv4g-1; Sat, 09 May 2026 13:15:44 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1CAB81800343; Sat, 9 May 2026 17:15:43 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BB29119560A2; Sat, 9 May 2026 17:15:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778346945; 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=7Ew8EtolbjA1D7Hs4jgTfKrH6QjkTzcJn1UfbgtMMQk=; b=WopFJ0IQQ5FB9E0lPD8eIhdi2BLhSHCyv4xZEjbdhuQ+nMlsK7QqAowLmboOAEdJ175PBL i5tGqT/v/HglEe3wPk7f4z6gr3bb+oBD2okmseuiP9g2A27kj4OdHsgTow2xXNsue6Oiml qrP+TGpgrSOdxq1zxGD7YyCTnSsjO7o= X-MC-Unique: aVfZwtckP7WDAgx4PhCv4g-1 X-Mimecast-MFC-AGG-ID: aVfZwtckP7WDAgx4PhCv4g_1778346943 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 17/33] ui/console-vc: extract vt100_init() and vt100_fini() Date: Sat, 9 May 2026 21:13:38 +0400 Message-ID: <20260509171356.1157879-18-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 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: 1778346982347158500 From: Marc-Andr=C3=A9 Lureau Consolidate VT100 initialization and finalization into dedicated functions, continuing the extraction of the VT100 layer from the console/chardev code. vt100_init() gathers the scattered setup (cursor timer, list insertion, FIFO creation, default attributes, and image) that was previously spread across vc_chr_open() and qemu_text_console_class_init(). vt100_fini() pairs with it by handling list removal, FIFO destruction, and cells cleanup, replacing the open-coded QTAILQ_REMOVE in qemu_text_console_finalize(). Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/console-vc.c | 55 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 18 deletions(-) diff --git a/ui/console-vc.c b/ui/console-vc.c index 9f5f49413d2..b58fe5de827 100644 --- a/ui/console-vc.c +++ b/ui/console-vc.c @@ -331,7 +331,7 @@ static void vt100_write(QemuVT100 *vt, const void *buf,= size_t len) vt->out_flush(vt); } =20 -static int vt100_input(QemuVT100 *vt, const uint8_t *buf, int len); +static size_t vt100_input(QemuVT100 *vt, const uint8_t *buf, size_t len); =20 static void vt100_keysym(QemuVT100 *vt, int keysym) { @@ -1129,12 +1129,19 @@ static void text_console_invalidate(void *opaque) vt100_refresh(&s->vt); } =20 +static void vt100_fini(QemuVT100 *vt) +{ + QTAILQ_REMOVE(&vt100s, vt, list); + fifo8_destroy(&vt->out_fifo); + g_free(vt->cells); +} + static void qemu_text_console_finalize(Object *obj) { QemuTextConsole *s =3D QEMU_TEXT_CONSOLE(obj); =20 - QTAILQ_REMOVE(&vt100s, &s->vt, list); + vt100_fini(&s->vt); } =20 static void @@ -1142,10 +1149,6 @@ qemu_text_console_class_init(ObjectClass *oc, const = void *data) { QemuConsoleClass *cc =3D QEMU_CONSOLE_CLASS(oc); =20 - if (!cursor_timer) { - cursor_timer =3D timer_new_ms(QEMU_CLOCK_REALTIME, cursor_timer_cb= , NULL); - } - cc->get_label =3D qemu_text_console_get_label; } =20 @@ -1211,6 +1214,27 @@ static void text_console_out_flush(QemuVT100 *vt) qemu_text_console_out_flush(console); } =20 +static void vt100_init(QemuVT100 *vt, + pixman_image_t *image, + ChardevVCEncoding encoding, + void (*image_update)(QemuVT100 *vt, int x, int y, i= nt w, int h), + void (*out_flush)(QemuVT100 *vt)) +{ + if (!cursor_timer) { + cursor_timer =3D timer_new_ms(QEMU_CLOCK_REALTIME, cursor_timer_cb= , NULL); + } + + vt->encoding =3D encoding; + QTAILQ_INSERT_HEAD(&vt100s, vt, list); + fifo8_create(&vt->out_fifo, 16); + vt->total_height =3D DEFAULT_BACKSCROLL; + vt->image_update =3D image_update; + vt->out_flush =3D out_flush; + /* set current text attributes to default */ + vt->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; + vt100_set_image(vt, image); +} + static bool vc_chr_open(Chardev *chr, ChardevBackend *backend, Error **err= p) { ChardevVC *vc =3D backend->u.vc.data; @@ -1240,22 +1264,17 @@ static bool vc_chr_open(Chardev *chr, ChardevBacken= d *backend, Error **errp) s =3D QEMU_TEXT_CONSOLE(object_new(TYPE_QEMU_FIXED_TEXT_CONSOLE)); } =20 - QTAILQ_INSERT_HEAD(&vt100s, &s->vt, list); - fifo8_create(&s->vt.out_fifo, 16); - s->vt.total_height =3D DEFAULT_BACKSCROLL; dpy_gfx_replace_surface(QEMU_CONSOLE(s), qemu_create_displaysurface(wi= dth, height)); - s->vt.image_update =3D text_console_image_update; - s->vt.out_flush =3D text_console_out_flush; - - s->chr =3D chr; - drv->console =3D s; if (vc->has_encoding) { - drv->encoding =3D s->vt.encoding =3D vc->encoding; + drv->encoding =3D vc->encoding; } + vt100_init(&s->vt, QEMU_CONSOLE(s)->surface->image, + drv->encoding, + text_console_image_update, + text_console_out_flush); =20 - /* set current text attributes to default */ - s->vt.t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; - vt100_set_image(&s->vt, QEMU_CONSOLE(s)->surface->image); + s->chr =3D chr; + drv->console =3D s; =20 if (chr->label) { char *msg; --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778346983; cv=none; d=zohomail.com; s=zohoarc; b=mwXcJc3UFjVQXvKsm0/LuD0iuHbK/8e1Ox6fdt+vyyngZ0Qf6P7on519PQGqxo+t3/UCLH2N0c060GDnL/MzK7MxV9QtHgMl+XstwS3iqe0urYNkNpi1Y/No+LoZfA3zus5iJA/8ggP6pGc35ajQ9kY9qAWGl4CYWQV7pxpY3zY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778346983; 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=98Cqm6BjQKTa0eqNhJ32Z6It2suApfQCNYqXZHOYdYU=; b=HTY+qnAm2xD9S9VM7e2vUivJsDw8DUKf4tCFQ45ECttqrTVjpZIAVqCwXeEYz/C3EYYj2NTtpfibGRYP5EY65g6vkHUkKxIKEDZ1trlfaHBemgFKYpcZum3t49RNXXW3UXe6Y12xdnFl0xZa0wCGr2zG0I+WtpYATz2eg2PF2Ts= 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 177834698332916.05371827516933; Sat, 9 May 2026 10:16:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlHd-0005Mj-8d; Sat, 09 May 2026 13:16:10 -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 1wLlHR-0004k7-7n for qemu-devel@nongnu.org; Sat, 09 May 2026 13:15:57 -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 1wLlHP-0005Ah-3S for qemu-devel@nongnu.org; Sat, 09 May 2026 13:15:56 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-58-7So-lHtgNnKJSdNR3AUI4A-1; Sat, 09 May 2026 13:15:51 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1BE9A18005B5; Sat, 9 May 2026 17:15:49 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 61BC919560A2; Sat, 9 May 2026 17:15:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778346954; 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=98Cqm6BjQKTa0eqNhJ32Z6It2suApfQCNYqXZHOYdYU=; b=VBlQIMD9oHAAhR34mNnoXwYQrAi/YkQ0kMPhFNbDmUEPQFYSWB6q7EjVcluW0RcJJJGKzL OAbZ7X8mKqG5MQOLTe/6dEakkYHSGxlU/m40E8M9DPoEj6c8Vq99G2PYJT92Ly4Bb+TfWA tU93TuDc2E1j2aMeL/ZyJoHjVIIj+5Y= X-MC-Unique: 7So-lHtgNnKJSdNR3AUI4A-1 X-Mimecast-MFC-AGG-ID: 7So-lHtgNnKJSdNR3AUI4A_1778346949 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Aleksandar Rikalo , Gerd Hoffmann , "Michael S. Tsirkin" , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko , Dmitry Fleytman Subject: [PULL v2 18/33] ui/console: remove console_ch_t typedef and console_write_ch() Date: Sat, 9 May 2026 21:13:39 +0400 Message-ID: <20260509171356.1157879-19-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 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, SPF_HELO_PASS=-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 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: 1778346984791158500 From: Marc-Andr=C3=A9 Lureau Since commit e2f82e924d05 ("console: purge curses bits from console.h"), console_ch_t is a plain uint32_t typedef and console_write_ch() is a trivial assignment (*dest =3D ch). These abstractions were originally needed because console_ch_t was the curses chtype when CONFIG_CURSES was enabled, and console_write_ch() handled VGA-to-curses character translation. That commit moved the curses logic into curses_update(), making the typedef and helper dead abstractions. Replace console_ch_t with uint32_t and console_write_ch() calls with direct assignments. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/ui/console.h | 9 +-------- hw/display/jazz_led.c | 10 +++++----- hw/display/vga.c | 16 ++++++++-------- hw/display/virtio-gpu-base.c | 2 +- hw/display/virtio-vga.c | 2 +- hw/display/vmware_vga.c | 2 +- ui/console-vc.c | 11 +++++------ ui/console.c | 2 +- ui/curses.c | 6 +++--- 9 files changed, 26 insertions(+), 34 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 27eacc39cc0..2bf768ed482 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -336,13 +336,6 @@ int dpy_gl_ctx_make_current(QemuConsole *con, QEMUGLCo= ntext ctx); =20 bool console_has_gl(QemuConsole *con); =20 -typedef uint32_t console_ch_t; - -static inline void console_write_ch(console_ch_t *dest, uint32_t ch) -{ - *dest =3D ch; -} - enum { GRAPHIC_FLAGS_NONE =3D 0, /* require a console/display with GL callbacks */ @@ -377,7 +370,7 @@ void graphic_console_close(QemuConsole *con); void graphic_hw_update(QemuConsole *con); void graphic_hw_update_done(QemuConsole *con); void graphic_hw_invalidate(QemuConsole *con); -void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata); +void graphic_hw_text_update(QemuConsole *con, uint32_t *chardata); void graphic_hw_gl_block(QemuConsole *con, bool block); =20 void qemu_console_early_init(void); diff --git a/hw/display/jazz_led.c b/hw/display/jazz_led.c index 7d1a020d4d9..ee9758a94b5 100644 --- a/hw/display/jazz_led.c +++ b/hw/display/jazz_led.c @@ -228,7 +228,7 @@ static void jazz_led_invalidate_display(void *opaque) s->state |=3D REDRAW_SEGMENTS | REDRAW_BACKGROUND; } =20 -static void jazz_led_text_update(void *opaque, console_ch_t *chardata) +static void jazz_led_text_update(void *opaque, uint32_t *chardata) { LedState *s =3D opaque; char buf[3]; @@ -238,10 +238,10 @@ static void jazz_led_text_update(void *opaque, consol= e_ch_t *chardata) =20 /* TODO: draw the segments */ snprintf(buf, 3, "%02hhx", s->segments); - console_write_ch(chardata++, ATTR2CHTYPE(buf[0], QEMU_COLOR_BLUE, - QEMU_COLOR_BLACK, 1)); - console_write_ch(chardata++, ATTR2CHTYPE(buf[1], QEMU_COLOR_BLUE, - QEMU_COLOR_BLACK, 1)); + *chardata++ =3D ATTR2CHTYPE(buf[0], QEMU_COLOR_BLUE, + QEMU_COLOR_BLACK, 1); + *chardata++ =3D ATTR2CHTYPE(buf[1], QEMU_COLOR_BLUE, + QEMU_COLOR_BLACK, 1); =20 dpy_text_update(s->con, 0, 0, 2, 1); } diff --git a/hw/display/vga.c b/hw/display/vga.c index 776aa443246..2f266f47a39 100644 --- a/hw/display/vga.c +++ b/hw/display/vga.c @@ -1901,13 +1901,13 @@ static void vga_reset(void *opaque) ((v & 0x00000800) << 10) | ((v & 0x00007000) >> 1)) /* relay text rendering to the display driver * instead of doing a full vga_update_display() */ -static void vga_update_text(void *opaque, console_ch_t *chardata) +static void vga_update_text(void *opaque, uint32_t *chardata) { VGACommonState *s =3D opaque; int graphic_mode, i, cursor_offset, cursor_visible; int cw, cheight, width, height, size, c_min, c_max; uint32_t *src; - console_ch_t *dst, val; + uint32_t *dst, val; char msg_buffer[80]; int full_update =3D 0; =20 @@ -2007,14 +2007,14 @@ static void vga_update_text(void *opaque, console_c= h_t *chardata) =20 if (full_update) { for (i =3D 0; i < size; src ++, dst ++, i ++) - console_write_ch(dst, VMEM2CHTYPE(le32_to_cpu(*src))); + *dst =3D VMEM2CHTYPE(le32_to_cpu(*src)); =20 dpy_text_update(s->con, 0, 0, width, height); } else { c_max =3D 0; =20 for (i =3D 0; i < size; src ++, dst ++, i ++) { - console_write_ch(&val, VMEM2CHTYPE(le32_to_cpu(*src))); + val =3D VMEM2CHTYPE(le32_to_cpu(*src)); if (*dst !=3D val) { *dst =3D val; c_max =3D i; @@ -2023,7 +2023,7 @@ static void vga_update_text(void *opaque, console_ch_= t *chardata) } c_min =3D i; for (; i < size; src ++, dst ++, i ++) { - console_write_ch(&val, VMEM2CHTYPE(le32_to_cpu(*src))); + val =3D VMEM2CHTYPE(le32_to_cpu(*src)); if (*dst !=3D val) { *dst =3D val; c_max =3D i; @@ -2061,14 +2061,14 @@ static void vga_update_text(void *opaque, console_c= h_t *chardata) dpy_text_resize(s->con, s->last_width, height); =20 for (dst =3D chardata, i =3D 0; i < s->last_width * height; i ++) - console_write_ch(dst ++, ' '); + *dst++ =3D ' '; =20 size =3D strlen(msg_buffer); width =3D (s->last_width - size) / 2; dst =3D chardata + s->last_width + width; for (i =3D 0; i < size; i ++) - console_write_ch(dst ++, ATTR2CHTYPE(msg_buffer[i], QEMU_COLOR_BLU= E, - QEMU_COLOR_BLACK, 1)); + *dst++ =3D ATTR2CHTYPE(msg_buffer[i], QEMU_COLOR_BLUE, + QEMU_COLOR_BLACK, 1); =20 dpy_text_update(s->con, 0, 0, s->last_width, height); } diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index 94cf362d152..bdc24492850 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -88,7 +88,7 @@ static bool virtio_gpu_update_display(void *opaque) return true; } =20 -static void virtio_gpu_text_update(void *opaque, console_ch_t *chardata) +static void virtio_gpu_text_update(void *opaque, uint32_t *chardata) { } =20 diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c index f4713b91a66..efd4858f3d0 100644 --- a/hw/display/virtio-vga.c +++ b/hw/display/virtio-vga.c @@ -31,7 +31,7 @@ static bool virtio_vga_base_update_display(void *opaque) } } =20 -static void virtio_vga_base_text_update(void *opaque, console_ch_t *charda= ta) +static void virtio_vga_base_text_update(void *opaque, uint32_t *chardata) { VirtIOVGABase *vvga =3D opaque; VirtIOGPUBase *g =3D vvga->vgpu; diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c index c84c84a445e..11f13c98d7a 100644 --- a/hw/display/vmware_vga.c +++ b/hw/display/vmware_vga.c @@ -1184,7 +1184,7 @@ static void vmsvga_invalidate_display(void *opaque) s->invalidated =3D 1; } =20 -static void vmsvga_text_update(void *opaque, console_ch_t *chardata) +static void vmsvga_text_update(void *opaque, uint32_t *chardata) { struct vmsvga_state_s *s =3D opaque; =20 diff --git a/ui/console-vc.c b/ui/console-vc.c index b58fe5de827..b9da9ddf30d 100644 --- a/ui/console-vc.c +++ b/ui/console-vc.c @@ -386,7 +386,7 @@ void qemu_text_console_handle_keysym(QemuTextConsole *s= , int keysym) vt100_keysym(&s->vt, keysym); } =20 -static void text_console_update(void *opaque, console_ch_t *chardata) +static void text_console_update(void *opaque, uint32_t *chardata) { QemuTextConsole *s =3D QEMU_TEXT_CONSOLE(opaque); int i, j, src; @@ -396,11 +396,10 @@ static void text_console_update(void *opaque, console= _ch_t *chardata) chardata +=3D s->vt.text_y[0] * s->vt.width; for (i =3D s->vt.text_y[0]; i <=3D s->vt.text_y[1]; i ++) for (j =3D 0; j < s->vt.width; j++, src++) { - console_write_ch(chardata ++, - ATTR2CHTYPE(s->vt.cells[src].ch, - s->vt.cells[src].t_attrib.fgc= ol, - s->vt.cells[src].t_attrib.bgc= ol, - s->vt.cells[src].t_attrib.bol= d)); + *chardata++ =3D ATTR2CHTYPE(s->vt.cells[src].ch, + s->vt.cells[src].t_attrib.fgcol, + s->vt.cells[src].t_attrib.bgcol, + s->vt.cells[src].t_attrib.bold); } dpy_text_update(QEMU_CONSOLE(s), s->vt.text_x[0], s->vt.text_y[0], s->vt.text_x[1] - s->vt.text_x[0], i - s->vt.text_= y[0]); diff --git a/ui/console.c b/ui/console.c index 799d61ec1a5..1c75b1a355b 100644 --- a/ui/console.c +++ b/ui/console.c @@ -210,7 +210,7 @@ void graphic_hw_invalidate(QemuConsole *con) } } =20 -void graphic_hw_text_update(QemuConsole *con, console_ch_t *chardata) +void graphic_hw_text_update(QemuConsole *con, uint32_t *chardata) { if (con && con->hw_ops->text_update) { con->hw_ops->text_update(con->hw, chardata); diff --git a/ui/curses.c b/ui/curses.c index af4ccb4227d..96427aa6bb9 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -57,7 +57,7 @@ enum maybe_keycode { }; =20 static DisplayChangeListener *dcl; -static console_ch_t *screen; +static uint32_t *screen; static WINDOW *screenpad =3D NULL; static int width, height, gwidth, gheight, invalidate; static int px, py, sminx, sminy, smaxx, smaxy; @@ -68,7 +68,7 @@ static cchar_t *vga_to_curses; static void curses_update(DisplayChangeListener *dcl, int x, int y, int w, int h) { - console_ch_t *line; + uint32_t *line; g_autofree cchar_t *curses_line =3D g_new(cchar_t, width); wchar_t wch[CCHARW_MAX]; attr_t attrs; @@ -796,7 +796,7 @@ static void curses_display_init(DisplayState *ds, Displ= ayOptions *opts) if (opts->u.curses.charset) { font_charset =3D opts->u.curses.charset; } - screen =3D g_new0(console_ch_t, 160 * 100); + screen =3D g_new0(uint32_t, 160 * 100); vga_to_curses =3D g_new0(cchar_t, 256); curses_setup(); curses_keyboard_setup(); --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778347056; cv=none; d=zohomail.com; s=zohoarc; b=WRxQWuBuMHlTqFGNRb3v28yU2ssIRepndB+PcEup2N1OT6qDUX7BT+eP2BghygsGgf86gTGuQL4nzpr3NpxL9eFKIzijXXY7v8GC4hX6ju1yeztgrckMWVeCohdnIsNryGje5KBI81rA3VqCP8FQk1VxWhr//ml1mPlVeDk2QCc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778347056; 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=AlTEWTLpQUUNopLeImgEQbsh4TqUou4fT/ZEpaj4ltw=; b=OqdvbjMWK/VcHpPcJA9p8WgzqXHU9enrVeDhhHRFfQcYsUjCIfbf2T4NoR6fvNzNkmCubjRbOet2miHS7a7zYTlXseI+TUhh//p9VC/BFjMN6SwOk2Tl4q/NLJugbLIAZZgeoeoKWBCrijF5A1yfsV/79sCjEUypYtHlLQlosic= 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 177834705620061.69269801509927; Sat, 9 May 2026 10:17:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlHs-0005q6-3D; Sat, 09 May 2026 13:16:24 -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 1wLlHZ-0005Mc-Hy for qemu-devel@nongnu.org; Sat, 09 May 2026 13:16:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wLlHU-0005Bp-3Z for qemu-devel@nongnu.org; Sat, 09 May 2026 13:16:04 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-147-efepPg_GOxO8hez0Lu2E2Q-1; Sat, 09 May 2026 13:15:56 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AAD6B1800610; Sat, 9 May 2026 17:15:55 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 78F5C19560A2; Sat, 9 May 2026 17:15:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778346959; 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=AlTEWTLpQUUNopLeImgEQbsh4TqUou4fT/ZEpaj4ltw=; b=QBHRDb8XaTAlNFnikLS/n9ijd4DQdAYCgyoLfjWy3BlR4j509kupWl/lF2BnFjgXgydThS 8NPp922VfwlA5RTOdN43rn1iYLtzw9EiO/SvmxzUMUcALF8GJvTttnbzdJptfcfMmcDoX2 PzAUYi9hWPDfI87X5n12T7XfcWjjq5M= X-MC-Unique: efepPg_GOxO8hez0Lu2E2Q-1 X-Mimecast-MFC-AGG-ID: efepPg_GOxO8hez0Lu2E2Q_1778346955 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 19/33] ui/console-vc: move VT100 emulation into separate unit Date: Sat, 9 May 2026 21:13:40 +0400 Message-ID: <20260509171356.1157879-20-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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 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: 1778347058631154100 From: Marc-Andr=C3=A9 Lureau Move the VT100 terminal emulation code into dedicated ui/vt100.c and ui/vt100.h files, completing the extraction from console-vc.c started in the previous patches. This makes the VT100 layer a self-contained module that can be reused independently of the chardev/console infrastructure. The code is moved as-is, with minor coding style fixes (adding missing braces, fixing whitespace) applied during the move. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/console-priv.h | 1 - ui/vt100.h | 95 ++++ ui/console-vc-stubs.c | 1 + ui/console-vc.c | 1033 +---------------------------------------- ui/console.c | 2 + ui/vt100.c | 984 +++++++++++++++++++++++++++++++++++++++ ui/meson.build | 4 +- 7 files changed, 1086 insertions(+), 1034 deletions(-) create mode 100644 ui/vt100.h create mode 100644 ui/vt100.c diff --git a/ui/console-priv.h b/ui/console-priv.h index 2299898984d..4f731b4f9ce 100644 --- a/ui/console-priv.h +++ b/ui/console-priv.h @@ -30,7 +30,6 @@ struct QemuConsole { }; =20 void qemu_text_console_update_size(QemuTextConsole *c); -void vt100_update_cursor(void); void qemu_text_console_handle_keysym(QemuTextConsole *s, int keysym); =20 #endif diff --git a/ui/vt100.h b/ui/vt100.h new file mode 100644 index 00000000000..22ce2368bff --- /dev/null +++ b/ui/vt100.h @@ -0,0 +1,95 @@ +/* + * SPDX-License-Identifier: MIT + * QEMU vt100 + */ +#ifndef VT100_H +#define VT100_H + +#include "chardev/char.h" +#include "ui/console.h" +#include "qemu/fifo8.h" +#include "qemu/queue.h" + +typedef struct TextAttributes { + uint8_t fgcol:4; + uint8_t bgcol:4; + uint8_t bold:1; + uint8_t uline:1; + uint8_t blink:1; + uint8_t invers:1; + uint8_t unvisible:1; +} TextAttributes; + +#define TEXT_ATTRIBUTES_DEFAULT ((TextAttributes) { \ + .fgcol =3D QEMU_COLOR_WHITE, \ + .bgcol =3D QEMU_COLOR_BLACK \ +}) + +typedef struct TextCell { + uint8_t ch; + TextAttributes t_attrib; +} TextCell; + +#define MAX_ESC_PARAMS 3 + +enum TTYState { + TTY_STATE_NORM, + TTY_STATE_ESC, + TTY_STATE_CSI, + TTY_STATE_G0, + TTY_STATE_G1, + TTY_STATE_OSC, +}; + +typedef struct QemuVT100 QemuVT100; + +struct QemuVT100 { + pixman_image_t *image; + void (*image_update)(QemuVT100 *vt, int x, int y, int width, int heigh= t); + + ChardevVCEncoding encoding; + int width; + int height; + int total_height; + int backscroll_height; + int x, y; + int y_displayed; + int y_base; + TextCell *cells; + int text_x[2], text_y[2], cursor_invalidate; + int echo; + + int update_x0; + int update_y0; + int update_x1; + int update_y1; + + enum TTYState state; + int esc_params[MAX_ESC_PARAMS]; + int nb_esc_params; + uint32_t utf8_state; /* UTF-8 DFA decoder state */ + uint32_t utf8_codepoint; /* accumulated UTF-8 code point */ + TextAttributes t_attrib; /* currently active text attributes */ + TextAttributes t_attrib_saved; + int x_saved, y_saved; + /* fifo for key pressed */ + Fifo8 out_fifo; + void (*out_flush)(QemuVT100 *vt); + + QTAILQ_ENTRY(QemuVT100) list; +}; + +void vt100_init(QemuVT100 *vt, + pixman_image_t *image, + ChardevVCEncoding encoding, + void (*image_update)(QemuVT100 *vt, int x, int y, int widt= h, int height), + void (*out_flush)(QemuVT100 *vt)); +void vt100_fini(QemuVT100 *vt); + +void vt100_update_cursor(void); +size_t vt100_input(QemuVT100 *vt, const uint8_t *buf, size_t len); +void vt100_keysym(QemuVT100 *vt, int keysym); +void vt100_set_image(QemuVT100 *vt, pixman_image_t *image); +void vt100_refresh(QemuVT100 *vt); + +#endif diff --git a/ui/console-vc-stubs.c b/ui/console-vc-stubs.c index d911a82f263..30e4d101197 100644 --- a/ui/console-vc-stubs.c +++ b/ui/console-vc-stubs.c @@ -9,6 +9,7 @@ #include "qemu/option.h" #include "chardev/char.h" #include "ui/console-priv.h" +#include "vt100.h" =20 void qemu_text_console_update_size(QemuTextConsole *c) { diff --git a/ui/console-vc.c b/ui/console-vc.c index b9da9ddf30d..99ad6d079df 100644 --- a/ui/console-vc.c +++ b/ui/console-vc.c @@ -6,93 +6,17 @@ =20 #include "chardev/char.h" #include "qapi/error.h" -#include "qemu/fifo8.h" #include "qemu/option.h" #include "qemu/queue.h" #include "qom/compat-properties.h" #include "ui/console.h" #include "ui/vgafont.h" -#include "ui/cp437.h" +#include "ui/vt100.h" =20 #include "pixman.h" #include "trace.h" #include "console-priv.h" =20 -#define DEFAULT_BACKSCROLL 512 -#define CONSOLE_CURSOR_PERIOD 500 - -typedef struct TextAttributes { - uint8_t fgcol:4; - uint8_t bgcol:4; - uint8_t bold:1; - uint8_t uline:1; - uint8_t blink:1; - uint8_t invers:1; - uint8_t unvisible:1; -} TextAttributes; - -#define TEXT_ATTRIBUTES_DEFAULT ((TextAttributes) { \ - .fgcol =3D QEMU_COLOR_WHITE, \ - .bgcol =3D QEMU_COLOR_BLACK \ -}) - -typedef struct TextCell { - uint8_t ch; - TextAttributes t_attrib; -} TextCell; - -#define MAX_ESC_PARAMS 3 - -enum TTYState { - TTY_STATE_NORM, - TTY_STATE_ESC, - TTY_STATE_CSI, - TTY_STATE_G0, - TTY_STATE_G1, - TTY_STATE_OSC, -}; - -typedef struct QemuVT100 QemuVT100; - -struct QemuVT100 { - pixman_image_t *image; - void (*image_update)(QemuVT100 *vt, int x, int y, int width, int heigh= t); - - ChardevVCEncoding encoding; - int width; - int height; - int total_height; - int backscroll_height; - int x, y; - int y_displayed; - int y_base; - TextCell *cells; - int text_x[2], text_y[2], cursor_invalidate; - int echo; - - int update_x0; - int update_y0; - int update_x1; - int update_y1; - - enum TTYState state; - int esc_params[MAX_ESC_PARAMS]; - int nb_esc_params; - uint32_t utf8_state; /* UTF-8 DFA decoder state */ - uint32_t utf8_codepoint; /* accumulated UTF-8 code point */ - TextAttributes t_attrib; /* currently active text attributes */ - TextAttributes t_attrib_saved; - int x_saved, y_saved; - /* fifo for key pressed */ - Fifo8 out_fifo; - void (*out_flush)(QemuVT100 *vt); - - QTAILQ_ENTRY(QemuVT100) list; -}; - -static QTAILQ_HEAD(QemuVT100Head, QemuVT100) vt100s =3D - QTAILQ_HEAD_INITIALIZER(vt100s); - typedef struct QemuTextConsole { QemuConsole parent; =20 @@ -120,32 +44,6 @@ struct VCChardev { }; typedef struct VCChardev VCChardev; =20 -static const pixman_color_t color_table_rgb[2][8] =3D { - { /* dark */ - [QEMU_COLOR_BLACK] =3D QEMU_PIXMAN_COLOR_BLACK, - [QEMU_COLOR_BLUE] =3D QEMU_PIXMAN_COLOR(0x00, 0x00, 0xaa), /* = blue */ - [QEMU_COLOR_GREEN] =3D QEMU_PIXMAN_COLOR(0x00, 0xaa, 0x00), /* = green */ - [QEMU_COLOR_CYAN] =3D QEMU_PIXMAN_COLOR(0x00, 0xaa, 0xaa), /* = cyan */ - [QEMU_COLOR_RED] =3D QEMU_PIXMAN_COLOR(0xaa, 0x00, 0x00), /* = red */ - [QEMU_COLOR_MAGENTA] =3D QEMU_PIXMAN_COLOR(0xaa, 0x00, 0xaa), /* = magenta */ - [QEMU_COLOR_YELLOW] =3D QEMU_PIXMAN_COLOR(0xaa, 0xaa, 0x00), /* = yellow */ - [QEMU_COLOR_WHITE] =3D QEMU_PIXMAN_COLOR_GRAY, - }, - { /* bright */ - [QEMU_COLOR_BLACK] =3D QEMU_PIXMAN_COLOR_BLACK, - [QEMU_COLOR_BLUE] =3D QEMU_PIXMAN_COLOR(0x00, 0x00, 0xff), /* = blue */ - [QEMU_COLOR_GREEN] =3D QEMU_PIXMAN_COLOR(0x00, 0xff, 0x00), /* = green */ - [QEMU_COLOR_CYAN] =3D QEMU_PIXMAN_COLOR(0x00, 0xff, 0xff), /* = cyan */ - [QEMU_COLOR_RED] =3D QEMU_PIXMAN_COLOR(0xff, 0x00, 0x00), /* = red */ - [QEMU_COLOR_MAGENTA] =3D QEMU_PIXMAN_COLOR(0xff, 0x00, 0xff), /* = magenta */ - [QEMU_COLOR_YELLOW] =3D QEMU_PIXMAN_COLOR(0xff, 0xff, 0x00), /* = yellow */ - [QEMU_COLOR_WHITE] =3D QEMU_PIXMAN_COLOR(0xff, 0xff, 0xff), /* = white */ - } -}; - -static bool cursor_visible_phase; -static QEMUTimer *cursor_timer; - static char * qemu_text_console_get_label(const QemuConsole *c) { @@ -154,157 +52,6 @@ qemu_text_console_get_label(const QemuConsole *c) return tc->chr ? g_strdup(tc->chr->label) : NULL; } =20 -static void image_fill_rect(pixman_image_t *image, int posx, int posy, - int width, int height, pixman_color_t color) -{ - pixman_rectangle16_t rect =3D { - .x =3D posx, .y =3D posy, .width =3D width, .height =3D height - }; - - pixman_image_fill_rectangles(PIXMAN_OP_SRC, image, &color, 1, &rect); -} - -/* copy from (xs, ys) to (xd, yd) a rectangle of size (w, h) */ -static void image_bitblt(pixman_image_t *image, - int xs, int ys, int xd, int yd, int w, int h) -{ - pixman_image_composite(PIXMAN_OP_SRC, - image, NULL, image, - xs, ys, 0, 0, xd, yd, w, h); -} - -static void vt100_putcharxy(QemuVT100 *vt, int x, int y, int ch, - TextAttributes *t_attrib) -{ - static pixman_image_t *glyphs[256]; - pixman_color_t fgcol, bgcol; - - assert(vt->image); - if (t_attrib->invers) { - bgcol =3D color_table_rgb[t_attrib->bold][t_attrib->fgcol]; - fgcol =3D color_table_rgb[t_attrib->bold][t_attrib->bgcol]; - } else { - fgcol =3D color_table_rgb[t_attrib->bold][t_attrib->fgcol]; - bgcol =3D color_table_rgb[t_attrib->bold][t_attrib->bgcol]; - } - - if (!glyphs[ch]) { - glyphs[ch] =3D qemu_pixman_glyph_from_vgafont(FONT_HEIGHT, vgafont= 16, ch); - } - qemu_pixman_glyph_render(glyphs[ch], vt->image, - &fgcol, &bgcol, x, y, FONT_WIDTH, FONT_HEIGHT= ); -} - -static void vt100_invalidate_xy(QemuVT100 *vt, int x, int y) -{ - if (vt->update_x0 > x * FONT_WIDTH) { - vt->update_x0 =3D x * FONT_WIDTH; - } - if (vt->update_y0 > y * FONT_HEIGHT) { - vt->update_y0 =3D y * FONT_HEIGHT; - } - if (vt->update_x1 < (x + 1) * FONT_WIDTH) { - vt->update_x1 =3D (x + 1) * FONT_WIDTH; - } - if (vt->update_y1 < (y + 1) * FONT_HEIGHT) { - vt->update_y1 =3D (y + 1) * FONT_HEIGHT; - } -} - -static void vt100_show_cursor(QemuVT100 *vt, int show) -{ - TextCell *c; - int y, y1; - int x =3D vt->x; - - vt->cursor_invalidate =3D 1; - - if (x >=3D vt->width) { - x =3D vt->width - 1; - } - y1 =3D (vt->y_base + vt->y) % vt->total_height; - y =3D y1 - vt->y_displayed; - if (y < 0) { - y +=3D vt->total_height; - } - if (y < vt->height) { - c =3D &vt->cells[y1 * vt->width + x]; - if (show && cursor_visible_phase) { - TextAttributes t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; - t_attrib.invers =3D !(t_attrib.invers); /* invert fg and bg */ - vt100_putcharxy(vt, x, y, c->ch, &t_attrib); - } else { - vt100_putcharxy(vt, x, y, c->ch, &(c->t_attrib)); - } - vt100_invalidate_xy(vt, x, y); - } -} - -static void vt100_image_update(QemuVT100 *vt, int x, int y, int width, int= height) -{ - vt->image_update(vt, x, y, width, height); -} - -static void vt100_refresh(QemuVT100 *vt) -{ - TextCell *c; - int x, y, y1; - int w =3D pixman_image_get_width(vt->image); - int h =3D pixman_image_get_height(vt->image); - - vt->text_x[0] =3D 0; - vt->text_y[0] =3D 0; - vt->text_x[1] =3D vt->width - 1; - vt->text_y[1] =3D vt->height - 1; - vt->cursor_invalidate =3D 1; - - image_fill_rect(vt->image, 0, 0, w, h, - color_table_rgb[0][QEMU_COLOR_BLACK]); - y1 =3D vt->y_displayed; - for (y =3D 0; y < vt->height; y++) { - c =3D vt->cells + y1 * vt->width; - for (x =3D 0; x < vt->width; x++) { - vt100_putcharxy(vt, x, y, c->ch, - &(c->t_attrib)); - c++; - } - if (++y1 =3D=3D vt->total_height) { - y1 =3D 0; - } - } - vt100_show_cursor(vt, 1); - vt100_image_update(vt, 0, 0, w, h); -} - -static void vt100_scroll(QemuVT100 *vt, int ydelta) -{ - int i, y1; - - if (ydelta > 0) { - for(i =3D 0; i < ydelta; i++) { - if (vt->y_displayed =3D=3D vt->y_base) - break; - if (++vt->y_displayed =3D=3D vt->total_height) - vt->y_displayed =3D 0; - } - } else { - ydelta =3D -ydelta; - i =3D vt->backscroll_height; - if (i > vt->total_height - vt->height) - i =3D vt->total_height - vt->height; - y1 =3D vt->y_base - i; - if (y1 < 0) - y1 +=3D vt->total_height; - for(i =3D 0; i < ydelta; i++) { - if (vt->y_displayed =3D=3D y1) - break; - if (--vt->y_displayed < 0) - vt->y_displayed =3D vt->total_height - 1; - } - } - vt100_refresh(vt); -} - static void qemu_text_console_out_flush(QemuTextConsole *s) { uint32_t len, avail; @@ -322,64 +69,6 @@ static void qemu_text_console_out_flush(QemuTextConsole= *s) } } =20 -static void vt100_write(QemuVT100 *vt, const void *buf, size_t len) -{ - uint32_t num_free; - - num_free =3D fifo8_num_free(&vt->out_fifo); - fifo8_push_all(&vt->out_fifo, buf, MIN(num_free, len)); - vt->out_flush(vt); -} - -static size_t vt100_input(QemuVT100 *vt, const uint8_t *buf, size_t len); - -static void vt100_keysym(QemuVT100 *vt, int keysym) -{ - uint8_t buf[16], *q; - int c; - - switch(keysym) { - case QEMU_KEY_CTRL_UP: - vt100_scroll(vt, -1); - break; - case QEMU_KEY_CTRL_DOWN: - vt100_scroll(vt, 1); - break; - case QEMU_KEY_CTRL_PAGEUP: - vt100_scroll(vt, -10); - break; - case QEMU_KEY_CTRL_PAGEDOWN: - vt100_scroll(vt, 10); - break; - default: - /* convert the QEMU keysym to VT100 key string */ - q =3D buf; - if (keysym >=3D 0xe100 && keysym <=3D 0xe11f) { - *q++ =3D '\033'; - *q++ =3D '['; - c =3D keysym - 0xe100; - if (c >=3D 10) - *q++ =3D '0' + (c / 10); - *q++ =3D '0' + (c % 10); - *q++ =3D '~'; - } else if (keysym >=3D 0xe120 && keysym <=3D 0xe17f) { - *q++ =3D '\033'; - *q++ =3D '['; - *q++ =3D keysym & 0xff; - } else if (vt->echo && (keysym =3D=3D '\r' || keysym =3D=3D '\n'))= { - vt100_input(vt, (uint8_t *)"\r", 1); - *q++ =3D '\n'; - } else { - *q++ =3D keysym; - } - if (vt->echo) { - vt100_input(vt, buf, q - buf); - } - vt100_write(vt, buf, q - buf); - break; - } - -} /* called when an ascii key is pressed */ void qemu_text_console_handle_keysym(QemuTextConsole *s, int keysym) { @@ -414,678 +103,10 @@ static void text_console_update(void *opaque, uint32= _t *chardata) } } =20 -static void vt100_set_image(QemuVT100 *vt, pixman_image_t *image) -{ - TextCell *cells, *c, *c1; - int w1, x, y, last_width, w, h; - - vt->image =3D image; - w =3D pixman_image_get_width(image) / FONT_WIDTH; - h =3D pixman_image_get_height(image) / FONT_HEIGHT; - if (w =3D=3D vt->width && h =3D=3D vt->height) { - return; - } - - last_width =3D vt->width; - vt->width =3D w; - vt->height =3D h; - - w1 =3D MIN(vt->width, last_width); - - cells =3D g_new(TextCell, vt->width * vt->total_height + 1); - for (y =3D 0; y < vt->total_height; y++) { - c =3D &cells[y * vt->width]; - if (w1 > 0) { - c1 =3D &vt->cells[y * last_width]; - for (x =3D 0; x < w1; x++) { - *c++ =3D *c1++; - } - } - for (x =3D w1; x < vt->width; x++) { - c->ch =3D ' '; - c->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; - c++; - } - } - g_free(vt->cells); - vt->cells =3D cells; -} - -static void vt100_put_lf(QemuVT100 *vt) -{ - TextCell *c; - int x, y1; - - vt->y++; - if (vt->y >=3D vt->height) { - vt->y =3D vt->height - 1; - - if (vt->y_displayed =3D=3D vt->y_base) { - if (++vt->y_displayed =3D=3D vt->total_height) - vt->y_displayed =3D 0; - } - if (++vt->y_base =3D=3D vt->total_height) - vt->y_base =3D 0; - if (vt->backscroll_height < vt->total_height) - vt->backscroll_height++; - y1 =3D (vt->y_base + vt->height - 1) % vt->total_height; - c =3D &vt->cells[y1 * vt->width]; - for(x =3D 0; x < vt->width; x++) { - c->ch =3D ' '; - c->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; - c++; - } - if (vt->y_displayed =3D=3D vt->y_base) { - vt->text_x[0] =3D 0; - vt->text_y[0] =3D 0; - vt->text_x[1] =3D vt->width - 1; - vt->text_y[1] =3D vt->height - 1; - - image_bitblt(vt->image, 0, FONT_HEIGHT, 0, 0, - vt->width * FONT_WIDTH, - (vt->height - 1) * FONT_HEIGHT); - image_fill_rect(vt->image, 0, (vt->height - 1) * FONT_HEIGHT, - vt->width * FONT_WIDTH, FONT_HEIGHT, - color_table_rgb[0][TEXT_ATTRIBUTES_DEFAULT.bgc= ol]); - vt->update_x0 =3D 0; - vt->update_y0 =3D 0; - vt->update_x1 =3D vt->width * FONT_WIDTH; - vt->update_y1 =3D vt->height * FONT_HEIGHT; - } - } -} - -/* Set console attributes depending on the current escape codes. - * NOTE: I know this code is not very efficient (checking every color for = it - * self) but it is more readable and better maintainable. - */ -static void vt100_handle_escape(QemuVT100 *vt) -{ - int i; - - for (i =3D 0; i < vt->nb_esc_params; i++) { - switch (vt->esc_params[i]) { - case 0: /* reset all console attributes to default */ - vt->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; - break; - case 1: - vt->t_attrib.bold =3D 1; - break; - case 4: - vt->t_attrib.uline =3D 1; - break; - case 5: - vt->t_attrib.blink =3D 1; - break; - case 7: - vt->t_attrib.invers =3D 1; - break; - case 8: - vt->t_attrib.unvisible =3D 1; - break; - case 22: - vt->t_attrib.bold =3D 0; - break; - case 24: - vt->t_attrib.uline =3D 0; - break; - case 25: - vt->t_attrib.blink =3D 0; - break; - case 27: - vt->t_attrib.invers =3D 0; - break; - case 28: - vt->t_attrib.unvisible =3D 0; - break; - /* set foreground color */ - case 30: - vt->t_attrib.fgcol =3D QEMU_COLOR_BLACK; - break; - case 31: - vt->t_attrib.fgcol =3D QEMU_COLOR_RED; - break; - case 32: - vt->t_attrib.fgcol =3D QEMU_COLOR_GREEN; - break; - case 33: - vt->t_attrib.fgcol =3D QEMU_COLOR_YELLOW; - break; - case 34: - vt->t_attrib.fgcol =3D QEMU_COLOR_BLUE; - break; - case 35: - vt->t_attrib.fgcol =3D QEMU_COLOR_MAGENTA; - break; - case 36: - vt->t_attrib.fgcol =3D QEMU_COLOR_CYAN; - break; - case 37: - vt->t_attrib.fgcol =3D QEMU_COLOR_WHITE; - break; - /* set background color */ - case 40: - vt->t_attrib.bgcol =3D QEMU_COLOR_BLACK; - break; - case 41: - vt->t_attrib.bgcol =3D QEMU_COLOR_RED; - break; - case 42: - vt->t_attrib.bgcol =3D QEMU_COLOR_GREEN; - break; - case 43: - vt->t_attrib.bgcol =3D QEMU_COLOR_YELLOW; - break; - case 44: - vt->t_attrib.bgcol =3D QEMU_COLOR_BLUE; - break; - case 45: - vt->t_attrib.bgcol =3D QEMU_COLOR_MAGENTA; - break; - case 46: - vt->t_attrib.bgcol =3D QEMU_COLOR_CYAN; - break; - case 47: - vt->t_attrib.bgcol =3D QEMU_COLOR_WHITE; - break; - } - } -} - -static void vt100_update_xy(QemuVT100 *vt, int x, int y) -{ - TextCell *c; - int y1, y2; - - vt->text_x[0] =3D MIN(vt->text_x[0], x); - vt->text_x[1] =3D MAX(vt->text_x[1], x); - vt->text_y[0] =3D MIN(vt->text_y[0], y); - vt->text_y[1] =3D MAX(vt->text_y[1], y); - - y1 =3D (vt->y_base + y) % vt->total_height; - y2 =3D y1 - vt->y_displayed; - if (y2 < 0) { - y2 +=3D vt->total_height; - } - if (y2 < vt->height) { - if (x >=3D vt->width) { - x =3D vt->width - 1; - } - c =3D &vt->cells[y1 * vt->width + x]; - vt100_putcharxy(vt, x, y2, c->ch, - &(c->t_attrib)); - vt100_invalidate_xy(vt, x, y2); - } -} - -static void vt100_clear_xy(QemuVT100 *vt, int x, int y) -{ - int y1 =3D (vt->y_base + y) % vt->total_height; - if (x >=3D vt->width) { - x =3D vt->width - 1; - } - TextCell *c =3D &vt->cells[y1 * vt->width + x]; - c->ch =3D ' '; - c->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; - vt100_update_xy(vt, x, y); -} - -/* - * UTF-8 DFA decoder by Bjoern Hoehrmann. - * Copyright (c) 2008-2010 Bjoern Hoehrmann - * See https://github.com/polijan/utf8_decode for details. - * - * SPDX-License-Identifier: MIT - */ -#define BH_UTF8_ACCEPT 0 -#define BH_UTF8_REJECT 12 - -static uint32_t bh_utf8_decode(uint32_t *state, uint32_t *codep, uint32_t = byte) -{ - static const uint8_t utf8d[] =3D { - /* character class lookup */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, - 10,3,3,3,3,3,3,3,3,3,3,3,3,4,3,3, 11,6,6,6,5,8,8,8,8,8,8,8,8,8,8,8, - - /* state transition lookup */ - 0,12,24,36,60,96,84,12,12,12,48,72, 12,12,12,12,12,12,12,12,12,12,= 12,12, - 12, 0,12,12,12,12,12, 0,12, 0,12,12, 12,24,12,12,12,12,12,24,12,24= ,12,12, - 12,12,12,12,12,12,12,24,12,12,12,12, 12,24,12,12,12,12,12,12,12,24= ,12,12, - 12,12,12,12,12,12,12,36,12,36,12,12, 12,36,12,12,12,12,12,36,12,36= ,12,12, - 12,36,12,12,12,12,12,12,12,12,12,12, - }; - uint32_t type =3D utf8d[byte]; - - *codep =3D (*state !=3D BH_UTF8_ACCEPT) ? - (byte & 0x3fu) | (*codep << 6) : - (0xffu >> type) & (byte); - - *state =3D utf8d[256 + *state + type]; - return *state; -} - -static void vt100_put_one(QemuVT100 *vt, int ch) -{ - TextCell *c; - int y1; - if (vt->x >=3D vt->width) { - /* line wrap */ - vt->x =3D 0; - vt100_put_lf(vt); - } - y1 =3D (vt->y_base + vt->y) % vt->total_height; - c =3D &vt->cells[y1 * vt->width + vt->x]; - c->ch =3D ch; - c->t_attrib =3D vt->t_attrib; - vt100_update_xy(vt, vt->x, vt->y); - vt->x++; -} - -/* set cursor, checking bounds */ -static void vt100_set_cursor(QemuVT100 *vt, int x, int y) -{ - if (x < 0) { - x =3D 0; - } - if (y < 0) { - y =3D 0; - } - if (y >=3D vt->height) { - y =3D vt->height - 1; - } - if (x >=3D vt->width) { - x =3D vt->width - 1; - } - - vt->x =3D x; - vt->y =3D y; -} - -/** - * vc_csi_P() - (DCH) deletes one or more characters from the cursor - * position to the right. As characters are deleted, the remaining - * characters between the cursor and right margin move to the - * left. Character attributes move with the characters. - */ -static void vt100_csi_P(QemuVT100 *vt, unsigned int nr) -{ - TextCell *c1, *c2; - unsigned int x1, x2, y; - unsigned int end, len; - - if (!nr) { - nr =3D 1; - } - if (nr > vt->width - vt->x) { - nr =3D vt->width - vt->x; - if (!nr) { - return; - } - } - - x1 =3D vt->x; - x2 =3D vt->x + nr; - len =3D vt->width - x2; - if (len) { - y =3D (vt->y_base + vt->y) % vt->total_height; - c1 =3D &vt->cells[y * vt->width + x1]; - c2 =3D &vt->cells[y * vt->width + x2]; - memmove(c1, c2, len * sizeof(*c1)); - for (end =3D x1 + len; x1 < end; x1++) { - vt100_update_xy(vt, x1, vt->y); - } - } - /* Clear the rest */ - for (; x1 < vt->width; x1++) { - vt100_clear_xy(vt, x1, vt->y); - } -} - -/** - * vc_csi_at() - (ICH) inserts `nr` blank characters with the default - * character attribute. The cursor remains at the beginning of the - * blank characters. Text between the cursor and right margin moves to - * the right. Characters scrolled past the right margin are lost. - */ -static void vt100_csi_at(QemuVT100 *vt, unsigned int nr) -{ - TextCell *c1, *c2; - unsigned int x1, x2, y; - unsigned int end, len; - - if (!nr) { - nr =3D 1; - } - if (nr > vt->width - vt->x) { - nr =3D vt->width - vt->x; - if (!nr) { - return; - } - } - - x1 =3D vt->x + nr; - x2 =3D vt->x; - len =3D vt->width - x1; - if (len) { - y =3D (vt->y_base + vt->y) % vt->total_height; - c1 =3D &vt->cells[y * vt->width + x1]; - c2 =3D &vt->cells[y * vt->width + x2]; - memmove(c1, c2, len * sizeof(*c1)); - for (end =3D x1 + len; x1 < end; x1++) { - vt100_update_xy(vt, x1, vt->y); - } - } - /* Insert blanks */ - for (x1 =3D vt->x; x1 < vt->x + nr; x1++) { - vt100_clear_xy(vt, x1, vt->y); - } -} - -/** - * vt100_save_cursor() - saves cursor position and character attributes. - */ -static void vt100_save_cursor(QemuVT100 *vt) -{ - vt->x_saved =3D vt->x; - vt->y_saved =3D vt->y; - vt->t_attrib_saved =3D vt->t_attrib; -} - -/** - * vt100_restore_cursor() - restores cursor position and character - * attributes from saved state. - */ -static void vt100_restore_cursor(QemuVT100 *vt) -{ - vt->x =3D vt->x_saved; - vt->y =3D vt->y_saved; - vt->t_attrib =3D vt->t_attrib_saved; -} - -static void vt100_putchar(QemuVT100 *vt, int ch) -{ - int i; - int x, y; - g_autofree char *response =3D NULL; - - switch (vt->state) { - case TTY_STATE_NORM: - if (ch >=3D 0x80 && vt->encoding =3D=3D CHARDEV_VC_ENCODING_UTF8) { - switch (bh_utf8_decode(&vt->utf8_state, &vt->utf8_codepoint, c= h)) { - case BH_UTF8_ACCEPT: - vt100_put_one(vt, unicode_to_cp437(vt->utf8_codepoint)); - break; - case BH_UTF8_REJECT: - vt->utf8_state =3D BH_UTF8_ACCEPT; - break; - default: - /* Need more bytes */ - break; - } - break; - } - vt->utf8_state =3D BH_UTF8_ACCEPT; - switch(ch) { - case '\r': /* carriage return */ - vt->x =3D 0; - break; - case '\n': /* newline */ - vt100_put_lf(vt); - break; - case '\b': /* backspace */ - if (vt->x > 0) - vt->x--; - break; - case '\t': /* tabspace */ - if (vt->x + (8 - (vt->x % 8)) > vt->width) { - vt->x =3D 0; - vt100_put_lf(vt); - } else { - vt->x =3D vt->x + (8 - (vt->x % 8)); - } - break; - case '\a': /* alert aka. bell */ - /* TODO: has to be implemented */ - break; - case 14: - /* SO (shift out), character set 1 (ignored) */ - break; - case 15: - /* SI (shift in), character set 0 (ignored) */ - break; - case 27: /* esc (introducing an escape sequence) */ - vt->state =3D TTY_STATE_ESC; - break; - default: - vt100_put_one(vt, ch); - break; - } - break; - case TTY_STATE_ESC: /* check if it is a terminal escape sequence */ - if (ch =3D=3D '[') { - for(i=3D0;iesc_params[i] =3D 0; - vt->nb_esc_params =3D 0; - vt->state =3D TTY_STATE_CSI; - } else if (ch =3D=3D '(') { - vt->state =3D TTY_STATE_G0; - } else if (ch =3D=3D ')') { - vt->state =3D TTY_STATE_G1; - } else if (ch =3D=3D ']' || ch =3D=3D 'P' || ch =3D=3D 'X' - || ch =3D=3D '^' || ch =3D=3D '_') { - /* String sequences: OSC, DCS, SOS, PM, APC */ - vt->state =3D TTY_STATE_OSC; - } else if (ch =3D=3D '7') { - vt100_save_cursor(vt); - vt->state =3D TTY_STATE_NORM; - } else if (ch =3D=3D '8') { - vt100_restore_cursor(vt); - vt->state =3D TTY_STATE_NORM; - } else { - vt->state =3D TTY_STATE_NORM; - } - break; - case TTY_STATE_CSI: /* handle escape sequence parameters */ - if (ch >=3D '0' && ch <=3D '9') { - if (vt->nb_esc_params < MAX_ESC_PARAMS) { - int *param =3D &vt->esc_params[vt->nb_esc_params]; - int digit =3D (ch - '0'); - - *param =3D (*param <=3D (INT_MAX - digit) / 10) ? - *param * 10 + digit : INT_MAX; - } - } else { - if (vt->nb_esc_params < MAX_ESC_PARAMS) - vt->nb_esc_params++; - if (ch =3D=3D ';' || ch =3D=3D '?') { - break; - } - trace_console_putchar_csi(vt->esc_params[0], vt->esc_params[1], - ch, vt->nb_esc_params); - vt->state =3D TTY_STATE_NORM; - switch(ch) { - case 'A': - /* move cursor up */ - if (vt->esc_params[0] =3D=3D 0) { - vt->esc_params[0] =3D 1; - } - vt100_set_cursor(vt, vt->x, vt->y - vt->esc_params[0]); - break; - case 'B': - /* move cursor down */ - if (vt->esc_params[0] =3D=3D 0) { - vt->esc_params[0] =3D 1; - } - vt100_set_cursor(vt, vt->x, vt->y + vt->esc_params[0]); - break; - case 'C': - /* move cursor right */ - if (vt->esc_params[0] =3D=3D 0) { - vt->esc_params[0] =3D 1; - } - vt100_set_cursor(vt, vt->x + vt->esc_params[0], vt->y); - break; - case 'D': - /* move cursor left */ - if (vt->esc_params[0] =3D=3D 0) { - vt->esc_params[0] =3D 1; - } - vt100_set_cursor(vt, vt->x - vt->esc_params[0], vt->y); - break; - case 'G': - /* move cursor to column */ - vt100_set_cursor(vt, vt->esc_params[0] - 1, vt->y); - break; - case 'f': - case 'H': - /* move cursor to row, column */ - vt100_set_cursor(vt, vt->esc_params[1] - 1, vt->esc_params= [0] - 1); - break; - case 'J': - switch (vt->esc_params[0]) { - case 0: - /* clear to end of screen */ - for (y =3D vt->y; y < vt->height; y++) { - for (x =3D 0; x < vt->width; x++) { - if (y =3D=3D vt->y && x < vt->x) { - continue; - } - vt100_clear_xy(vt, x, y); - } - } - break; - case 1: - /* clear from beginning of screen */ - for (y =3D 0; y <=3D vt->y; y++) { - for (x =3D 0; x < vt->width; x++) { - if (y =3D=3D vt->y && x > vt->x) { - break; - } - vt100_clear_xy(vt, x, y); - } - } - break; - case 2: - /* clear entire screen */ - for (y =3D 0; y < vt->height; y++) { - for (x =3D 0; x < vt->width; x++) { - vt100_clear_xy(vt, x, y); - } - } - break; - } - break; - case 'K': - switch (vt->esc_params[0]) { - case 0: - /* clear to eol */ - for(x =3D vt->x; x < vt->width; x++) { - vt100_clear_xy(vt, x, vt->y); - } - break; - case 1: - /* clear from beginning of line */ - for (x =3D 0; x <=3D vt->x && x < vt->width; x++) { - vt100_clear_xy(vt, x, vt->y); - } - break; - case 2: - /* clear entire line */ - for(x =3D 0; x < vt->width; x++) { - vt100_clear_xy(vt, x, vt->y); - } - break; - } - break; - case 'P': - vt100_csi_P(vt, vt->esc_params[0]); - break; - case 'm': - vt100_handle_escape(vt); - break; - case 'n': - switch (vt->esc_params[0]) { - case 5: - /* report console status (always succeed)*/ - vt100_write(vt, "\033[0n", 4); - break; - case 6: - /* report cursor position */ - response =3D g_strdup_printf("\033[%d;%dR", - vt->y + 1, vt->x + 1); - vt100_write(vt, response, strlen(response)); - break; - } - break; - case 's': - vt100_save_cursor(vt); - break; - case 'u': - vt100_restore_cursor(vt); - break; - case '@': - vt100_csi_at(vt, vt->esc_params[0]); - break; - default: - trace_console_putchar_unhandled(ch); - break; - } - break; - } - break; - case TTY_STATE_OSC: /* Operating System Command: ESC ] ... BEL/ST */ - if (ch =3D=3D '\a') { - /* BEL terminates OSC */ - vt->state =3D TTY_STATE_NORM; - } else if (ch =3D=3D 27) { - /* ESC might start ST (ESC \) */ - vt->state =3D TTY_STATE_ESC; - } - /* All other bytes are silently consumed */ - break; - case TTY_STATE_G0: /* set character sets */ - case TTY_STATE_G1: /* set character sets */ - switch (ch) { - case 'B': - /* Latin-1 map */ - break; - } - vt->state =3D TTY_STATE_NORM; - break; - } -} - #define TYPE_CHARDEV_VC "chardev-vc" DECLARE_INSTANCE_CHECKER(VCChardev, VC_CHARDEV, TYPE_CHARDEV_VC) =20 -static size_t vt100_input(QemuVT100 *vt, const uint8_t *buf, size_t len) -{ - int i; - - vt->update_x0 =3D vt->width * FONT_WIDTH; - vt->update_y0 =3D vt->height * FONT_HEIGHT; - vt->update_x1 =3D 0; - vt->update_y1 =3D 0; - vt100_show_cursor(vt, 0); - for(i =3D 0; i < len; i++) { - vt100_putchar(vt, buf[i]); - } - vt100_show_cursor(vt, 1); - if (vt->update_x0 < vt->update_x1) { - vt100_image_update(vt, vt->update_x0, vt->update_y0, - vt->update_x1 - vt->update_x0, - vt->update_y1 - vt->update_y0); - } - return len; -} - static int vc_chr_write(Chardev *chr, const uint8_t *buf, int len) { VCChardev *drv =3D VC_CHARDEV(chr); @@ -1094,30 +115,6 @@ static int vc_chr_write(Chardev *chr, const uint8_t *= buf, int len) return vt100_input(&s->vt, buf, len); } =20 -void vt100_update_cursor(void) -{ - QemuVT100 *vt; - - cursor_visible_phase =3D !cursor_visible_phase; - - if (QTAILQ_EMPTY(&vt100s)) { - return; - } - - QTAILQ_FOREACH(vt, &vt100s, list) { - vt100_refresh(vt); - } - - timer_mod(cursor_timer, - qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + CONSOLE_CURSOR_PERIOD / 2= ); -} - -static void -cursor_timer_cb(void *opaque) -{ - vt100_update_cursor(); -} - static void text_console_invalidate(void *opaque) { QemuTextConsole *s =3D QEMU_TEXT_CONSOLE(opaque); @@ -1128,13 +125,6 @@ static void text_console_invalidate(void *opaque) vt100_refresh(&s->vt); } =20 -static void vt100_fini(QemuVT100 *vt) -{ - QTAILQ_REMOVE(&vt100s, vt, list); - fifo8_destroy(&vt->out_fifo); - g_free(vt->cells); -} - static void qemu_text_console_finalize(Object *obj) { @@ -1213,27 +203,6 @@ static void text_console_out_flush(QemuVT100 *vt) qemu_text_console_out_flush(console); } =20 -static void vt100_init(QemuVT100 *vt, - pixman_image_t *image, - ChardevVCEncoding encoding, - void (*image_update)(QemuVT100 *vt, int x, int y, i= nt w, int h), - void (*out_flush)(QemuVT100 *vt)) -{ - if (!cursor_timer) { - cursor_timer =3D timer_new_ms(QEMU_CLOCK_REALTIME, cursor_timer_cb= , NULL); - } - - vt->encoding =3D encoding; - QTAILQ_INSERT_HEAD(&vt100s, vt, list); - fifo8_create(&vt->out_fifo, 16); - vt->total_height =3D DEFAULT_BACKSCROLL; - vt->image_update =3D image_update; - vt->out_flush =3D out_flush; - /* set current text attributes to default */ - vt->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; - vt100_set_image(vt, image); -} - static bool vc_chr_open(Chardev *chr, ChardevBackend *backend, Error **err= p) { ChardevVC *vc =3D backend->u.vc.data; diff --git a/ui/console.c b/ui/console.c index 1c75b1a355b..b837ce1c9fc 100644 --- a/ui/console.c +++ b/ui/console.c @@ -39,6 +39,8 @@ #include "system/memory.h" #include "qom/object.h" #include "qemu/memfd.h" +#include "ui/vt100.h" +#include "vgafont.h" =20 #include "console-priv.h" =20 diff --git a/ui/vt100.c b/ui/vt100.c new file mode 100644 index 00000000000..e2fba822523 --- /dev/null +++ b/ui/vt100.c @@ -0,0 +1,984 @@ +/* + * SPDX-License-Identifier: MIT + * QEMU vt100 + */ +#include "qemu/osdep.h" +#include "qemu/timer.h" +#include "cp437.h" +#include "vgafont.h" +#include "vt100.h" + +#include "trace.h" + +#define DEFAULT_BACKSCROLL 512 +#define CONSOLE_CURSOR_PERIOD 500 + +static const pixman_color_t color_table_rgb[2][8] =3D { + { /* dark */ + [QEMU_COLOR_BLACK] =3D QEMU_PIXMAN_COLOR_BLACK, + [QEMU_COLOR_BLUE] =3D QEMU_PIXMAN_COLOR(0x00, 0x00, 0xaa), /* = blue */ + [QEMU_COLOR_GREEN] =3D QEMU_PIXMAN_COLOR(0x00, 0xaa, 0x00), /* = green */ + [QEMU_COLOR_CYAN] =3D QEMU_PIXMAN_COLOR(0x00, 0xaa, 0xaa), /* = cyan */ + [QEMU_COLOR_RED] =3D QEMU_PIXMAN_COLOR(0xaa, 0x00, 0x00), /* = red */ + [QEMU_COLOR_MAGENTA] =3D QEMU_PIXMAN_COLOR(0xaa, 0x00, 0xaa), /* = magenta */ + [QEMU_COLOR_YELLOW] =3D QEMU_PIXMAN_COLOR(0xaa, 0xaa, 0x00), /* = yellow */ + [QEMU_COLOR_WHITE] =3D QEMU_PIXMAN_COLOR_GRAY, + }, + { /* bright */ + [QEMU_COLOR_BLACK] =3D QEMU_PIXMAN_COLOR_BLACK, + [QEMU_COLOR_BLUE] =3D QEMU_PIXMAN_COLOR(0x00, 0x00, 0xff), /* = blue */ + [QEMU_COLOR_GREEN] =3D QEMU_PIXMAN_COLOR(0x00, 0xff, 0x00), /* = green */ + [QEMU_COLOR_CYAN] =3D QEMU_PIXMAN_COLOR(0x00, 0xff, 0xff), /* = cyan */ + [QEMU_COLOR_RED] =3D QEMU_PIXMAN_COLOR(0xff, 0x00, 0x00), /* = red */ + [QEMU_COLOR_MAGENTA] =3D QEMU_PIXMAN_COLOR(0xff, 0x00, 0xff), /* = magenta */ + [QEMU_COLOR_YELLOW] =3D QEMU_PIXMAN_COLOR(0xff, 0xff, 0x00), /* = yellow */ + [QEMU_COLOR_WHITE] =3D QEMU_PIXMAN_COLOR(0xff, 0xff, 0xff), /* = white */ + } +}; + +static bool cursor_visible_phase; +static QEMUTimer *cursor_timer; +static QTAILQ_HEAD(QemuVT100Head, QemuVT100) vt100s =3D + QTAILQ_HEAD_INITIALIZER(vt100s); + +static void image_fill_rect(pixman_image_t *image, int posx, int posy, + int width, int height, pixman_color_t color) +{ + pixman_rectangle16_t rect =3D { + .x =3D posx, .y =3D posy, .width =3D width, .height =3D height + }; + + pixman_image_fill_rectangles(PIXMAN_OP_SRC, image, + &color, 1, &rect); +} + +/* copy from (xs, ys) to (xd, yd) a rectangle of size (w, h) */ +static void image_bitblt(pixman_image_t *image, + int xs, int ys, int xd, int yd, int w, int h) +{ + pixman_image_composite(PIXMAN_OP_SRC, + image, NULL, image, + xs, ys, 0, 0, xd, yd, w, h); +} + +static void vt100_putcharxy(QemuVT100 *vt, int x, int y, int ch, + TextAttributes *t_attrib) +{ + static pixman_image_t *glyphs[256]; + pixman_color_t fgcol, bgcol; + + assert(vt->image); + if (t_attrib->invers) { + bgcol =3D color_table_rgb[t_attrib->bold][t_attrib->fgcol]; + fgcol =3D color_table_rgb[t_attrib->bold][t_attrib->bgcol]; + } else { + fgcol =3D color_table_rgb[t_attrib->bold][t_attrib->fgcol]; + bgcol =3D color_table_rgb[t_attrib->bold][t_attrib->bgcol]; + } + + if (!glyphs[ch]) { + glyphs[ch] =3D qemu_pixman_glyph_from_vgafont(FONT_HEIGHT, vgafont= 16, ch); + } + qemu_pixman_glyph_render(glyphs[ch], vt->image, + &fgcol, &bgcol, x, y, FONT_WIDTH, FONT_HEIGHT= ); +} + +static void vt100_invalidate_xy(QemuVT100 *vt, int x, int y) +{ + if (vt->update_x0 > x * FONT_WIDTH) { + vt->update_x0 =3D x * FONT_WIDTH; + } + if (vt->update_y0 > y * FONT_HEIGHT) { + vt->update_y0 =3D y * FONT_HEIGHT; + } + if (vt->update_x1 < (x + 1) * FONT_WIDTH) { + vt->update_x1 =3D (x + 1) * FONT_WIDTH; + } + if (vt->update_y1 < (y + 1) * FONT_HEIGHT) { + vt->update_y1 =3D (y + 1) * FONT_HEIGHT; + } +} + +static void vt100_show_cursor(QemuVT100 *vt, int show) +{ + TextCell *c; + int y, y1; + int x =3D vt->x; + + vt->cursor_invalidate =3D 1; + + if (x >=3D vt->width) { + x =3D vt->width - 1; + } + y1 =3D (vt->y_base + vt->y) % vt->total_height; + y =3D y1 - vt->y_displayed; + if (y < 0) { + y +=3D vt->total_height; + } + if (y < vt->height) { + c =3D &vt->cells[y1 * vt->width + x]; + if (show && cursor_visible_phase) { + TextAttributes t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; + t_attrib.invers =3D !(t_attrib.invers); /* invert fg and bg */ + vt100_putcharxy(vt, x, y, c->ch, &t_attrib); + } else { + vt100_putcharxy(vt, x, y, c->ch, &(c->t_attrib)); + } + vt100_invalidate_xy(vt, x, y); + } +} + +static void vt100_image_update(QemuVT100 *vt, int x, int y, int width, int= height) +{ + vt->image_update(vt, x, y, width, height); +} + +void vt100_refresh(QemuVT100 *vt) +{ + TextCell *c; + int x, y, y1; + int w =3D pixman_image_get_width(vt->image); + int h =3D pixman_image_get_height(vt->image); + + vt->text_x[0] =3D 0; + vt->text_y[0] =3D 0; + vt->text_x[1] =3D vt->width - 1; + vt->text_y[1] =3D vt->height - 1; + vt->cursor_invalidate =3D 1; + + image_fill_rect(vt->image, 0, 0, w, h, + color_table_rgb[0][QEMU_COLOR_BLACK]); + y1 =3D vt->y_displayed; + for (y =3D 0; y < vt->height; y++) { + c =3D vt->cells + y1 * vt->width; + for (x =3D 0; x < vt->width; x++) { + vt100_putcharxy(vt, x, y, c->ch, + &(c->t_attrib)); + c++; + } + if (++y1 =3D=3D vt->total_height) { + y1 =3D 0; + } + } + vt100_show_cursor(vt, 1); + vt100_image_update(vt, 0, 0, w, h); +} + +static void vt100_scroll(QemuVT100 *vt, int ydelta) +{ + int i, y1; + + if (ydelta > 0) { + for (i =3D 0; i < ydelta; i++) { + if (vt->y_displayed =3D=3D vt->y_base) { + break; + } + if (++vt->y_displayed =3D=3D vt->total_height) { + vt->y_displayed =3D 0; + } + } + } else { + ydelta =3D -ydelta; + i =3D vt->backscroll_height; + if (i > vt->total_height - vt->height) { + i =3D vt->total_height - vt->height; + } + y1 =3D vt->y_base - i; + if (y1 < 0) { + y1 +=3D vt->total_height; + } + for (i =3D 0; i < ydelta; i++) { + if (vt->y_displayed =3D=3D y1) { + break; + } + if (--vt->y_displayed < 0) { + vt->y_displayed =3D vt->total_height - 1; + } + } + } + vt100_refresh(vt); +} + +static void vt100_write(QemuVT100 *vt, const void *buf, size_t len) +{ + uint32_t num_free; + + num_free =3D fifo8_num_free(&vt->out_fifo); + fifo8_push_all(&vt->out_fifo, buf, MIN(num_free, len)); + vt->out_flush(vt); +} + +void vt100_set_image(QemuVT100 *vt, pixman_image_t *image) +{ + TextCell *cells, *c, *c1; + int w1, x, y, last_width, w, h; + + vt->image =3D image; + w =3D pixman_image_get_width(vt->image) / FONT_WIDTH; + h =3D pixman_image_get_height(vt->image) / FONT_HEIGHT; + if (w =3D=3D vt->width && h =3D=3D vt->height) { + return; + } + + last_width =3D vt->width; + vt->width =3D w; + vt->height =3D h; + + w1 =3D MIN(vt->width, last_width); + + cells =3D g_new(TextCell, vt->width * vt->total_height + 1); + for (y =3D 0; y < vt->total_height; y++) { + c =3D &cells[y * vt->width]; + if (w1 > 0) { + c1 =3D &vt->cells[y * last_width]; + for (x =3D 0; x < w1; x++) { + *c++ =3D *c1++; + } + } + for (x =3D w1; x < vt->width; x++) { + c->ch =3D ' '; + c->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; + c++; + } + } + g_free(vt->cells); + vt->cells =3D cells; +} + +static void vt100_put_lf(QemuVT100 *vt) +{ + TextCell *c; + int x, y1; + + vt->y++; + if (vt->y >=3D vt->height) { + vt->y =3D vt->height - 1; + + if (vt->y_displayed =3D=3D vt->y_base) { + if (++vt->y_displayed =3D=3D vt->total_height) { + vt->y_displayed =3D 0; + } + } + if (++vt->y_base =3D=3D vt->total_height) { + vt->y_base =3D 0; + } + if (vt->backscroll_height < vt->total_height) { + vt->backscroll_height++; + } + y1 =3D (vt->y_base + vt->height - 1) % vt->total_height; + c =3D &vt->cells[y1 * vt->width]; + for (x =3D 0; x < vt->width; x++) { + c->ch =3D ' '; + c->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; + c++; + } + if (vt->y_displayed =3D=3D vt->y_base) { + vt->text_x[0] =3D 0; + vt->text_y[0] =3D 0; + vt->text_x[1] =3D vt->width - 1; + vt->text_y[1] =3D vt->height - 1; + + image_bitblt(vt->image, 0, FONT_HEIGHT, 0, 0, + vt->width * FONT_WIDTH, + (vt->height - 1) * FONT_HEIGHT); + image_fill_rect(vt->image, 0, (vt->height - 1) * FONT_HEIGHT, + vt->width * FONT_WIDTH, FONT_HEIGHT, + color_table_rgb[0][TEXT_ATTRIBUTES_DEFAULT.bgc= ol]); + vt->update_x0 =3D 0; + vt->update_y0 =3D 0; + vt->update_x1 =3D vt->width * FONT_WIDTH; + vt->update_y1 =3D vt->height * FONT_HEIGHT; + } + } +} + +/* + * Set console attributes depending on the current escape codes. + * NOTE: I know this code is not very efficient (checking every color for = it + * self) but it is more readable and better maintainable. + */ +static void vt100_handle_escape(QemuVT100 *vt) +{ + int i; + + for (i =3D 0; i < vt->nb_esc_params; i++) { + switch (vt->esc_params[i]) { + case 0: /* reset all console attributes to default */ + vt->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; + break; + case 1: + vt->t_attrib.bold =3D 1; + break; + case 4: + vt->t_attrib.uline =3D 1; + break; + case 5: + vt->t_attrib.blink =3D 1; + break; + case 7: + vt->t_attrib.invers =3D 1; + break; + case 8: + vt->t_attrib.unvisible =3D 1; + break; + case 22: + vt->t_attrib.bold =3D 0; + break; + case 24: + vt->t_attrib.uline =3D 0; + break; + case 25: + vt->t_attrib.blink =3D 0; + break; + case 27: + vt->t_attrib.invers =3D 0; + break; + case 28: + vt->t_attrib.unvisible =3D 0; + break; + /* set foreground color */ + case 30: + vt->t_attrib.fgcol =3D QEMU_COLOR_BLACK; + break; + case 31: + vt->t_attrib.fgcol =3D QEMU_COLOR_RED; + break; + case 32: + vt->t_attrib.fgcol =3D QEMU_COLOR_GREEN; + break; + case 33: + vt->t_attrib.fgcol =3D QEMU_COLOR_YELLOW; + break; + case 34: + vt->t_attrib.fgcol =3D QEMU_COLOR_BLUE; + break; + case 35: + vt->t_attrib.fgcol =3D QEMU_COLOR_MAGENTA; + break; + case 36: + vt->t_attrib.fgcol =3D QEMU_COLOR_CYAN; + break; + case 37: + vt->t_attrib.fgcol =3D QEMU_COLOR_WHITE; + break; + /* set background color */ + case 40: + vt->t_attrib.bgcol =3D QEMU_COLOR_BLACK; + break; + case 41: + vt->t_attrib.bgcol =3D QEMU_COLOR_RED; + break; + case 42: + vt->t_attrib.bgcol =3D QEMU_COLOR_GREEN; + break; + case 43: + vt->t_attrib.bgcol =3D QEMU_COLOR_YELLOW; + break; + case 44: + vt->t_attrib.bgcol =3D QEMU_COLOR_BLUE; + break; + case 45: + vt->t_attrib.bgcol =3D QEMU_COLOR_MAGENTA; + break; + case 46: + vt->t_attrib.bgcol =3D QEMU_COLOR_CYAN; + break; + case 47: + vt->t_attrib.bgcol =3D QEMU_COLOR_WHITE; + break; + } + } +} + +static void vt100_update_xy(QemuVT100 *vt, int x, int y) +{ + TextCell *c; + int y1, y2; + + vt->text_x[0] =3D MIN(vt->text_x[0], x); + vt->text_x[1] =3D MAX(vt->text_x[1], x); + vt->text_y[0] =3D MIN(vt->text_y[0], y); + vt->text_y[1] =3D MAX(vt->text_y[1], y); + + y1 =3D (vt->y_base + y) % vt->total_height; + y2 =3D y1 - vt->y_displayed; + if (y2 < 0) { + y2 +=3D vt->total_height; + } + if (y2 < vt->height) { + if (x >=3D vt->width) { + x =3D vt->width - 1; + } + c =3D &vt->cells[y1 * vt->width + x]; + vt100_putcharxy(vt, x, y2, c->ch, + &(c->t_attrib)); + vt100_invalidate_xy(vt, x, y2); + } +} + +static void vt100_clear_xy(QemuVT100 *vt, int x, int y) +{ + int y1 =3D (vt->y_base + y) % vt->total_height; + if (x >=3D vt->width) { + x =3D vt->width - 1; + } + TextCell *c =3D &vt->cells[y1 * vt->width + x]; + c->ch =3D ' '; + c->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; + vt100_update_xy(vt, x, y); +} + +/* + * UTF-8 DFA decoder by Bjoern Hoehrmann. + * Copyright (c) 2008-2010 Bjoern Hoehrmann + * See https://github.com/polijan/utf8_decode for details. + * + * SPDX-License-Identifier: MIT + */ +#define BH_UTF8_ACCEPT 0 +#define BH_UTF8_REJECT 12 + +static uint32_t bh_utf8_decode(uint32_t *state, uint32_t *codep, uint32_t = byte) +{ + static const uint8_t utf8d[] =3D { + /* character class lookup */ + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, + 8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, + 10,3,3,3,3,3,3,3,3,3,3,3,3,4,3,3, 11,6,6,6,5,8,8,8,8,8,8,8,8,8,8,8, + + /* state transition lookup */ + 0,12,24,36,60,96,84,12,12,12,48,72, 12,12,12,12,12,12,12,12,12,12,= 12,12, + 12, 0,12,12,12,12,12, 0,12, 0,12,12, 12,24,12,12,12,12,12,24,12,24= ,12,12, + 12,12,12,12,12,12,12,24,12,12,12,12, 12,24,12,12,12,12,12,12,12,24= ,12,12, + 12,12,12,12,12,12,12,36,12,36,12,12, 12,36,12,12,12,12,12,36,12,36= ,12,12, + 12,36,12,12,12,12,12,12,12,12,12,12, + }; + uint32_t type =3D utf8d[byte]; + + *codep =3D (*state !=3D BH_UTF8_ACCEPT) ? + (byte & 0x3fu) | (*codep << 6) : + (0xffu >> type) & (byte); + + *state =3D utf8d[256 + *state + type]; + return *state; +} + +static void vt100_put_one(QemuVT100 *vt, int ch) +{ + TextCell *c; + int y1; + if (vt->x >=3D vt->width) { + /* line wrap */ + vt->x =3D 0; + vt100_put_lf(vt); + } + y1 =3D (vt->y_base + vt->y) % vt->total_height; + c =3D &vt->cells[y1 * vt->width + vt->x]; + c->ch =3D ch; + c->t_attrib =3D vt->t_attrib; + vt100_update_xy(vt, vt->x, vt->y); + vt->x++; +} + +/* set cursor, checking bounds */ +static void vt100_set_cursor(QemuVT100 *vt, int x, int y) +{ + if (x < 0) { + x =3D 0; + } + if (y < 0) { + y =3D 0; + } + if (y >=3D vt->height) { + y =3D vt->height - 1; + } + if (x >=3D vt->width) { + x =3D vt->width - 1; + } + + vt->x =3D x; + vt->y =3D y; +} + +/** + * vt100_csi_P() - (DCH) deletes one or more characters from the cursor + * position to the right. As characters are deleted, the remaining + * characters between the cursor and right margin move to the + * left. Character attributes move with the characters. + */ +static void vt100_csi_P(QemuVT100 *vt, unsigned int nr) +{ + TextCell *c1, *c2; + unsigned int x1, x2, y; + unsigned int end, len; + + if (!nr) { + nr =3D 1; + } + if (nr > vt->width - vt->x) { + nr =3D vt->width - vt->x; + if (!nr) { + return; + } + } + + x1 =3D vt->x; + x2 =3D vt->x + nr; + len =3D vt->width - x2; + if (len) { + y =3D (vt->y_base + vt->y) % vt->total_height; + c1 =3D &vt->cells[y * vt->width + x1]; + c2 =3D &vt->cells[y * vt->width + x2]; + memmove(c1, c2, len * sizeof(*c1)); + for (end =3D x1 + len; x1 < end; x1++) { + vt100_update_xy(vt, x1, vt->y); + } + } + /* Clear the rest */ + for (; x1 < vt->width; x1++) { + vt100_clear_xy(vt, x1, vt->y); + } +} + +/** + * vt100_csi_at() - (ICH) inserts `nr` blank characters with the default + * character attribute. The cursor remains at the beginning of the + * blank characters. Text between the cursor and right margin moves to + * the right. Characters scrolled past the right margin are lost. + */ +static void vt100_csi_at(QemuVT100 *vt, unsigned int nr) +{ + TextCell *c1, *c2; + unsigned int x1, x2, y; + unsigned int end, len; + + if (!nr) { + nr =3D 1; + } + if (nr > vt->width - vt->x) { + nr =3D vt->width - vt->x; + if (!nr) { + return; + } + } + + x1 =3D vt->x + nr; + x2 =3D vt->x; + len =3D vt->width - x1; + if (len) { + y =3D (vt->y_base + vt->y) % vt->total_height; + c1 =3D &vt->cells[y * vt->width + x1]; + c2 =3D &vt->cells[y * vt->width + x2]; + memmove(c1, c2, len * sizeof(*c1)); + for (end =3D x1 + len; x1 < end; x1++) { + vt100_update_xy(vt, x1, vt->y); + } + } + /* Insert blanks */ + for (x1 =3D vt->x; x1 < vt->x + nr; x1++) { + vt100_clear_xy(vt, x1, vt->y); + } +} + +/** + * vt100_save_cursor() - saves cursor position and character attributes. + */ +static void vt100_save_cursor(QemuVT100 *vt) +{ + vt->x_saved =3D vt->x; + vt->y_saved =3D vt->y; + vt->t_attrib_saved =3D vt->t_attrib; +} + +/** + * vt100_restore_cursor() - restores cursor position and character + * attributes from saved state. + */ +static void vt100_restore_cursor(QemuVT100 *vt) +{ + vt->x =3D vt->x_saved; + vt->y =3D vt->y_saved; + vt->t_attrib =3D vt->t_attrib_saved; +} + +static void vt100_putchar(QemuVT100 *vt, int ch) +{ + int i; + int x, y; + g_autofree char *response =3D NULL; + + switch (vt->state) { + case TTY_STATE_NORM: + if (ch >=3D 0x80 && vt->encoding =3D=3D CHARDEV_VC_ENCODING_UTF8) { + switch (bh_utf8_decode(&vt->utf8_state, &vt->utf8_codepoint, c= h)) { + case BH_UTF8_ACCEPT: + vt100_put_one(vt, unicode_to_cp437(vt->utf8_codepoint)); + break; + case BH_UTF8_REJECT: + vt->utf8_state =3D BH_UTF8_ACCEPT; + break; + default: + break; + } + break; + } + vt->utf8_state =3D BH_UTF8_ACCEPT; + switch (ch) { + case '\r': /* carriage return */ + vt->x =3D 0; + break; + case '\n': /* newline */ + vt100_put_lf(vt); + break; + case '\b': /* backspace */ + if (vt->x > 0) { + vt->x--; + } + break; + case '\t': /* tabspace */ + if (vt->x + (8 - (vt->x % 8)) > vt->width) { + vt->x =3D 0; + vt100_put_lf(vt); + } else { + vt->x =3D vt->x + (8 - (vt->x % 8)); + } + break; + case '\a': /* alert aka. bell */ + /* TODO: has to be implemented */ + break; + case 14: + /* SO (shift out), character set 1 (ignored) */ + break; + case 15: + /* SI (shift in), character set 0 (ignored) */ + break; + case 27: /* esc (introducing an escape sequence) */ + vt->state =3D TTY_STATE_ESC; + break; + default: + vt100_put_one(vt, ch); + break; + } + break; + case TTY_STATE_ESC: /* check if it is a terminal escape sequence */ + if (ch =3D=3D '[') { + for (i =3D 0; i < MAX_ESC_PARAMS; i++) { + vt->esc_params[i] =3D 0; + } + vt->nb_esc_params =3D 0; + vt->state =3D TTY_STATE_CSI; + } else if (ch =3D=3D '(') { + vt->state =3D TTY_STATE_G0; + } else if (ch =3D=3D ')') { + vt->state =3D TTY_STATE_G1; + } else if (ch =3D=3D ']' || ch =3D=3D 'P' || ch =3D=3D 'X' + || ch =3D=3D '^' || ch =3D=3D '_') { + /* String sequences: OSC, DCS, SOS, PM, APC */ + vt->state =3D TTY_STATE_OSC; + } else if (ch =3D=3D '7') { + vt100_save_cursor(vt); + vt->state =3D TTY_STATE_NORM; + } else if (ch =3D=3D '8') { + vt100_restore_cursor(vt); + vt->state =3D TTY_STATE_NORM; + } else { + vt->state =3D TTY_STATE_NORM; + } + break; + case TTY_STATE_CSI: /* handle escape sequence parameters */ + if (ch >=3D '0' && ch <=3D '9') { + if (vt->nb_esc_params < MAX_ESC_PARAMS) { + int *param =3D &vt->esc_params[vt->nb_esc_params]; + int digit =3D (ch - '0'); + + *param =3D (*param <=3D (INT_MAX - digit) / 10) ? + *param * 10 + digit : INT_MAX; + } + } else { + if (vt->nb_esc_params < MAX_ESC_PARAMS) { + vt->nb_esc_params++; + } + if (ch =3D=3D ';' || ch =3D=3D '?') { + break; + } + trace_console_putchar_csi(vt->esc_params[0], vt->esc_params[1], + ch, vt->nb_esc_params); + vt->state =3D TTY_STATE_NORM; + switch (ch) { + case 'A': + /* move cursor up */ + if (vt->esc_params[0] =3D=3D 0) { + vt->esc_params[0] =3D 1; + } + vt100_set_cursor(vt, vt->x, vt->y - vt->esc_params[0]); + break; + case 'B': + /* move cursor down */ + if (vt->esc_params[0] =3D=3D 0) { + vt->esc_params[0] =3D 1; + } + vt100_set_cursor(vt, vt->x, vt->y + vt->esc_params[0]); + break; + case 'C': + /* move cursor right */ + if (vt->esc_params[0] =3D=3D 0) { + vt->esc_params[0] =3D 1; + } + vt100_set_cursor(vt, vt->x + vt->esc_params[0], vt->y); + break; + case 'D': + /* move cursor left */ + if (vt->esc_params[0] =3D=3D 0) { + vt->esc_params[0] =3D 1; + } + vt100_set_cursor(vt, vt->x - vt->esc_params[0], vt->y); + break; + case 'G': + /* move cursor to column */ + vt100_set_cursor(vt, vt->esc_params[0] - 1, vt->y); + break; + case 'f': + case 'H': + /* move cursor to row, column */ + vt100_set_cursor(vt, vt->esc_params[1] - 1, vt->esc_params= [0] - 1); + break; + case 'J': + switch (vt->esc_params[0]) { + case 0: + /* clear to end of screen */ + for (y =3D vt->y; y < vt->height; y++) { + for (x =3D 0; x < vt->width; x++) { + if (y =3D=3D vt->y && x < vt->x) { + continue; + } + vt100_clear_xy(vt, x, y); + } + } + break; + case 1: + /* clear from beginning of screen */ + for (y =3D 0; y <=3D vt->y; y++) { + for (x =3D 0; x < vt->width; x++) { + if (y =3D=3D vt->y && x > vt->x) { + break; + } + vt100_clear_xy(vt, x, y); + } + } + break; + case 2: + /* clear entire screen */ + for (y =3D 0; y < vt->height; y++) { + for (x =3D 0; x < vt->width; x++) { + vt100_clear_xy(vt, x, y); + } + } + break; + } + break; + case 'K': + switch (vt->esc_params[0]) { + case 0: + /* clear to eol */ + for (x =3D vt->x; x < vt->width; x++) { + vt100_clear_xy(vt, x, vt->y); + } + break; + case 1: + /* clear from beginning of line */ + for (x =3D 0; x <=3D vt->x && x < vt->width; x++) { + vt100_clear_xy(vt, x, vt->y); + } + break; + case 2: + /* clear entire line */ + for (x =3D 0; x < vt->width; x++) { + vt100_clear_xy(vt, x, vt->y); + } + break; + } + break; + case 'P': + vt100_csi_P(vt, vt->esc_params[0]); + break; + case 'm': + vt100_handle_escape(vt); + break; + case 'n': + switch (vt->esc_params[0]) { + case 5: + /* report console status (always succeed)*/ + vt100_write(vt, "\033[0n", 4); + break; + case 6: + /* report cursor position */ + response =3D g_strdup_printf("\033[%d;%dR", + vt->y + 1, vt->x + 1); + vt100_write(vt, response, strlen(response)); + break; + } + break; + case 's': + vt100_save_cursor(vt); + break; + case 'u': + vt100_restore_cursor(vt); + break; + case '@': + vt100_csi_at(vt, vt->esc_params[0]); + break; + default: + trace_console_putchar_unhandled(ch); + break; + } + break; + } + break; + case TTY_STATE_OSC: /* Operating System Command: ESC ] ... BEL/ST */ + if (ch =3D=3D '\a') { + /* BEL terminates OSC */ + vt->state =3D TTY_STATE_NORM; + } else if (ch =3D=3D 27) { + /* ESC might start ST (ESC \) */ + vt->state =3D TTY_STATE_ESC; + } + /* All other bytes are silently consumed */ + break; + case TTY_STATE_G0: /* set character sets */ + case TTY_STATE_G1: /* set character sets */ + switch (ch) { + case 'B': + /* Latin-1 map */ + break; + } + vt->state =3D TTY_STATE_NORM; + break; + } + +} + +size_t vt100_input(QemuVT100 *vt, const uint8_t *buf, size_t len) +{ + int i; + + vt->update_x0 =3D vt->width * FONT_WIDTH; + vt->update_y0 =3D vt->height * FONT_HEIGHT; + vt->update_x1 =3D 0; + vt->update_y1 =3D 0; + vt100_show_cursor(vt, 0); + for (i =3D 0; i < len; i++) { + vt100_putchar(vt, buf[i]); + } + vt100_show_cursor(vt, 1); + if (vt->update_x0 < vt->update_x1) { + vt100_image_update(vt, vt->update_x0, vt->update_y0, + vt->update_x1 - vt->update_x0, + vt->update_y1 - vt->update_y0); + } + return len; +} + +void vt100_keysym(QemuVT100 *vt, int keysym) +{ + uint8_t buf[16], *q; + int c; + + switch (keysym) { + case QEMU_KEY_CTRL_UP: + vt100_scroll(vt, -1); + break; + case QEMU_KEY_CTRL_DOWN: + vt100_scroll(vt, 1); + break; + case QEMU_KEY_CTRL_PAGEUP: + vt100_scroll(vt, -10); + break; + case QEMU_KEY_CTRL_PAGEDOWN: + vt100_scroll(vt, 10); + break; + default: + /* convert the QEMU keysym to VT100 key string */ + q =3D buf; + if (keysym >=3D 0xe100 && keysym <=3D 0xe11f) { + *q++ =3D '\033'; + *q++ =3D '['; + c =3D keysym - 0xe100; + if (c >=3D 10) { + *q++ =3D '0' + (c / 10); + } + *q++ =3D '0' + (c % 10); + *q++ =3D '~'; + } else if (keysym >=3D 0xe120 && keysym <=3D 0xe17f) { + *q++ =3D '\033'; + *q++ =3D '['; + *q++ =3D keysym & 0xff; + } else if (vt->echo && (keysym =3D=3D '\r' || keysym =3D=3D '\n'))= { + vt100_input(vt, (uint8_t *)"\r", 1); + *q++ =3D '\n'; + } else { + *q++ =3D keysym; + } + if (vt->echo) { + vt100_input(vt, buf, q - buf); + } + vt100_write(vt, buf, q - buf); + break; + } +} + +void vt100_update_cursor(void) +{ + QemuVT100 *vt; + + cursor_visible_phase =3D !cursor_visible_phase; + + if (QTAILQ_EMPTY(&vt100s)) { + return; + } + + QTAILQ_FOREACH(vt, &vt100s, list) { + vt100_refresh(vt); + } + + timer_mod(cursor_timer, + qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + CONSOLE_CURSOR_PERIOD / 2= ); +} + +static void +cursor_timer_cb(void *opaque) +{ + vt100_update_cursor(); +} + +void vt100_init(QemuVT100 *vt, + pixman_image_t *image, + ChardevVCEncoding encoding, + void (*image_update)(QemuVT100 *vt, int x, int y, int w, i= nt h), + void (*out_flush)(QemuVT100 *vt)) +{ + if (!cursor_timer) { + cursor_timer =3D timer_new_ms(QEMU_CLOCK_REALTIME, cursor_timer_cb= , NULL); + } + + vt->encoding =3D encoding; + QTAILQ_INSERT_HEAD(&vt100s, vt, list); + fifo8_create(&vt->out_fifo, 16); + vt->total_height =3D DEFAULT_BACKSCROLL; + vt->image_update =3D image_update; + vt->out_flush =3D out_flush; + /* set current text attributes to default */ + vt->t_attrib =3D TEXT_ATTRIBUTES_DEFAULT; + vt100_set_image(vt, image); +} + +void vt100_fini(QemuVT100 *vt) +{ + QTAILQ_REMOVE(&vt100s, vt, list); + fifo8_destroy(&vt->out_fifo); + g_free(vt->cells); +} diff --git a/ui/meson.build b/ui/meson.build index d69eebfdaf1..7b6e867d3af 100644 --- a/ui/meson.build +++ b/ui/meson.build @@ -3,6 +3,7 @@ system_ss.add(png) system_ss.add(files( 'clipboard.c', 'console.c', + 'cp437.c', 'cursor.c', 'display-surface.c', 'dmabuf.c', @@ -17,8 +18,9 @@ system_ss.add(files( 'ui-qmp-cmds.c', 'util.c', 'vgafont.c', + 'vt100.c', )) -system_ss.add(when: pixman, if_true: files('console-vc.c', 'cp437.c'), if_= false: files('console-vc-stubs.c')) +system_ss.add(when: pixman, if_true: files('console-vc.c'), if_false: file= s('console-vc-stubs.c')) if dbus_display system_ss.add(files('dbus-module.c')) endif --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778347021; cv=none; d=zohomail.com; s=zohoarc; b=UOsYkQBSXqhokPz5KODfWacHIhvco4Y11onKDpe4C44M6rWR7o+22nq98hGBqT3bQy6q+6xIr202fNVpQUEchffpYr7jNtZYj4hnloONnWuJH+dQi0gUEiapgQW330Cz2xOYkKon8++U1htuY35iwala3ng8jkr1/ufZ/qzcFVs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778347021; 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=t8ObG7/YpUW5QUS6BKgeVhaMUcZQOUTbu2MDi+0Jl8Y=; b=Z3kdi8vB6DMiqFmXYk3GjUArss/tpuw4P9Qjo2C75ehOL91arj4+z0+TIDp8r5/8F5GPHEUNAddiR8GtrsY/FYNFdRXSgY6ypgz+f1Cs7hEIJi9xmj4wNY3hqpBNoiXx9sU5mieHTbYNXCx8uycFgOgqFwagBkcwZnL7NPty7WQ= 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 1778347021027583.8995137576018; Sat, 9 May 2026 10:17:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlHr-0005m0-Sz; Sat, 09 May 2026 13:16:23 -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 1wLlHb-0005Mx-14 for qemu-devel@nongnu.org; Sat, 09 May 2026 13:16:07 -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 1wLlHZ-0005DY-An for qemu-devel@nongnu.org; Sat, 09 May 2026 13:16:06 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-570--UEMNL_CNAuI1inci88f_w-1; Sat, 09 May 2026 13:16:02 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 78D13180034C; Sat, 9 May 2026 17:16:01 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2181F1955D84; Sat, 9 May 2026 17:15:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778346963; 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=t8ObG7/YpUW5QUS6BKgeVhaMUcZQOUTbu2MDi+0Jl8Y=; b=R8SNkeacjN81rwkNY6W6WIrgSZLzmgRjBG7EI75PMyl1G5ZXBKGIaiYLOeZAe/X6RbfGhd IlsswhsYCh9IJ373+6rxUEep9uYZtyxhgVLcElBX+stqeKhScqhrp1YfUxthkFpXw8aIQE f0KegHq3OX2yjHkoYJzUClilTB9MkCs= X-MC-Unique: -UEMNL_CNAuI1inci88f_w-1 X-Mimecast-MFC-AGG-ID: -UEMNL_CNAuI1inci88f_w_1778346961 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 20/33] ui/vnc: make the worker thread per-VncDisplay Date: Sat, 9 May 2026 21:13:41 +0400 Message-ID: <20260509171356.1157879-21-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 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, SPF_HELO_PASS=-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 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: 1778347023585154100 From: Marc-Andr=C3=A9 Lureau The VNC encoding worker thread was using a single global queue shared across all VNC displays, with no way to stop it. This made it impossible to properly clean up resources when a VncDisplay is freed. Move the VncJobQueue from a file-scoped global to a per-VncDisplay member, so each display owns its worker thread and queue. Add vnc_stop_worker_thread() to perform an orderly shutdown: signal the thread to exit, join it, and destroy the queue. The thread is now created as QEMU_THREAD_JOINABLE instead of QEMU_THREAD_DETACHED. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/vnc-jobs.h | 3 ++- ui/vnc.h | 2 ++ ui/vnc-jobs.c | 62 +++++++++++++++++++++++++++++++++------------------ ui/vnc.c | 3 ++- 4 files changed, 46 insertions(+), 24 deletions(-) diff --git a/ui/vnc-jobs.h b/ui/vnc-jobs.h index 59f66bcc353..e5ab55c1da6 100644 --- a/ui/vnc-jobs.h +++ b/ui/vnc-jobs.h @@ -37,7 +37,8 @@ void vnc_job_push(VncJob *job); void vnc_jobs_join(VncState *vs); =20 void vnc_jobs_consume_buffer(VncState *vs); -void vnc_start_worker_thread(void); +void vnc_start_worker_thread(VncDisplay *vd); +void vnc_stop_worker_thread(VncDisplay *vd); =20 /* Locks */ static inline int vnc_trylock_display(VncDisplay *vd) diff --git a/ui/vnc.h b/ui/vnc.h index 472a55f7b5f..780fd39469f 100644 --- a/ui/vnc.h +++ b/ui/vnc.h @@ -62,6 +62,7 @@ =20 typedef struct VncState VncState; typedef struct VncJob VncJob; +typedef struct VncJobQueue VncJobQueue; typedef struct VncRect VncRect; typedef struct VncRectEntry VncRectEntry; =20 @@ -158,6 +159,7 @@ struct VncDisplay int ledstate; QKbdState *kbd; QemuMutex mutex; + VncJobQueue *queue; =20 int cursor_msize; uint8_t *cursor_mask; diff --git a/ui/vnc-jobs.c b/ui/vnc-jobs.c index 5b17ef54091..90b68bf4cb9 100644 --- a/ui/vnc-jobs.c +++ b/ui/vnc-jobs.c @@ -29,8 +29,6 @@ #include "qemu/osdep.h" #include "vnc.h" #include "vnc-jobs.h" -#include "qemu/sockets.h" -#include "qemu/main-loop.h" #include "trace.h" =20 /* @@ -56,17 +54,10 @@ struct VncJobQueue { QemuCond cond; QemuMutex mutex; QemuThread thread; + bool exit; QTAILQ_HEAD(, VncJob) jobs; }; =20 -typedef struct VncJobQueue VncJobQueue; - -/* - * We use a single global queue, but most of the functions are - * already reentrant, so we can easily add more than one encoding thread - */ -static VncJobQueue *queue; - static void vnc_lock_queue(VncJobQueue *queue) { qemu_mutex_lock(&queue->mutex); @@ -125,12 +116,15 @@ static void vnc_job_free(VncJob *job) */ void vnc_job_push(VncJob *job) { + VncJobQueue *queue =3D job->vs->vd->queue; + assert(!QTAILQ_IN_USE(job, next)); =20 if (QLIST_EMPTY(&job->rectangles)) { vnc_job_free(job); } else { vnc_lock_queue(queue); + assert(!queue->exit); QTAILQ_INSERT_TAIL(&queue->jobs, job, next); qemu_cond_broadcast(&queue->cond); vnc_unlock_queue(queue); @@ -139,6 +133,7 @@ void vnc_job_push(VncJob *job) =20 static bool vnc_has_job_locked(VncState *vs) { + VncJobQueue *queue =3D vs->vd->queue; VncJob *job; =20 QTAILQ_FOREACH(job, &queue->jobs, next) { @@ -151,6 +146,8 @@ static bool vnc_has_job_locked(VncState *vs) =20 void vnc_jobs_join(VncState *vs) { + VncJobQueue *queue =3D vs->vd->queue; + vnc_lock_queue(queue); while (vnc_has_job_locked(vs)) { qemu_cond_wait(&queue->cond, &queue->mutex); @@ -252,9 +249,13 @@ static int vnc_worker_thread_loop(VncJobQueue *queue) int saved_offset; =20 vnc_lock_queue(queue); - while (QTAILQ_EMPTY(&queue->jobs)) { + while (QTAILQ_EMPTY(&queue->jobs) && !queue->exit) { qemu_cond_wait(&queue->cond, &queue->mutex); } + if (queue->exit) { + vnc_unlock_queue(queue); + return 1; + } job =3D QTAILQ_FIRST(&queue->jobs); vnc_unlock_queue(queue); =20 @@ -340,7 +341,7 @@ disconnected: return 0; } =20 -static VncJobQueue *vnc_queue_init(void) +static VncJobQueue *vnc_queue_new(void) { VncJobQueue *queue =3D g_new0(VncJobQueue, 1); =20 @@ -350,29 +351,46 @@ static VncJobQueue *vnc_queue_init(void) return queue; } =20 +static void vnc_queue_free(VncJobQueue *queue) +{ + qemu_cond_destroy(&queue->cond); + qemu_mutex_destroy(&queue->mutex); + g_free(queue); +} + static void *vnc_worker_thread(void *arg) { VncJobQueue *queue =3D arg; =20 while (!vnc_worker_thread_loop(queue)) ; - g_assert_not_reached(); + return NULL; } =20 -static bool vnc_worker_thread_running(void) +void vnc_start_worker_thread(VncDisplay *vd) { - return queue; /* Check global queue */ + assert(vd->queue =3D=3D NULL); + + vd->queue =3D vnc_queue_new(); + qemu_thread_create(&vd->queue->thread, "vnc_worker", vnc_worker_thread= , vd->queue, + QEMU_THREAD_JOINABLE); } =20 -void vnc_start_worker_thread(void) +void vnc_stop_worker_thread(VncDisplay *vd) { - VncJobQueue *q; + VncJobQueue *queue =3D vd->queue; =20 - if (vnc_worker_thread_running()) + if (!queue) { return; + } + + /* all VNC clients must have finished before we can stop the worker th= read */ + vnc_lock_queue(queue); + assert(QTAILQ_EMPTY(&queue->jobs)); + queue->exit =3D true; + qemu_cond_broadcast(&queue->cond); + vnc_unlock_queue(queue); =20 - q =3D vnc_queue_init(); - qemu_thread_create(&q->thread, "vnc_worker", vnc_worker_thread, q, - QEMU_THREAD_DETACHED); - queue =3D q; /* Set global queue */ + qemu_thread_join(&queue->thread); + g_clear_pointer(&vd->queue, vnc_queue_free); } diff --git a/ui/vnc.c b/ui/vnc.c index c87d1f61a0a..3a908670ab9 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -3457,7 +3457,7 @@ void vnc_display_init(const char *id, Error **errp) vd->share_policy =3D VNC_SHARE_POLICY_ALLOW_EXCLUSIVE; vd->connections_limit =3D 32; =20 - vnc_start_worker_thread(); + vnc_start_worker_thread(vd); =20 register_displaychangelistener(&vd->dcl); vd->kbd =3D qkbd_state_init(vd->dcl.con); @@ -3513,6 +3513,7 @@ static void vnc_display_free(VncDisplay *vd) =20 assert(QTAILQ_EMPTY(&vd->clients)); =20 + vnc_stop_worker_thread(vd); vnc_display_close(vd); unregister_displaychangelistener(&vd->dcl); qkbd_state_free(vd->kbd); --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778347179; cv=none; d=zohomail.com; s=zohoarc; b=IAkH4kR6To5yGf/H0Jg5ZBkZLm+lCtYIm0heS8V6hb6pFAijbUgFWjLHurtyOXFtrPhLPpPikH+uvE3JCtb4+3HyJXREREZTb2ZAnk6rlisHQlnjlDHw2A63IORxnXbZNYMxrWHX1qpXrFymD+3AuiSbTeOmjUdBZV46FVbH+pQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778347179; 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=cfYs1LjQpDYe54tsVrqJvVf2U2NzuLWTpllOslebg8A=; b=blqxAbZZFFJPrlbbl5E+sqpQOhu4ELfFLR8b/xuf4DO3zwhCAldlxkJr90WKBUuv9YYnzqMLSAsexS1i3xYeNX8LOObQiwVCQtsjPMX23h8w8VaU04OoIH4F/xHRto2XCiMM0uIBp+0JBE/rql61nd9bV3yMGHvtAqwyu/1eJ3s= 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 1778347179727501.01248603743704; Sat, 9 May 2026 10:19:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlHt-0005wN-8b; Sat, 09 May 2026 13:16:25 -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 1wLlHg-0005Zs-7x for qemu-devel@nongnu.org; Sat, 09 May 2026 13:16:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wLlHe-0005EU-IN for qemu-devel@nongnu.org; Sat, 09 May 2026 13:16:11 -0400 Received: from mx-prod-mc-05.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-605-SaZKL8O1PnKv18Y3w1ZYdA-1; Sat, 09 May 2026 13:16:07 -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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F00781956080; Sat, 9 May 2026 17:16:06 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A849F18004A3; Sat, 9 May 2026 17:16:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778346969; 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=cfYs1LjQpDYe54tsVrqJvVf2U2NzuLWTpllOslebg8A=; b=iXzTj1bFuh2mtWNDKyv8UCSdjSUIqsezOLKh1wCsYMHMC4k6pHQspZrntTmAm5ElBsIQNI 9777iJJafFPGeR5unnKtI7zz1cEtRh5VkTUOT0Q/zjVC0hq3A+sOdGWeRMLhzHa5PH4cx6 fNVEdkvHdvn/CUx4TG22W1dGB3FbKYs= X-MC-Unique: SaZKL8O1PnKv18Y3w1ZYdA-1 X-Mimecast-MFC-AGG-ID: SaZKL8O1PnKv18Y3w1ZYdA_1778346967 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 21/33] ui/vnc: vnc_display_init() and vnc_display_open() return bool Date: Sat, 9 May 2026 21:13:42 +0400 Message-ID: <20260509171356.1157879-22-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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.129.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_H4=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: 1778347182324154100 From: Marc-Andr=C3=A9 Lureau Use the QEMU-style error pattern returning "true" on success. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/ui/console.h | 4 ++-- ui/vnc.c | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 2bf768ed482..7224b8142f3 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -438,8 +438,8 @@ const char *qemu_display_get_vc(DisplayOptions *opts); void qemu_display_help(void); =20 /* vnc.c */ -void vnc_display_init(const char *id, Error **errp); -void vnc_display_open(const char *id, Error **errp); +bool vnc_display_init(const char *id, Error **errp); +bool vnc_display_open(const char *id, Error **errp); void vnc_display_add_client(const char *id, int csock, bool skipauth); int vnc_display_password(const char *id, const char *password, Error **err= p); int vnc_display_pw_expire(const char *id, time_t expires); diff --git a/ui/vnc.c b/ui/vnc.c index 3a908670ab9..067f534cf08 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -3425,12 +3425,12 @@ static void vmstate_change_handler(void *opaque, bo= ol running, RunState state) =20 static void vnc_display_free(VncDisplay *vd); =20 -void vnc_display_init(const char *id, Error **errp) +bool vnc_display_init(const char *id, Error **errp) { VncDisplay *vd; =20 if (vnc_display_find(id) !=3D NULL) { - return; + return true; } vd =3D g_malloc0(sizeof(*vd)); =20 @@ -3451,7 +3451,7 @@ void vnc_display_init(const char *id, Error **errp) =20 if (!vd->kbd_layout) { vnc_display_free(vd); - return; + return false; } =20 vd->share_policy =3D VNC_SHARE_POLICY_ALLOW_EXCLUSIVE; @@ -3465,6 +3465,7 @@ void vnc_display_init(const char *id, Error **errp) &vmstate_change_handler, vd); =20 QTAILQ_INSERT_TAIL(&vnc_displays, vd, next); + return true; } =20 static void vnc_display_close(VncDisplay *vd) @@ -4070,7 +4071,7 @@ bool vnc_display_update(DisplayUpdateOptionsVNC *arg,= Error **errp) return true; } =20 -void vnc_display_open(const char *id, Error **errp) +bool vnc_display_open(const char *id, Error **errp) { VncDisplay *vd =3D vnc_display_find(id); QemuOpts *opts =3D qemu_opts_find(&qemu_vnc_opts, id); @@ -4273,7 +4274,7 @@ void vnc_display_open(const char *id, Error **errp) qkbd_state_set_delay(vd->kbd, key_delay_ms); =20 if (saddr_list =3D=3D NULL) { - return; + return true; } =20 if (reverse) { @@ -4291,10 +4292,11 @@ void vnc_display_open(const char *id, Error **errp) } =20 /* Success */ - return; + return true; =20 fail: vnc_display_close(vd); + return false; } =20 void vnc_display_add_client(const char *id, int csock, bool skipauth) @@ -4350,12 +4352,10 @@ int vnc_init_func(void *opaque, QemuOpts *opts, Err= or **errp) id =3D vnc_auto_assign_id(opts); } =20 - vnc_display_init(id, errp); - if (*errp) { + if (!vnc_display_init(id, errp)) { return -1; } - vnc_display_open(id, errp); - if (*errp) { + if (!vnc_display_open(id, errp)) { return -1; } return 0; --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778347036; cv=none; d=zohomail.com; s=zohoarc; b=iInQWsKxMFwzEDfRN+dGpgG5UlcoJo07+4FFL/tZZ/iPUCAD0Jo2fmbnPpSIy4phwqdSsJgaVW44BjHaByDwiRJLYOkmYeHqkApm2oN5lOLMbIRIcksfv39VqMr+a4Zi+gdCKIZ9iU9Do+MlJ1lEHm7D8j+Y7PofB2dDuTzjEgE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778347036; 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=rSl6Qg2kHxj3sLHlW8PKIqc8zqLChLXQKGoH238Ktd0=; b=J3Bq1UICkNwEvl4vMw0rGbNT1Qerwozsxx9UK9OTze2+pN2Wv/XrUdXksCfmPj8qfsF0gADo+KEetioI+VWBaWyyYbgeAjdlS8Dj01/D3B5OPQ0FkmyYIycdBHILu11OB7NK4cYJ2S7tca4t7fKDKA6FmXBGqyoiRNVHy24mIVc= 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 1778347036496863.3435689672907; Sat, 9 May 2026 10:17:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlHu-00064j-Fg; Sat, 09 May 2026 13:16:26 -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 1wLlHl-0005dz-Sp for qemu-devel@nongnu.org; Sat, 09 May 2026 13:16:20 -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 1wLlHk-0005GS-2K for qemu-devel@nongnu.org; Sat, 09 May 2026 13:16:17 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-70-E09RaorTORC-FQ_Bs_6Zxg-1; Sat, 09 May 2026 13:16:13 -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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6890318005B8; Sat, 9 May 2026 17:16:12 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 57E8918004A3; Sat, 9 May 2026 17:16:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778346974; 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=rSl6Qg2kHxj3sLHlW8PKIqc8zqLChLXQKGoH238Ktd0=; b=D6FIx+wh/4/c1iAVgpMFfpqpnMKQEs5nNKLjXU6ZQYNW41Gg84ewY0wYr3GAOit+vSuKKi FCzM6DKakri2alP98MiOIPMnwk/RfgZlkwTZ4fHzP28wpucJRjGkyb7FA7noDgVunykYqt VCsPLav51/iJlSlI1bnR738rDV0zH/Q= X-MC-Unique: E09RaorTORC-FQ_Bs_6Zxg-1 X-Mimecast-MFC-AGG-ID: E09RaorTORC-FQ_Bs_6Zxg_1778346972 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 22/33] ui/vnc: merge vnc_display_init() and vnc_display_open() Date: Sat, 9 May 2026 21:13:43 +0400 Message-ID: <20260509171356.1157879-23-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 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, SPF_HELO_PASS=-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 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: 1778347038024158500 From: Marc-Andr=C3=A9 Lureau Combine the two-step vnc_display_init()/vnc_display_open() sequence into a single vnc_display_new() function that returns VncDisplay*. This simplifies the API by making vnc_display_open() an internal detail and will allow further code simplification. vnc_display_new() is moved to vnc.h, since it returns VncDisplay* now. Add vnc_display_free() for consistency, and it will be later used. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/ui/console.h | 2 -- ui/vnc.h | 3 ++ ui/vnc.c | 79 ++++++++++++++++++-------------------------- 3 files changed, 36 insertions(+), 48 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 7224b8142f3..550a5e08e46 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -438,8 +438,6 @@ const char *qemu_display_get_vc(DisplayOptions *opts); void qemu_display_help(void); =20 /* vnc.c */ -bool vnc_display_init(const char *id, Error **errp); -bool vnc_display_open(const char *id, Error **errp); void vnc_display_add_client(const char *id, int csock, bool skipauth); int vnc_display_password(const char *id, const char *password, Error **err= p); int vnc_display_pw_expire(const char *id, time_t expires); diff --git a/ui/vnc.h b/ui/vnc.h index 780fd39469f..d2ebb0f7f45 100644 --- a/ui/vnc.h +++ b/ui/vnc.h @@ -549,6 +549,9 @@ enum VncFeatures { #define VNC_CLIPBOARD_NOTIFY (1 << 27) #define VNC_CLIPBOARD_PROVIDE (1 << 28) =20 +VncDisplay *vnc_display_new(const char *id, Error **errp); +void vnc_display_free(VncDisplay *vd); + /*************************************************************************= **** * * Internal APIs diff --git a/ui/vnc.c b/ui/vnc.c index 067f534cf08..1c649e7bccf 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -3423,17 +3423,15 @@ static void vmstate_change_handler(void *opaque, bo= ol running, RunState state) update_displaychangelistener(&vd->dcl, VNC_REFRESH_INTERVAL_BASE); } =20 -static void vnc_display_free(VncDisplay *vd); +static bool vnc_display_open(VncDisplay *vd, Error **errp); =20 -bool vnc_display_init(const char *id, Error **errp) +VncDisplay *vnc_display_new(const char *id, Error **errp) { VncDisplay *vd; =20 - if (vnc_display_find(id) !=3D NULL) { - return true; - } - vd =3D g_malloc0(sizeof(*vd)); + assert(!vnc_display_find(id)); =20 + vd =3D g_new0(VncDisplay, 1); qemu_mutex_init(&vd->mutex); vd->id =3D g_strdup(id); vd->dcl.ops =3D &dcl_ops; @@ -3451,7 +3449,7 @@ bool vnc_display_init(const char *id, Error **errp) =20 if (!vd->kbd_layout) { vnc_display_free(vd); - return false; + return NULL; } =20 vd->share_policy =3D VNC_SHARE_POLICY_ALLOW_EXCLUSIVE; @@ -3464,8 +3462,13 @@ bool vnc_display_init(const char *id, Error **errp) vd->vmstate_handler_entry =3D qemu_add_vm_change_state_handler( &vmstate_change_handler, vd); =20 + if (!vnc_display_open(vd, errp)) { + vnc_display_free(vd); + return NULL; + } + QTAILQ_INSERT_TAIL(&vnc_displays, vd, next); - return true; + return vd; } =20 static void vnc_display_close(VncDisplay *vd) @@ -3506,7 +3509,7 @@ static void vnc_display_close(VncDisplay *vd) #endif } =20 -static void vnc_display_free(VncDisplay *vd) +void vnc_display_free(VncDisplay *vd) { if (!vd) { return; @@ -3528,7 +3531,6 @@ static void vnc_display_free(VncDisplay *vd) g_free(vd); } =20 - int vnc_display_password(const char *id, const char *password, Error **err= p) { VncDisplay *vd =3D vnc_display_find(id); @@ -4071,10 +4073,9 @@ bool vnc_display_update(DisplayUpdateOptionsVNC *arg= , Error **errp) return true; } =20 -bool vnc_display_open(const char *id, Error **errp) +static bool vnc_display_open(VncDisplay *vd, Error **errp) { - VncDisplay *vd =3D vnc_display_find(id); - QemuOpts *opts =3D qemu_opts_find(&qemu_vnc_opts, id); + QemuOpts *opts =3D qemu_opts_find(&qemu_vnc_opts, vd->id); g_autoptr(SocketAddressList) saddr_list =3D NULL; g_autoptr(SocketAddressList) wsaddr_list =3D NULL; const char *share, *device_id; @@ -4093,26 +4094,23 @@ bool vnc_display_open(const char *id, Error **errp) assert(vd); assert(opts); =20 - vnc_display_close(vd); - reverse =3D qemu_opt_get_bool(opts, "reverse", false); if (vnc_display_get_addresses(opts, reverse, &saddr_list, &wsaddr_list, errp) < 0) { - goto fail; + return false; } =20 - passwordSecret =3D qemu_opt_get(opts, "password-secret"); if (passwordSecret) { if (qemu_opt_get(opts, "password")) { error_setg(errp, "'password' flag is redundant with 'password-secret= '"); - goto fail; + return false; } vd->password =3D qcrypto_secret_lookup_as_utf8(passwordSecret, errp); if (!vd->password) { - goto fail; + return false; } password =3D true; } else { @@ -4123,7 +4121,7 @@ bool vnc_display_open(const char *id, Error **errp) QCRYPTO_CIPHER_ALGO_DES, QCRYPTO_CIPHER_MODE_ECB)) { error_setg(errp, "Cipher backend does not support DES algorithm"); - goto fail; + return false; } } =20 @@ -4133,7 +4131,7 @@ bool vnc_display_open(const char *id, Error **errp) #ifndef CONFIG_VNC_SASL if (sasl) { error_setg(errp, "VNC SASL auth requires cyrus-sasl support"); - goto fail; + return false; } #endif /* CONFIG_VNC_SASL */ credid =3D qemu_opt_get(opts, "tls-creds"); @@ -4144,7 +4142,7 @@ bool vnc_display_open(const char *id, Error **errp) if (!creds) { error_setg(errp, "No TLS credentials with id '%s'", credid); - goto fail; + return false; } vd->tlscreds =3D (QCryptoTLSCreds *) object_dynamic_cast(creds, @@ -4152,26 +4150,26 @@ bool vnc_display_open(const char *id, Error **errp) if (!vd->tlscreds) { error_setg(errp, "Object with id '%s' is not TLS credentials", credid); - goto fail; + return false; } object_ref(OBJECT(vd->tlscreds)); =20 if (!qcrypto_tls_creds_check_endpoint(vd->tlscreds, QCRYPTO_TLS_CREDS_ENDPOINT_S= ERVER, errp)) { - goto fail; + return false; } } tlsauthz =3D qemu_opt_get(opts, "tls-authz"); if (tlsauthz && !vd->tlscreds) { error_setg(errp, "'tls-authz' provided but TLS is not enabled"); - goto fail; + return false; } =20 saslauthz =3D qemu_opt_get(opts, "sasl-authz"); if (saslauthz && !sasl) { error_setg(errp, "'sasl-authz' provided but SASL auth is not enabl= ed"); - goto fail; + return false; } =20 share =3D qemu_opt_get(opts, "share"); @@ -4184,7 +4182,7 @@ bool vnc_display_open(const char *id, Error **errp) vd->share_policy =3D VNC_SHARE_POLICY_FORCE_SHARED; } else { error_setg(errp, "unknown vnc share=3D option"); - goto fail; + return false; } } else { vd->share_policy =3D VNC_SHARE_POLICY_ALLOW_EXCLUSIVE; @@ -4218,20 +4216,20 @@ bool vnc_display_open(const char *id, Error **errp) if (vnc_display_setup_auth(&vd->auth, &vd->subauth, vd->tlscreds, password, sasl, false, errp) < 0) { - goto fail; + return false; } trace_vnc_auth_init(vd, 0, vd->auth, vd->subauth); =20 if (vnc_display_setup_auth(&vd->ws_auth, &vd->ws_subauth, vd->tlscreds, password, sasl, true, errp) < 0) { - goto fail; + return false; } trace_vnc_auth_init(vd, 1, vd->ws_auth, vd->ws_subauth); =20 #ifdef CONFIG_VNC_SASL if (sasl && !vnc_sasl_server_init(errp)) { - goto fail; + return false; } #endif vd->lock_key_sync =3D lock_key_sync; @@ -4244,7 +4242,7 @@ bool vnc_display_open(const char *id, Error **errp) if (audiodev) { vd->audio_be =3D audio_be_by_name(audiodev, errp); if (!vd->audio_be) { - goto fail; + return false; } } else { vd->audio_be =3D audio_get_default_audio_be(NULL); @@ -4258,7 +4256,7 @@ bool vnc_display_open(const char *id, Error **errp) con =3D qemu_console_lookup_by_device_name(device_id, head, &err); if (err) { error_propagate(errp, err); - goto fail; + return false; } } else { con =3D qemu_console_lookup_default(); @@ -4279,11 +4277,11 @@ bool vnc_display_open(const char *id, Error **errp) =20 if (reverse) { if (vnc_display_connect(vd, saddr_list, wsaddr_list, errp) < 0) { - goto fail; + return false; } } else { if (vnc_display_listen(vd, saddr_list, wsaddr_list, errp) < 0) { - goto fail; + return false; } } =20 @@ -4291,12 +4289,7 @@ bool vnc_display_open(const char *id, Error **errp) vnc_display_print_local_addr(vd); } =20 - /* Success */ return true; - -fail: - vnc_display_close(vd); - return false; } =20 void vnc_display_add_client(const char *id, int csock, bool skipauth) @@ -4352,13 +4345,7 @@ int vnc_init_func(void *opaque, QemuOpts *opts, Erro= r **errp) id =3D vnc_auto_assign_id(opts); } =20 - if (!vnc_display_init(id, errp)) { - return -1; - } - if (!vnc_display_open(id, errp)) { - return -1; - } - return 0; + return vnc_display_new(id, errp) !=3D NULL ? 0 : -1; } =20 static void vnc_register_config(void) --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778347177; cv=none; d=zohomail.com; s=zohoarc; b=assQLYLihktkqbC5uo5VEKIEtakIn9zcX8BhyEq4pkFmjqtRu5bNjkXkqme4yRO3o3IGgbhEPiqURNLLmAvzjJseJs4XhWRo5BV9wkXHJtMPPX9peQdHs+1YpG8mvHGB2T1FCLs5qbMRm7wFHYi/dgaJVUpOuZOjSd2GXxoLkeg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778347177; 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=0Ut9hVNcaNcfqrxmvxrNuTtAlj/ior+DgGj+U0dvZAo=; b=gR0TSaTUAn2yWEUksbGvvYPuikAvgsgBf9L72CJFyFujRmU/SZaOjL7czg524CaU7Ux9Zo2h6RBrnVmRx6fGqTPobBliBb1aJay3RvR3qGUEdgNi49oxyOHVWrIhNgjfl+dVvSdtanAGvvHNxcAJnJRss4qrrzmdO0C19GkYLlk= 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 1778347177487840.1639595252293; Sat, 9 May 2026 10:19:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlHt-000617-Mg; Sat, 09 May 2026 13:16:25 -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 1wLlHq-0005m5-9S for qemu-devel@nongnu.org; Sat, 09 May 2026 13:16:23 -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 1wLlHo-0005HX-MG for qemu-devel@nongnu.org; Sat, 09 May 2026 13:16:22 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-8-5nu8gJjANSmzFgeFKQmaIQ-1; Sat, 09 May 2026 13:16:18 -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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9128C1800343; Sat, 9 May 2026 17:16:17 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 96B5618004A3; Sat, 9 May 2026 17:16:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778346979; 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=0Ut9hVNcaNcfqrxmvxrNuTtAlj/ior+DgGj+U0dvZAo=; b=d5OOmvtAtkRsx/1QHqHErFya+t6EZEyubiZF2stt+dogbruZzFjHtGJ4XXKvSC3YWDSxMg g8LQD9G1vYa3EJgBhSpA/lmNt5Cizu5vVi1lm12JJ0twCL18aJMkXk/n3qLP7ogTvMjGmb l0tX7P2pWfH3mXJYgdepoEZYXLFStNM= X-MC-Unique: 5nu8gJjANSmzFgeFKQmaIQ-1 X-Mimecast-MFC-AGG-ID: 5nu8gJjANSmzFgeFKQmaIQ_1778346977 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Subject: [PULL v2 23/33] ui/vnc: clean up VNC displays on exit Date: Sat, 9 May 2026 21:13:44 +0400 Message-ID: <20260509171356.1157879-24-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 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, SPF_HELO_PASS=-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 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: 1778347180306154100 From: Marc-Andr=C3=A9 Lureau Previously, VNC displays were never torn down on QEMU exit, leaking resources and leaving connected clients with unclean disconnects. Add vnc_cleanup() to free all VNC displays during qemu_cleanup(). Make vnc_display_close() initiate disconnection of active clients, and have vnc_display_free() drain the main loop until all clients have completed their teardown, instead of asserting the client list is empty. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/ui/console.h | 1 + system/runstate.c | 5 +++++ ui/vnc.c | 20 ++++++++++++++++++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 550a5e08e46..89fb4c1942a 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -445,6 +445,7 @@ void vnc_parse(const char *str); int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp); bool vnc_display_reload_certs(const char *id, Error **errp); bool vnc_display_update(DisplayUpdateOptionsVNC *arg, Error **errp); +void vnc_cleanup(void); =20 /* input.c */ int index_from_key(const char *key, size_t key_length); diff --git a/system/runstate.c b/system/runstate.c index 770253b467b..0e1cb3b4e67 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -61,6 +61,8 @@ #include "system/confidential-guest-support.h" #include "system/system.h" #include "system/tpm.h" +#include "ui/console.h" + #include "trace.h" =20 static NotifierList exit_notifiers =3D @@ -1044,5 +1046,8 @@ void qemu_cleanup(int status) monitor_cleanup(); qemu_chr_cleanup(); user_creatable_cleanup(); +#ifdef CONFIG_VNC + vnc_cleanup(); +#endif /* TODO: unref root container, check all devices are ok */ } diff --git a/ui/vnc.c b/ui/vnc.c index 1c649e7bccf..d65153a5001 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -3473,8 +3473,13 @@ VncDisplay *vnc_display_new(const char *id, Error **= errp) =20 static void vnc_display_close(VncDisplay *vd) { + VncState *vs; + assert(vd); =20 + QTAILQ_FOREACH(vs, &vd->clients, next) { + vnc_disconnect_start(vs); + } if (vd->listener) { qio_net_listener_disconnect(vd->listener); object_unref(OBJECT(vd->listener)); @@ -3515,10 +3520,12 @@ void vnc_display_free(VncDisplay *vd) return; } =20 - assert(QTAILQ_EMPTY(&vd->clients)); + vnc_display_close(vd); + while (!QTAILQ_EMPTY(&vd->clients)) { + main_loop_wait(false); + } =20 vnc_stop_worker_thread(vd); - vnc_display_close(vd); unregister_displaychangelistener(&vd->dcl); qkbd_state_free(vd->kbd); qemu_del_vm_change_state_handler(vd->vmstate_handler_entry); @@ -4348,6 +4355,15 @@ int vnc_init_func(void *opaque, QemuOpts *opts, Erro= r **errp) return vnc_display_new(id, errp) !=3D NULL ? 0 : -1; } =20 +void vnc_cleanup(void) +{ + VncDisplay *vd, *vd_next; + + QTAILQ_FOREACH_SAFE(vd, &vnc_displays, next, vd_next) { + vnc_display_free(vd); + } +} + static void vnc_register_config(void) { qemu_add_opts(&qemu_vnc_opts); --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778347014; cv=none; d=zohomail.com; s=zohoarc; b=d5Mq9v7GFMFRaZv9Tk+dqBMyhNkkGcKhXKv8oIW/d1wMvdT9ud+hU91hGScpeoS9/u/UHNIsHtkXwWIAjI4d7p7bmrqvhQ14JhCdadHALNeHvw1GX+xSQo6lcXqEggPW2JU3e1r6fY37bF2y6f8epaDuKfM6wSumIp1iKLK7x64= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778347014; 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=4N3hQj9EjQUIZF134aiZJrF9XMeohYQd/6PSpXWb5D8=; b=MzjqNMbA0ujwxP97vj3MtbkG/5Ewv91LaoF8v0sn23hBh3spAnbwwNq3wz2XYn1Com116aWdKdREEZfiv1GjL6hPS4Hw6lGN5+H2zLbGGASjSA6lnhXviwQXp7BYhkR0BanVj9LoZ98ea2a1XA6T7Ve4ia0EcEyBI1MbfP6pLcA= 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 1778347014389198.98336620252007; Sat, 9 May 2026 10:16:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlHz-0006ob-5W; Sat, 09 May 2026 13:16:31 -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 1wLlHx-0006bg-J8 for qemu-devel@nongnu.org; Sat, 09 May 2026 13:16:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wLlHv-0005IZ-W4 for qemu-devel@nongnu.org; Sat, 09 May 2026 13:16:29 -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-649-UccH4XBYO6OBbQcsrKdzDA-1; Sat, 09 May 2026 13:16:24 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 2570E19560AA; Sat, 9 May 2026 17:16:23 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C454119560A2; Sat, 9 May 2026 17:16:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778346987; 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=4N3hQj9EjQUIZF134aiZJrF9XMeohYQd/6PSpXWb5D8=; b=KRzAF8Swgom52QJcgwcvT6OgNxre4H/C1+M70PvDLd8fDAFPwLigVLeMQUgC/GHWkBz5WM o+dwDAwjA3XpZX7hoWe43y8JMedoLvT4KEYjSkwovbHEdJsSHZf8qaOdyNg9iuooesbQDx 4ppHHdnfZwoNHIIXRX0JbAEXvN4Vf3w= X-MC-Unique: UccH4XBYO6OBbQcsrKdzDA-1 X-Mimecast-MFC-AGG-ID: UccH4XBYO6OBbQcsrKdzDA_1778346983 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 24/33] ui/vnc: defer listener registration until the console is known Date: Sat, 9 May 2026 21:13:45 +0400 Message-ID: <20260509171356.1157879-25-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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.129.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_H4=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: 1778347017797158502 From: Marc-Andr=C3=A9 Lureau Previously, the display change listener was registered early in vnc_display_new() without a console, requiring vnc_display_open() to conditionally unregister and re-register it when the actual console was resolved. Since vnc_display_new() and vnc_display_open() were merged in the previous commit, simply delay the registration and keyboard state initialization to vnc_display_open(), after the console has been looked up. This removes the conditional re-registration and simplifies the code. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/vnc.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/ui/vnc.c b/ui/vnc.c index d65153a5001..ea1579135b8 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -3457,8 +3457,6 @@ VncDisplay *vnc_display_new(const char *id, Error **e= rrp) =20 vnc_start_worker_thread(vd); =20 - register_displaychangelistener(&vd->dcl); - vd->kbd =3D qkbd_state_init(vd->dcl.con); vd->vmstate_handler_entry =3D qemu_add_vm_change_state_handler( &vmstate_change_handler, vd); =20 @@ -4269,13 +4267,9 @@ static bool vnc_display_open(VncDisplay *vd, Error *= *errp) con =3D qemu_console_lookup_default(); } =20 - if (con !=3D vd->dcl.con) { - qkbd_state_free(vd->kbd); - unregister_displaychangelistener(&vd->dcl); - vd->dcl.con =3D con; - register_displaychangelistener(&vd->dcl); - vd->kbd =3D qkbd_state_init(vd->dcl.con); - } + vd->dcl.con =3D con; + register_displaychangelistener(&vd->dcl); + vd->kbd =3D qkbd_state_init(vd->dcl.con); qkbd_state_set_delay(vd->kbd, key_delay_ms); =20 if (saddr_list =3D=3D NULL) { --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778347008; cv=none; d=zohomail.com; s=zohoarc; b=EPjDaQmkJaBQ6JQLAPo7f/KrEexNwU8I88TqWevXG09u/+pxNo7KQ+l2UoMyRGs40V+onmsgcFLJjkgQPaiYlwqwvbKBFCPq5F1MBbpiKU1iQImm+mHAhKHoQ/eiX9Dm1C1BGYcxKd8GNAYaUsdTXQFG6sKdfUphVSHpRjpHixw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778347008; 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=+Gmc791aL5c7XJeFqvLsA3fXbA9hTzJpJ+t7ss6+PVE=; b=L3UD8Py1eDafhb5TaFtOGrfhiDYmPxYAnoghuDm6stFQsZSlselqBMDYfPiQhEYallcUjeeaVJOLK4TTdXe02x9xgmACyHbLNTpnb4Pzuk6kNmbxO+dywAS7jviV5sx/QLZov7y6R2Bu4K8EUtid8RMLLim98uO7Yd6xNp3aQNk= 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 1778347008314177.48010984657333; Sat, 9 May 2026 10:16:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlI6-0007u2-BR; Sat, 09 May 2026 13:16:38 -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 1wLlI3-0007S9-I6 for qemu-devel@nongnu.org; Sat, 09 May 2026 13:16:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wLlI2-0005JT-0Q for qemu-devel@nongnu.org; Sat, 09 May 2026 13:16:35 -0400 Received: from mx-prod-mc-01.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-345-qL9xpFabM86brWZeFNFdmA-1; Sat, 09 May 2026 13:16:29 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 76C0A19560B0; Sat, 9 May 2026 17:16:28 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6049319560A2; Sat, 9 May 2026 17:16:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778346993; 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=+Gmc791aL5c7XJeFqvLsA3fXbA9hTzJpJ+t7ss6+PVE=; b=RBhOC7RFSwKHvYjMfwwT2cyqVg7IDh2/HKOlytNOD5AyVEbncTz5Q8YXFK8oBzhpsRcGo7 MGI8vKy2BerQJ5zi/by/qKEtu3dFttMYBWFUwBmiRvgTQITYUEz02a0iELQx78mFN9nwzC dnCBIdsTJUZiAvSfJCRc1adbiVDAi9s= X-MC-Unique: qL9xpFabM86brWZeFNFdmA-1 X-Mimecast-MFC-AGG-ID: qL9xpFabM86brWZeFNFdmA_1778346988 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 25/33] ui/vnc: add vnc-system unit, to allow different implementations Date: Sat, 9 May 2026 21:13:46 +0400 Message-ID: <20260509171356.1157879-26-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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.129.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_H4=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: 1778347011334154100 From: Marc-Andr=C3=A9 Lureau The qemu-vnc server will want to signal the XVP requests, let it have its own implementation. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/vnc.h | 4 ++++ ui/vnc-system.c | 19 +++++++++++++++++++ ui/vnc.c | 4 ++-- ui/meson.build | 2 +- 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 ui/vnc-system.c diff --git a/ui/vnc.h b/ui/vnc.h index d2ebb0f7f45..0b345246c8e 100644 --- a/ui/vnc.h +++ b/ui/vnc.h @@ -648,4 +648,8 @@ void vnc_server_cut_text_caps(VncState *vs); void vnc_client_cut_text(VncState *vs, size_t len, uint8_t *text); void vnc_client_cut_text_ext(VncState *vs, int32_t len, uint32_t flags, ui= nt8_t *data); =20 +/* XVP events */ +void vnc_action_shutdown(VncState *vs); +void vnc_action_reset(VncState *vs); + #endif /* QEMU_VNC_H */ diff --git a/ui/vnc-system.c b/ui/vnc-system.c new file mode 100644 index 00000000000..0632885f655 --- /dev/null +++ b/ui/vnc-system.c @@ -0,0 +1,19 @@ +/* + * QEMU VNC display driver + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include "qemu/osdep.h" + +#include "ui/vnc.h" +#include "system/runstate.h" + +void vnc_action_shutdown(VncState *vs) +{ + qemu_system_powerdown_request(); +} + +void vnc_action_reset(VncState *vs) +{ + qemu_system_reset_request(SHUTDOWN_CAUSE_HOST_QMP_SYSTEM_RESET); +} diff --git a/ui/vnc.c b/ui/vnc.c index ea1579135b8..154b07e2e4e 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -2522,13 +2522,13 @@ static int protocol_client_msg(VncState *vs, uint8_= t *data, size_t len) =20 switch (action) { case VNC_XVP_ACTION_SHUTDOWN: - qemu_system_powerdown_request(); + vnc_action_shutdown(vs); break; case VNC_XVP_ACTION_REBOOT: send_xvp_message(vs, VNC_XVP_CODE_FAIL); break; case VNC_XVP_ACTION_RESET: - qemu_system_reset_request(SHUTDOWN_CAUSE_HOST_QMP_SYSTEM_R= ESET); + vnc_action_reset(vs); break; default: send_xvp_message(vs, VNC_XVP_CODE_FAIL); diff --git a/ui/meson.build b/ui/meson.build index 7b6e867d3af..74151b05033 100644 --- a/ui/meson.build +++ b/ui/meson.build @@ -48,7 +48,7 @@ vnc_ss.add(files( vnc_ss.add(zlib, jpeg, png) vnc_ss.add(when: sasl, if_true: files('vnc-auth-sasl.c')) system_ss.add_all(when: [vnc, pixman], if_true: vnc_ss) -system_ss.add(when: vnc, if_false: files('vnc-stubs.c')) +system_ss.add(when: vnc, if_true: files('vnc-system.c'), if_false: files('= vnc-stubs.c')) =20 ui_modules =3D {} =20 --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778347023; cv=none; d=zohomail.com; s=zohoarc; b=IRQI1ayWLx0vlhDF6Q3ugP2FHfyVL2QI32IgEaz2n9JvYXgHGbQrdkvpzYv3jrysjw2XAHE24MEq6ObexEbzwK+5zSJlQLM078nolyeVt2JI4TsHk6bSTMEYds427+HbFoF7Samr3vxXl9R3rAGULMk9lKFp75tx4AhjMGJjLso= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778347023; 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=g+c4BIrOH8DkncyyrvHy+6mRNt8eywsptgQTzkEOG+U=; b=iUUCg8/KPDjXMd6YJ4W2DqVW7m6RUiQREILu772nMM7PIhy75CIGqTVzo4kDrhh8Xlwq5xuvRDBbQSPuEMEnIIdX4FePQ18kEVXxgra070cMHQfHXj5PwV6pLRtAySGt7ZkNvsskkGhXRIlFPY9YzUMDC/oKy/yUs8CrR+0pSlM= 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 1778347023226881.7912866450572; Sat, 9 May 2026 10:17:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlIQ-0000Mo-8L; Sat, 09 May 2026 13:16:58 -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 1wLlIB-00004w-J7 for qemu-devel@nongnu.org; Sat, 09 May 2026 13:16:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wLlI7-0005KZ-Ey for qemu-devel@nongnu.org; Sat, 09 May 2026 13:16:41 -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-365-BvnryurSMzCnQOPU4uqJ4A-1; Sat, 09 May 2026 13:16:36 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 1E66E195605F; Sat, 9 May 2026 17:16:35 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 294781800352; Sat, 9 May 2026 17:16:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778346998; 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=g+c4BIrOH8DkncyyrvHy+6mRNt8eywsptgQTzkEOG+U=; b=dYtMOe4469AWJRRMMEOon9mBn5aXRV5il8fFqy02Jn5A1ZwhgG5WhaYi/aW9rIY88eQHGE PmnfkHhTwM/QL59zwo+Qmi+iP2TZEGYZTsgEgMIgslx5nhzoraaX3LLd2sx5LXsuMOXLaT g7uwYsxJgvGTnGvtTGX+0TAU+hFhjNI= X-MC-Unique: BvnryurSMzCnQOPU4uqJ4A-1 X-Mimecast-MFC-AGG-ID: BvnryurSMzCnQOPU4uqJ4A_1778346995 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki Subject: [PULL v2 26/33] ui/console: simplify registering display/console change listener Date: Sat, 9 May 2026 21:13:47 +0400 Message-ID: <20260509171356.1157879-27-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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.129.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_H4=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: 1778347024239158500 From: Marc-Andr=C3=A9 Lureau Introduce qemu_console_register_listener() which combines setting dcl->con, dcl->ops and calling register_displaychangelistener() into a single call. This removes repetitive boilerplate across all display backends and makes it harder to forget setting one of the fields. Also move the early-return check in unregister_displaychangelistener() before the trace call, so that unregistering a never-registered listener (e.g. on error paths) does not dereference a NULL ops pointer. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/ui/console.h | 6 ++++-- hw/display/qxl.c | 4 +--- ui/console.c | 11 ++++++++--- ui/curses.c | 9 +++------ ui/dbus-console.c | 6 ++---- ui/dbus-listener.c | 27 ++++++++------------------- ui/egl-headless.c | 4 +--- ui/gtk.c | 10 ++++------ ui/sdl2.c | 8 +++----- ui/spice-display.c | 8 +++----- ui/vnc.c | 11 ++++------- ui/cocoa.m | 13 ++++--------- 12 files changed, 45 insertions(+), 72 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 89fb4c1942a..69ac7b01b33 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -291,10 +291,12 @@ struct DisplayGLCtx { =20 DisplayState *init_displaystate(void); =20 -void register_displaychangelistener(DisplayChangeListener *dcl); +void qemu_console_register_listener(QemuConsole *con, + DisplayChangeListener *dcl, + const DisplayChangeListenerOps *ops); void update_displaychangelistener(DisplayChangeListener *dcl, uint64_t interval); -void unregister_displaychangelistener(DisplayChangeListener *dcl); +void qemu_console_unregister_listener(DisplayChangeListener *dcl); =20 bool dpy_ui_info_supported(const QemuConsole *con); const QemuUIInfo *dpy_get_ui_info(const QemuConsole *con); diff --git a/hw/display/qxl.c b/hw/display/qxl.c index 0a3c42c8ec2..4244ebe51d2 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -2251,9 +2251,7 @@ static void qxl_realize_primary(PCIDevice *dev, Error= **errp) return; } =20 - qxl->ssd.dcl.ops =3D &display_listener_ops; - qxl->ssd.dcl.con =3D vga->con; - register_displaychangelistener(&qxl->ssd.dcl); + qemu_console_register_listener(vga->con, &qxl->ssd.dcl, &display_liste= ner_ops); } =20 static void qxl_realize_secondary(PCIDevice *dev, Error **errp) diff --git a/ui/console.c b/ui/console.c index b837ce1c9fc..4f3b4394268 100644 --- a/ui/console.c +++ b/ui/console.c @@ -572,10 +572,15 @@ dcl_set_graphic_cursor(DisplayChangeListener *dcl, Qe= muGraphicConsole *con) } } =20 -void register_displaychangelistener(DisplayChangeListener *dcl) +void qemu_console_register_listener(QemuConsole *con, + DisplayChangeListener *dcl, + const DisplayChangeListenerOps *ops) { assert(!dcl->ds); =20 + dcl->con =3D con; + dcl->ops =3D ops; + trace_displaychangelistener_register(dcl, dcl->ops->dpy_name); dcl->ds =3D get_alloc_displaystate(); QLIST_INSERT_HEAD(&dcl->ds->listeners, dcl, next); @@ -600,10 +605,10 @@ void update_displaychangelistener(DisplayChangeListen= er *dcl, } } =20 -void unregister_displaychangelistener(DisplayChangeListener *dcl) +void qemu_console_unregister_listener(DisplayChangeListener *dcl) { DisplayState *ds =3D dcl->ds; - trace_displaychangelistener_unregister(dcl, dcl->ops->dpy_name); + trace_displaychangelistener_unregister(dcl, dcl->ops ? dcl->ops->dpy_n= ame : NULL); if (!ds) { return; } diff --git a/ui/curses.c b/ui/curses.c index 96427aa6bb9..dbb5992981c 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -324,9 +324,8 @@ static void curses_refresh(DisplayChangeListener *dcl) if (con) { erase(); wnoutrefresh(stdscr); - unregister_displaychangelistener(dcl); - dcl->con =3D con; - register_displaychangelistener(dcl); + qemu_console_unregister_listener(dcl); + qemu_console_register_listener(con, dcl, dcl->= ops); =20 invalidate =3D 1; } @@ -805,9 +804,7 @@ static void curses_display_init(DisplayState *ds, Displ= ayOptions *opts) curses_winch_init(); =20 dcl =3D g_new0(DisplayChangeListener, 1); - dcl->con =3D qemu_console_lookup_default(); - dcl->ops =3D &dcl_ops; - register_displaychangelistener(dcl); + qemu_console_register_listener(qemu_console_lookup_default(), dcl, &dc= l_ops); =20 invalidate =3D 1; } diff --git a/ui/dbus-console.c b/ui/dbus-console.c index 564f004bd86..23f547a673d 100644 --- a/ui/dbus-console.c +++ b/ui/dbus-console.c @@ -143,7 +143,6 @@ dbus_display_console_init(DBusDisplayConsole *object) DBusDisplayConsole *ddc =3D DBUS_DISPLAY_CONSOLE(object); =20 ddc->listeners =3D g_ptr_array_new_with_free_func(g_object_unref); - ddc->dcl.ops =3D &dbus_console_dcl_ops; } =20 static void @@ -151,7 +150,7 @@ dbus_display_console_dispose(GObject *object) { DBusDisplayConsole *ddc =3D DBUS_DISPLAY_CONSOLE(object); =20 - unregister_displaychangelistener(&ddc->dcl); + qemu_console_unregister_listener(&ddc->dcl); g_clear_object(&ddc->iface_touch); g_clear_object(&ddc->iface_mouse); g_clear_object(&ddc->iface_kbd); @@ -553,7 +552,6 @@ dbus_display_console_new(DBusDisplay *display, QemuCons= ole *con) "g-object-path", path, NULL); ddc->display =3D display; - ddc->dcl.con =3D con; /* handle errors, and skip non graphics? */ qemu_console_fill_device_address( con, device_addr, sizeof(device_addr), NULL); @@ -611,7 +609,7 @@ dbus_display_console_new(DBusDisplay *display, QemuCons= ole *con) slot->tracking_id =3D -1; } =20 - register_displaychangelistener(&ddc->dcl); + qemu_console_register_listener(con, &ddc->dcl, &dbus_console_dcl_ops); ddc->mouse_mode_notifier.notify =3D dbus_mouse_mode_change; qemu_add_mouse_mode_change_notifier(&ddc->mouse_mode_notifier); dbus_mouse_update_is_absolute(ddc); diff --git a/ui/dbus-listener.c b/ui/dbus-listener.c index e5ce92d1257..cc2c969686e 100644 --- a/ui/dbus-listener.c +++ b/ui/dbus-listener.c @@ -957,7 +957,7 @@ dbus_display_listener_dispose(GObject *object) { DBusDisplayListener *ddl =3D DBUS_DISPLAY_LISTENER(object); =20 - unregister_displaychangelistener(&ddl->dcl); + qemu_console_unregister_listener(&ddl->dcl); g_clear_object(&ddl->conn); g_clear_pointer(&ddl->bus_name, g_free); g_clear_object(&ddl->proxy); @@ -978,28 +978,12 @@ dbus_display_listener_dispose(GObject *object) G_OBJECT_CLASS(dbus_display_listener_parent_class)->dispose(object); } =20 -static void -dbus_display_listener_constructed(GObject *object) -{ - DBusDisplayListener *ddl =3D DBUS_DISPLAY_LISTENER(object); - - ddl->dcl.ops =3D &dbus_dcl_ops; -#ifdef CONFIG_OPENGL - if (display_opengl) { - ddl->dcl.ops =3D &dbus_gl_dcl_ops; - } -#endif - - G_OBJECT_CLASS(dbus_display_listener_parent_class)->constructed(object= ); -} - static void dbus_display_listener_class_init(DBusDisplayListenerClass *klass) { GObjectClass *object_class =3D G_OBJECT_CLASS(klass); =20 object_class->dispose =3D dbus_display_listener_dispose; - object_class->constructed =3D dbus_display_listener_constructed; } =20 static void @@ -1258,6 +1242,7 @@ dbus_display_listener_new(const char *bus_name, GDBusConnection *conn, DBusDisplayConsole *console) { + const DisplayChangeListenerOps *ops =3D &dbus_dcl_ops; DBusDisplayListener *ddl; QemuConsole *con; g_autoptr(GError) err =3D NULL; @@ -1290,8 +1275,12 @@ dbus_display_listener_new(const char *bus_name, =20 con =3D qemu_console_lookup_by_index(dbus_display_console_get_index(co= nsole)); assert(con); - ddl->dcl.con =3D con; - register_displaychangelistener(&ddl->dcl); +#ifdef CONFIG_OPENGL + if (display_opengl) { + ops =3D &dbus_gl_dcl_ops; + } +#endif + qemu_console_register_listener(con, &ddl->dcl, ops); =20 return ddl; } diff --git a/ui/egl-headless.c b/ui/egl-headless.c index 352b30b43fb..4f046c975a9 100644 --- a/ui/egl-headless.c +++ b/ui/egl-headless.c @@ -229,13 +229,11 @@ static void egl_headless_init(DisplayState *ds, Displ= ayOptions *opts) } =20 edpy =3D g_new0(egl_dpy, 1); - edpy->dcl.con =3D con; - edpy->dcl.ops =3D &egl_ops; edpy->gls =3D qemu_gl_init_shader(); ctx =3D g_new0(DisplayGLCtx, 1); ctx->ops =3D &eglctx_ops; qemu_console_set_display_gl_ctx(con, ctx); - register_displaychangelistener(&edpy->dcl); + qemu_console_register_listener(con, &edpy->dcl, &egl_ops); } } =20 diff --git a/ui/gtk.c b/ui/gtk.c index ec95f0f294a..ef3707b3634 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -2251,6 +2251,7 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, Vir= tualConsole *vc, QemuConsole *con, int idx, GSList *group, GtkWidget *view_menu) { + const DisplayChangeListenerOps *ops =3D &dcl_ops; bool zoom_to_fit =3D false; int i; =20 @@ -2275,7 +2276,7 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, Vir= tualConsole *vc, vc->gfx.drawing_area =3D gtk_gl_area_new(); g_signal_connect(vc->gfx.drawing_area, "realize", G_CALLBACK(gl_area_realize), vc); - vc->gfx.dcl.ops =3D &dcl_gl_area_ops; + ops =3D &dcl_gl_area_ops; vc->gfx.dgc.ops =3D &gl_area_ctx_ops; } else { #ifdef CONFIG_X11 @@ -2290,7 +2291,7 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, Vir= tualConsole *vc, #pragma GCC diagnostic ignored "-Wdeprecated-declarations" gtk_widget_set_double_buffered(vc->gfx.drawing_area, FALSE); #pragma GCC diagnostic pop - vc->gfx.dcl.ops =3D &dcl_egl_ops; + ops =3D &dcl_egl_ops; vc->gfx.dgc.ops =3D &egl_ctx_ops; vc->gfx.has_dmabuf =3D qemu_egl_has_dmabuf(); #else @@ -2301,7 +2302,6 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, Vir= tualConsole *vc, #endif { vc->gfx.drawing_area =3D gtk_drawing_area_new(); - vc->gfx.dcl.ops =3D &dcl_ops; } =20 =20 @@ -2325,12 +2325,10 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, V= irtualConsole *vc, vc->tab_item, gtk_label_new(vc->label)); =20 vc->gfx.kbd =3D qkbd_state_init(con); - vc->gfx.dcl.con =3D con; - if (display_opengl) { qemu_console_set_display_gl_ctx(con, &vc->gfx.dgc); } - register_displaychangelistener(&vc->gfx.dcl); + qemu_console_register_listener(con, &vc->gfx.dcl, ops); =20 gd_connect_vc_gfx_signals(vc); group =3D gd_vc_menu_init(s, vc, idx, group, view_menu); diff --git a/ui/sdl2.c b/ui/sdl2.c index 5dd612d9a6a..89516f95c41 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -934,6 +934,7 @@ static void sdl2_display_init(DisplayState *ds, Display= Options *o) sdl2_console =3D g_new0(struct sdl2_console, sdl2_num_outputs); for (i =3D 0; i < sdl2_num_outputs; i++) { QemuConsole *con =3D qemu_console_lookup_by_index(i); + const DisplayChangeListenerOps *ops =3D &dcl_2d_ops; assert(con !=3D NULL); if (!qemu_console_is_graphic(con) && qemu_console_get_index(con) !=3D 0) { @@ -943,13 +944,11 @@ static void sdl2_display_init(DisplayState *ds, Displ= ayOptions *o) sdl2_console[i].opts =3D o; #ifdef CONFIG_OPENGL sdl2_console[i].opengl =3D display_opengl; - sdl2_console[i].dcl.ops =3D display_opengl ? &dcl_gl_ops : &dcl_2d= _ops; sdl2_console[i].dgc.ops =3D display_opengl ? &gl_ctx_ops : NULL; + ops =3D display_opengl ? &dcl_gl_ops : &dcl_2d_ops; #else sdl2_console[i].opengl =3D 0; - sdl2_console[i].dcl.ops =3D &dcl_2d_ops; #endif - sdl2_console[i].dcl.con =3D con; sdl2_console[i].kbd =3D qkbd_state_init(con); #ifdef CONFIG_OPENGL if (display_opengl) { @@ -957,8 +956,7 @@ static void sdl2_display_init(DisplayState *ds, Display= Options *o) sdl2_gl_console_init(&sdl2_console[i]); } #endif - register_displaychangelistener(&sdl2_console[i].dcl); - + qemu_console_register_listener(con, &sdl2_console[i].dcl, ops); #if defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_X11) if (SDL_GetWindowWMInfo(sdl2_console[i].real_window, &info)) { #if defined(SDL_VIDEO_DRIVER_WINDOWS) diff --git a/ui/spice-display.c b/ui/spice-display.c index 87cc193cdee..56d8140fad8 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -1387,13 +1387,13 @@ static void qemu_spice_display_init_one(QemuConsole= *con) SimpleSpiceDisplay *ssd =3D g_new0(SimpleSpiceDisplay, 1); Error *err =3D NULL; char device_address[256] =3D ""; + const DisplayChangeListenerOps *ops =3D &display_listener_ops; =20 qemu_spice_display_init_common(ssd); =20 - ssd->dcl.ops =3D &display_listener_ops; #ifdef HAVE_SPICE_GL if (spice_opengl) { - ssd->dcl.ops =3D &display_listener_gl_ops; + ops =3D &display_listener_gl_ops; ssd->dgc.ops =3D &gl_ctx_ops; ssd->gl_unblock_bh =3D qemu_bh_new(qemu_spice_gl_unblock_bh, ssd); ssd->gl_unblock_timer =3D timer_new_ms(QEMU_CLOCK_REALTIME, @@ -1403,8 +1403,6 @@ static void qemu_spice_display_init_one(QemuConsole *= con) ssd->have_scanout =3D false; } #endif - ssd->dcl.con =3D con; - ssd->qxl.base.sif =3D &dpy_interface.base; qemu_spice_add_display_interface(&ssd->qxl, con); =20 @@ -1422,7 +1420,7 @@ static void qemu_spice_display_init_one(QemuConsole *= con) if (spice_opengl) { qemu_console_set_display_gl_ctx(con, &ssd->dgc); } - register_displaychangelistener(&ssd->dcl); + qemu_console_register_listener(con, &ssd->dcl, ops); } =20 void qemu_spice_display_init(void) diff --git a/ui/vnc.c b/ui/vnc.c index 154b07e2e4e..e8c8773a36e 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -1860,10 +1860,9 @@ static void do_key_event(VncState *vs, int down, int= keycode, int sym) qkbd_state_modifier_get(vs->vd->kbd, QKBD_MOD_ALT)) { QemuConsole *con =3D qemu_console_lookup_by_index(qcode - Q_KE= Y_CODE_1); if (con) { - unregister_displaychangelistener(&vs->vd->dcl); + qemu_console_unregister_listener(&vs->vd->dcl); qkbd_state_switch_console(vs->vd->kbd, con); - vs->vd->dcl.con =3D con; - register_displaychangelistener(&vs->vd->dcl); + qemu_console_register_listener(con, &vs->vd->dcl, vs->vd->= dcl.ops); } return; } @@ -3434,7 +3433,6 @@ VncDisplay *vnc_display_new(const char *id, Error **e= rrp) vd =3D g_new0(VncDisplay, 1); qemu_mutex_init(&vd->mutex); vd->id =3D g_strdup(id); - vd->dcl.ops =3D &dcl_ops; =20 QTAILQ_INIT(&vd->clients); vd->expires =3D TIME_MAX; @@ -3524,7 +3522,7 @@ void vnc_display_free(VncDisplay *vd) } =20 vnc_stop_worker_thread(vd); - unregister_displaychangelistener(&vd->dcl); + qemu_console_unregister_listener(&vd->dcl); qkbd_state_free(vd->kbd); qemu_del_vm_change_state_handler(vd->vmstate_handler_entry); kbd_layout_free(vd->kbd_layout); @@ -4267,8 +4265,7 @@ static bool vnc_display_open(VncDisplay *vd, Error **= errp) con =3D qemu_console_lookup_default(); } =20 - vd->dcl.con =3D con; - register_displaychangelistener(&vd->dcl); + qemu_console_register_listener(con, &vd->dcl, &dcl_ops); vd->kbd =3D qkbd_state_init(vd->dcl.con); qkbd_state_set_delay(vd->kbd, key_delay_ms); =20 diff --git a/ui/cocoa.m b/ui/cocoa.m index 9093d1e408f..aaf82421589 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -93,9 +93,7 @@ static void cocoa_switch(DisplayChangeListener *dcl, .dpy_mouse_set =3D cocoa_mouse_set, .dpy_cursor_define =3D cocoa_cursor_define, }; -static DisplayChangeListener dcl =3D { - .ops =3D &dcl_ops, -}; +static DisplayChangeListener dcl; static QKbdState *kbd; static int cursor_hide =3D 1; static int left_command_key_enabled =3D 1; @@ -425,8 +423,7 @@ - (void) selectConsoleLocked:(unsigned int)index =20 unregister_displaychangelistener(&dcl); qkbd_state_switch_console(kbd, con); - dcl.con =3D con; - register_displaychangelistener(&dcl); + qemu_console_register_listener(con, &dcl, &dcl_ops); [self notifyMouseModeChange]; [self updateUIInfo]; } @@ -2145,11 +2142,9 @@ static void cocoa_display_init(DisplayState *ds, Dis= playOptions *opts) add_console_menu_entries(); addRemovableDevicesMenuItems(); =20 - dcl.con =3D qemu_console_lookup_default(); + qemu_console_register_listener(qemu_console_lookup_default(), + &dcl, &dcl_ops); kbd =3D qkbd_state_init(dcl.con); - - // register vga output callbacks - register_displaychangelistener(&dcl); qemu_add_mouse_mode_change_notifier(&mouse_mode_change_notifier); [cocoaView notifyMouseModeChange]; [cocoaView updateUIInfo]; --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778347076; cv=none; d=zohomail.com; s=zohoarc; b=AM0oF3ERwh0WOUtBJVVEjfPI6xmSmYK9sz8Rze/OO1sUB75Bf/K4x+Lr0lTpSXRRdEecT3K5/zUv4YSEnL/juCU1NWicX+rp252ZvKXTTmMifXEusfPt+Y3v9DKeriJy8EidKl2pA0S9Oh9gLbzuYXUOYujdIzEu8Ir7uVwTmQ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778347076; 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=HBuFafYm6F01wcXXCOvB+PnpdAUYUNMO5FI3mobc9nQ=; b=fJrR+NSdRADlPVv/7HbJwBsaWds8lnb2zUjFX/QedyKPxVL0Y+fimMIEUIjLtwonno5XV0o9AdaYGMCItAtrO0WFpaVAhb7dwuwmS2Fma5xcezZSNUh2iYcf3tWly+xPcDEFQzs6YDVGBH28WeuYkHRI2iN3pXsSoEB0ObzMOWk= 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 1778347076933173.48581779196024; Sat, 9 May 2026 10:17:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlIb-0000hE-Ol; Sat, 09 May 2026 13:17:09 -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 1wLlIH-0000Kp-H4 for qemu-devel@nongnu.org; Sat, 09 May 2026 13:16:51 -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 1wLlIE-0005LU-6Q for qemu-devel@nongnu.org; Sat, 09 May 2026 13:16:48 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-596-J-OVLP8rOcOUnpRBenVt0Q-1; Sat, 09 May 2026 13:16:41 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 587CB18002DC; Sat, 9 May 2026 17:16:40 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 569D31800240; Sat, 9 May 2026 17:16:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778347005; 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=HBuFafYm6F01wcXXCOvB+PnpdAUYUNMO5FI3mobc9nQ=; b=iRssY2/uu/hrX8aBBjUyDHgjlSt3yAkNp64X9CDWgh8dvZvkO2Hl3IjQ2ZPnpnDmtAVKok GEfOf52+Fg1KDiWq604L8zp36g3D/o41/Ao2sAOOdJ/3chQcmK2ySUjNTlUogU9mljXezn 3d19EOAEy6EgEqcIs+UWAqZpS+Fq6rc= X-MC-Unique: J-OVLP8rOcOUnpRBenVt0Q-1 X-Mimecast-MFC-AGG-ID: J-OVLP8rOcOUnpRBenVt0Q_1778347000 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 27/33] ui/console: add doc comment for qemu_console_{un}register_listener() Date: Sat, 9 May 2026 21:13:48 +0400 Message-ID: <20260509171356.1157879-28-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 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, SPF_HELO_PASS=-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 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: 1778347078798154100 From: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/console.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ui/console.c b/ui/console.c index 4f3b4394268..22ca1c35db3 100644 --- a/ui/console.c +++ b/ui/console.c @@ -572,6 +572,17 @@ dcl_set_graphic_cursor(DisplayChangeListener *dcl, Qem= uGraphicConsole *con) } } =20 +/* + * qemu_console_register_listener: + * @con: the console to attach the listener to + * @dcl: the display change listener to register + * @ops: the listener operations (callbacks for display updates) + * + * Register a display change listener on a console. The listener + * must not already be registered (i.e. @dcl->ds must be NULL). + * This sets up the listener, adds it to the display state, triggers + * an initial display update, and setup the cursor. + */ void qemu_console_register_listener(QemuConsole *con, DisplayChangeListener *dcl, const DisplayChangeListenerOps *ops) @@ -605,6 +616,15 @@ void update_displaychangelistener(DisplayChangeListene= r *dcl, } } =20 +/* + * qemu_console_unregister_listener: + * @dcl: the display change listener to unregister + * + * Unregister a display change listener, removing it from the + * display state's listener list. If the listener is not currently + * registered (@dcl->ds is NULL), this is a no-op. After unregistering, + * the display refresh timer is recalculated. + */ void qemu_console_unregister_listener(DisplayChangeListener *dcl) { DisplayState *ds =3D dcl->ds; --=20 2.54.0 From nobody Mon May 25 20:37:28 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1778347053; cv=none; d=zohomail.com; s=zohoarc; b=NkAOLyogdlcVekwjJ3Ss7VGvL1WdYjpNHbop3jhhNCpLNir3Wttx8n9J4wIpZtzWDbjSoqirsXeHkoBH84A3ytxcFoE8iYlT5WkA3FxNJn5QQFrnZtDIFyqOYX8ABKzZQiy8t4WqnxcmGYVFEP0Bz94wTeC/ScHPyPbUya1gh/I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778347053; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=S55zZ457fOtWSDgpU0+d8V9m5MMTKNlkmEv79oOosxI=; b=WhJhLnkSB18tWWg7kxu6TnA9fU1IBARRLTBk0QASvAB2ibe6+hUnlFXrAbGtH2Z08GzyOJyLcvjoFJaxJxgnwZQ6ZzBFWVjjpJtzwKKBUQj75xT1qurVo4JzxuWEfG2CTnj/CVCj9TPVqL1d4jdkKQmpTrqv+ZM8WJlGS1jB6Jo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1778347053396640.3854823546247; Sat, 9 May 2026 10:17:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1304899.1577578 (Exim 4.92) (envelope-from ) id 1wLlIW-0004kF-TD; Sat, 09 May 2026 17:17:04 +0000 Received: by outflank-mailman (output) from mailman id 1304899.1577578; Sat, 09 May 2026 17:17:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wLlIW-0004k8-P6; Sat, 09 May 2026 17:17:04 +0000 Received: by outflank-mailman (input) for mailman id 1304899; Sat, 09 May 2026 17:17:03 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wLlIU-0004k2-GJ for xen-devel@lists.xenproject.org; Sat, 09 May 2026 17:17:03 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wLlIT-0026KT-TV for xen-devel@lists.xenproject.org; Sat, 09 May 2026 19:17:01 +0200 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69ff6bfe-5cb7-0a2a0a5109dd-0a2a4502e204-8 for ; Sat, 09 May 2026 19:17:01 +0200 Received: from [170.10.133.124] (helo=us-smtp-delivery-124.mimecast.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 69ff6c0c-af86-0a2a45020019-aa0a857c766d-3 for ; Sat, 09 May 2026 19:17:01 +0200 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-636-BfaoMpQBOwe2Oicoz6BwWg-1; Sat, 09 May 2026 13:16:55 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 6AB3819560B4; Sat, 9 May 2026 17:16:50 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 444FB3002D30; Sat, 9 May 2026 17:16:44 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mimecast20190719 header.d=redhat.com header.i="@redhat.com" header.h="From:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding:In-Reply-To:References" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778347020; 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=S55zZ457fOtWSDgpU0+d8V9m5MMTKNlkmEv79oOosxI=; b=C+TmSI3nIwTwD4oIrctDe9CWbo9P2q+dcej67Ab4ATrZPkE20KAHf35ntdpwWOVz0YQN94 6WlFODnMCIPPg/WEWa8JdCVptM+ojhMTuYepz/WHVG13+ZCDh8BgfbWeQ+brjM+7yKXRYq WcWL1NzGNzlDeUROA94epJNehYQy2T0= X-MC-Unique: BfaoMpQBOwe2Oicoz6BwWg-1 X-Mimecast-MFC-AGG-ID: BfaoMpQBOwe2Oicoz6BwWg_1778347011 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Jan Kiszka , Peter Maydell , Phil Dennis-Jordan , Richard Henderson , Helge Deller , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Mark Cave-Ayland , Samuel Tardieu , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Aleksandar Rikalo , Jean-Christophe Dubois , Laurent Vivier , Thomas Huth , BALATON Zoltan , "Michael S. Tsirkin" , Stefano Garzarella , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko , Dmitry Fleytman , Stefano Stabellini , Anthony PERARD , "Edgar E. Iglesias" , Alistair Francis , Alex Williamson , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-arm@nongnu.org (open list:Musicpal), qemu-ppc@nongnu.org (open list:sam460ex), xen-devel@lists.xenproject.org (open list:X86 Xen CPUs) Subject: [PULL v2 28/33] ui/console: rename public API to use consistent qemu_console_ prefix Date: Sat, 9 May 2026 21:13:49 +0400 Message-ID: <20260509171356.1157879-29-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-MFC-PROC-ID: D35fY0rVM-B65eHF4-ZLT2s8iET6TQw44jBDt0cMmao_1778347011 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-720697/1778347021-7BD672C1-286549E4/0/0 X-purgate-type: clean X-purgate-size: 114193 X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1778347056855154100 From: Marc-Andr=C3=A9 Lureau Rename the display and graphic console public functions to follow a consistent qemu_console_ (or qemu_graphic_console_) naming convention. The previous API used a mix of prefixes: dpy_, graphic_hw_, graphic_console_, console_has_, and update_displaychangelistener(). Unify them under a common qemu_console_ namespace for better discoverability and consistency. The main renames are: - dpy_gfx_*() / dpy_text_*() / dpy_gl_*() =E2=86=92 qemu_console_*() - dpy_{get,set}_ui_info() =E2=86=92 qemu_console_{get,set}_ui_info() - graphic_hw_*() =E2=86=92 qemu_console_hw_*() - graphic_console_*() =E2=86=92 qemu_graphic_console_*() - console_has_gl() =E2=86=92 qemu_console_has_gl() - update_displaychangelistener() =E2=86=92 qemu_console_listener_set_refres= h() No functional changes. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- include/ui/console.h | 108 ++++++++++++------------ hw/arm/musicpal.c | 4 +- hw/display/artist.c | 4 +- hw/display/ati.c | 16 ++-- hw/display/bcm2835_fb.c | 5 +- hw/display/bochs-display.c | 14 ++-- hw/display/cg3.c | 6 +- hw/display/cirrus_vga.c | 8 +- hw/display/cirrus_vga_isa.c | 2 +- hw/display/dm163.c | 6 +- hw/display/exynos4210_fimd.c | 4 +- hw/display/g364fb.c | 10 +-- hw/display/imx6ul_lcdif.c | 14 ++-- hw/display/jazz_led.c | 8 +- hw/display/macfb.c | 6 +- hw/display/next-fb.c | 4 +- hw/display/omap_lcdc.c | 4 +- hw/display/pl110.c | 4 +- hw/display/qxl-render.c | 12 +-- hw/display/qxl.c | 14 ++-- hw/display/ramfb-standalone.c | 2 +- hw/display/ramfb.c | 4 +- hw/display/sm501.c | 6 +- hw/display/ssd0303.c | 4 +- hw/display/ssd0323.c | 5 +- hw/display/tcx.c | 16 ++-- hw/display/vga-isa.c | 2 +- hw/display/vga-mmio.c | 2 +- hw/display/vga-pci.c | 6 +- hw/display/vga.c | 40 +++++---- hw/display/vhost-user-gpu.c | 22 ++--- hw/display/virtio-gpu-base.c | 2 +- hw/display/virtio-gpu-rutabaga.c | 10 +-- hw/display/virtio-gpu-udmabuf.c | 4 +- hw/display/virtio-gpu-virgl.c | 20 ++--- hw/display/virtio-gpu.c | 26 +++--- hw/display/virtio-vga.c | 2 +- hw/display/vmware_vga.c | 12 +-- hw/display/xenfb.c | 6 +- hw/display/xlnx_dp.c | 10 +-- hw/vfio/display.c | 32 +++---- ui/console-vc.c | 12 +-- ui/console.c | 140 +++++++++++++++---------------- ui/curses.c | 8 +- ui/dbus-console.c | 4 +- ui/dbus-listener.c | 10 +-- ui/egl-headless.c | 4 +- ui/gtk-egl.c | 6 +- ui/gtk-gl-area.c | 6 +- ui/gtk.c | 18 ++-- ui/sdl2-2d.c | 2 +- ui/sdl2-gl.c | 2 +- ui/sdl2.c | 6 +- ui/spice-display.c | 16 ++-- ui/vnc.c | 22 ++--- hw/display/apple-gfx.m | 16 ++-- ui/cocoa.m | 10 +-- 57 files changed, 379 insertions(+), 389 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 69ac7b01b33..cfa940d4c66 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -294,49 +294,49 @@ DisplayState *init_displaystate(void); void qemu_console_register_listener(QemuConsole *con, DisplayChangeListener *dcl, const DisplayChangeListenerOps *ops); -void update_displaychangelistener(DisplayChangeListener *dcl, - uint64_t interval); +void qemu_console_listener_set_refresh(DisplayChangeListener *dcl, + uint64_t interval); void qemu_console_unregister_listener(DisplayChangeListener *dcl); =20 -bool dpy_ui_info_supported(const QemuConsole *con); -const QemuUIInfo *dpy_get_ui_info(const QemuConsole *con); -int dpy_set_ui_info(QemuConsole *con, QemuUIInfo *info, bool delay); - -void dpy_gfx_update(QemuConsole *con, int x, int y, int w, int h); -void dpy_gfx_update_full(QemuConsole *con); -void dpy_gfx_replace_surface(QemuConsole *con, - DisplaySurface *surface); -void dpy_text_cursor(QemuConsole *con, int x, int y); -void dpy_text_update(QemuConsole *con, int x, int y, int w, int h); -void dpy_text_resize(QemuConsole *con, int w, int h); -void dpy_mouse_set(QemuConsole *con, int x, int y, bool on); -void dpy_cursor_define(QemuConsole *con, QEMUCursor *cursor); -bool dpy_gfx_check_format(QemuConsole *con, - pixman_format_code_t format); - -void dpy_gl_scanout_disable(QemuConsole *con); -void dpy_gl_scanout_texture(QemuConsole *con, - uint32_t backing_id, bool backing_y_0_top, - uint32_t backing_width, uint32_t backing_heigh= t, - uint32_t x, uint32_t y, uint32_t w, uint32_t h, - void *d3d_tex2d); -void dpy_gl_scanout_dmabuf(QemuConsole *con, - QemuDmaBuf *dmabuf); -void dpy_gl_cursor_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf, - bool have_hot, uint32_t hot_x, uint32_t hot_y); -void dpy_gl_cursor_position(QemuConsole *con, - uint32_t pos_x, uint32_t pos_y); -void dpy_gl_release_dmabuf(QemuConsole *con, - QemuDmaBuf *dmabuf); -void dpy_gl_update(QemuConsole *con, - uint32_t x, uint32_t y, uint32_t w, uint32_t h); - -QEMUGLContext dpy_gl_ctx_create(QemuConsole *con, - QEMUGLParams *params); -void dpy_gl_ctx_destroy(QemuConsole *con, QEMUGLContext ctx); -int dpy_gl_ctx_make_current(QemuConsole *con, QEMUGLContext ctx); - -bool console_has_gl(QemuConsole *con); +bool qemu_console_ui_info_supported(const QemuConsole *con); +const QemuUIInfo *qemu_console_get_ui_info(const QemuConsole *con); +int qemu_console_set_ui_info(QemuConsole *con, QemuUIInfo *info, bool dela= y); + +void qemu_console_update(QemuConsole *con, int x, int y, int w, int h); +void qemu_console_update_full(QemuConsole *con); +void qemu_console_set_surface(QemuConsole *con, + DisplaySurface *surface); +void qemu_console_text_set_cursor(QemuConsole *con, int x, int y); +void qemu_console_text_update(QemuConsole *con, int x, int y, int w, int h= ); +void qemu_console_text_resize(QemuConsole *con, int w, int h); +void qemu_console_set_mouse(QemuConsole *con, int x, int y, bool on); +void qemu_console_set_cursor(QemuConsole *con, QEMUCursor *cursor); +bool qemu_console_check_format(QemuConsole *con, + pixman_format_code_t format); + +void qemu_console_gl_scanout_disable(QemuConsole *con); +void qemu_console_gl_scanout_texture(QemuConsole *con, + uint32_t backing_id, bool backing_y_0= _top, + uint32_t backing_width, uint32_t back= ing_height, + uint32_t x, uint32_t y, uint32_t w, u= int32_t h, + void *d3d_tex2d); +void qemu_console_gl_scanout_dmabuf(QemuConsole *con, + QemuDmaBuf *dmabuf); +void qemu_console_gl_cursor_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf, + bool have_hot, uint32_t hot_x, uint32_t= hot_y); +void qemu_console_gl_cursor_position(QemuConsole *con, + uint32_t pos_x, uint32_t pos_y); +void qemu_console_gl_release_dmabuf(QemuConsole *con, + QemuDmaBuf *dmabuf); +void qemu_console_gl_update(QemuConsole *con, + uint32_t x, uint32_t y, uint32_t w, uint32_t h= ); + +QEMUGLContext qemu_console_gl_ctx_create(QemuConsole *con, + QEMUGLParams *params); +void qemu_console_gl_ctx_destroy(QemuConsole *con, QEMUGLContext ctx); +int qemu_console_gl_ctx_make_current(QemuConsole *con, QEMUGLContext ctx); + +bool qemu_console_has_gl(QemuConsole *con); =20 enum { GRAPHIC_FLAGS_NONE =3D 0, @@ -361,19 +361,19 @@ typedef struct GraphicHwOps { void (*gl_block)(void *opaque, bool block); } GraphicHwOps; =20 -QemuConsole *graphic_console_init(DeviceState *dev, uint32_t head, - const GraphicHwOps *ops, - void *opaque); -void graphic_console_set_hwops(QemuConsole *con, - const GraphicHwOps *hw_ops, - void *opaque); -void graphic_console_close(QemuConsole *con); - -void graphic_hw_update(QemuConsole *con); -void graphic_hw_update_done(QemuConsole *con); -void graphic_hw_invalidate(QemuConsole *con); -void graphic_hw_text_update(QemuConsole *con, uint32_t *chardata); -void graphic_hw_gl_block(QemuConsole *con, bool block); +QemuConsole *qemu_graphic_console_create(DeviceState *dev, uint32_t head, + const GraphicHwOps *ops, + void *opaque); +void qemu_graphic_console_set_hwops(QemuConsole *con, + const GraphicHwOps *hw_ops, + void *opaque); +void qemu_graphic_console_close(QemuConsole *con); + +void qemu_console_hw_update(QemuConsole *con); +void qemu_console_hw_update_done(QemuConsole *con); +void qemu_console_hw_invalidate(QemuConsole *con); +void qemu_console_hw_text_update(QemuConsole *con, uint32_t *chardata); +void qemu_console_hw_gl_block(QemuConsole *con, bool block); =20 void qemu_console_early_init(void); =20 diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c index ba88ed756e2..83676eb7fea 100644 --- a/hw/arm/musicpal.c +++ b/hw/arm/musicpal.c @@ -170,7 +170,7 @@ static bool lcd_refresh(void *opaque) } } =20 - dpy_gfx_update(s->con, 0, 0, 128*3, 64*3); + qemu_console_update(s->con, 0, 0, 128*3, 64*3); return true; } =20 @@ -253,7 +253,7 @@ static const GraphicHwOps musicpal_gfx_ops =3D { static void musicpal_lcd_realize(DeviceState *dev, Error **errp) { musicpal_lcd_state *s =3D MUSICPAL_LCD(dev); - s->con =3D graphic_console_init(dev, 0, &musicpal_gfx_ops, s); + s->con =3D qemu_graphic_console_create(dev, 0, &musicpal_gfx_ops, s); qemu_console_resize(s->con, 128 * 3, 64 * 3); } =20 diff --git a/hw/display/artist.c b/hw/display/artist.c index a07508378c7..288d466ec64 100644 --- a/hw/display/artist.c +++ b/hw/display/artist.c @@ -1324,7 +1324,7 @@ static bool artist_update_display(void *opaque) artist_draw_cursor(s); =20 if (first >=3D 0) { - dpy_gfx_update(s->con, 0, first, s->width, last - first + 1); + qemu_console_update(s->con, 0, first, s->width, last - first + 1); } =20 return true; @@ -1424,7 +1424,7 @@ static void artist_realizefn(DeviceState *dev, Error = **errp) s->misc_video |=3D 0x0A000000; s->misc_ctrl |=3D 0x00800000; =20 - s->con =3D graphic_console_init(dev, 0, &artist_ops, s); + s->con =3D qemu_graphic_console_create(dev, 0, &artist_ops, s); qemu_console_resize(s->con, s->width, s->height); } =20 diff --git a/hw/display/ati.c b/hw/display/ati.c index 3a7d45a8820..d77589df67a 100644 --- a/hw/display/ati.c +++ b/hw/display/ati.c @@ -161,7 +161,7 @@ static void ati_cursor_define(ATIVGAState *s) } cursor_set_mono(s->cursor, s->regs.cur_color1, s->regs.cur_color0, (uint8_t *)&data[64], 1, (uint8_t *)&data[0]); - dpy_cursor_define(s->vga.con, s->cursor); + qemu_console_set_cursor(s->vga.con, s->cursor); } =20 /* Alternatively support guest rendered hardware cursor */ @@ -626,9 +626,9 @@ static void ati_mm_write(void *opaque, hwaddr addr, if (s->regs.crtc_gen_cntl & CRTC2_CUR_EN) { ati_cursor_define(s); } - dpy_mouse_set(s->vga.con, s->regs.cur_hv_pos >> 16, - s->regs.cur_hv_pos & 0xffff, - (s->regs.crtc_gen_cntl & CRTC2_CUR_EN) !=3D = 0); + qemu_console_set_mouse(s->vga.con, s->regs.cur_hv_pos >> 1= 6, + s->regs.cur_hv_pos & 0xffff, + (s->regs.crtc_gen_cntl & CRTC2_CUR_= EN) !=3D 0); } } if ((val & (CRTC2_EXT_DISP_EN | CRTC2_EN)) !=3D @@ -780,8 +780,8 @@ static void ati_mm_write(void *opaque, hwaddr addr, } if (!s->cursor_guest_mode && (s->regs.crtc_gen_cntl & CRTC2_CUR_EN) && !(t & BIT(31))) { - dpy_mouse_set(s->vga.con, s->regs.cur_hv_pos >> 16, - s->regs.cur_hv_pos & 0xffff, true); + qemu_console_set_mouse(s->vga.con, s->regs.cur_hv_pos >> 16, + s->regs.cur_hv_pos & 0xffff, true); } break; } @@ -1094,7 +1094,7 @@ static void ati_vga_realize(PCIDevice *dev, Error **e= rrp) } vga_init(vga, OBJECT(s), pci_address_space(dev), pci_address_space_io(dev), true); - vga->con =3D graphic_console_init(DEVICE(s), 0, s->vga.hw_ops, vga); + vga->con =3D qemu_graphic_console_create(DEVICE(s), 0, s->vga.hw_ops, = vga); if (s->cursor_guest_mode) { vga->cursor_invalidate =3D ati_cursor_invalidate; vga->cursor_draw_line =3D ati_cursor_draw_line; @@ -1167,7 +1167,7 @@ static void ati_vga_exit(PCIDevice *dev) ATIVGAState *s =3D ATI_VGA(dev); =20 timer_del(&s->vblank_timer); - graphic_console_close(s->vga.con); + qemu_graphic_console_close(s->vga.con); } =20 static const Property ati_vga_properties[] =3D { diff --git a/hw/display/bcm2835_fb.c b/hw/display/bcm2835_fb.c index 83c4c03c7ca..bd58f625fcd 100644 --- a/hw/display/bcm2835_fb.c +++ b/hw/display/bcm2835_fb.c @@ -207,8 +207,7 @@ static bool fb_update_display(void *opaque) draw_line_src16, s, &first, &last); =20 if (first >=3D 0) { - dpy_gfx_update(s->con, 0, first, s->config.xres, - last - first + 1); + qemu_console_update(s->con, 0, first, s->config.xres, last - first= + 1); } =20 s->invalidate =3D false; @@ -427,7 +426,7 @@ static void bcm2835_fb_realize(DeviceState *dev, Error = **errp) =20 bcm2835_fb_reset(dev); =20 - s->con =3D graphic_console_init(dev, 0, &vgafb_ops, s); + s->con =3D qemu_graphic_console_create(dev, 0, &vgafb_ops, s); qemu_console_resize(s->con, s->config.xres, s->config.yres); } =20 diff --git a/hw/display/bochs-display.c b/hw/display/bochs-display.c index 8ef9b76cf85..64e669429c4 100644 --- a/hw/display/bochs-display.c +++ b/hw/display/bochs-display.c @@ -224,12 +224,12 @@ static bool bochs_display_update(void *opaque) mode.format, mode.stride, ptr + mode.offset); - dpy_gfx_replace_surface(s->con, ds); + qemu_console_set_surface(s->con, ds); full_update =3D true; } =20 if (full_update) { - dpy_gfx_update_full(s->con); + qemu_console_update_full(s->con); } else { snap =3D memory_region_snapshot_and_clear_dirty(&s->vram, mode.offset, mode.si= ze, @@ -243,14 +243,12 @@ static bool bochs_display_update(void *opaque) ys =3D y; } if (!dirty && ys >=3D 0) { - dpy_gfx_update(s->con, 0, ys, - mode.width, y - ys); + qemu_console_update(s->con, 0, ys, mode.width, y - ys); ys =3D -1; } } if (ys >=3D 0) { - dpy_gfx_update(s->con, 0, ys, - mode.width, y - ys); + qemu_console_update(s->con, 0, ys, mode.width, y - ys); } =20 g_free(snap); @@ -279,7 +277,7 @@ static void bochs_display_realize(PCIDevice *dev, Error= **errp) } s->vgamem =3D pow2ceil(s->vgamem); =20 - s->con =3D graphic_console_init(DEVICE(dev), 0, &bochs_display_gfx_ops= , s); + s->con =3D qemu_graphic_console_create(DEVICE(dev), 0, &bochs_display_= gfx_ops, s); =20 memory_region_init_ram(&s->vram, obj, "bochs-display-vram", s->vgamem, &error_fatal); @@ -344,7 +342,7 @@ static void bochs_display_exit(PCIDevice *dev) { BochsDisplayState *s =3D BOCHS_DISPLAY(dev); =20 - graphic_console_close(s->con); + qemu_graphic_console_close(s->con); } =20 static const Property bochs_display_properties[] =3D { diff --git a/hw/display/cg3.c b/hw/display/cg3.c index 963bb3427a6..f9dda1549dd 100644 --- a/hw/display/cg3.c +++ b/hw/display/cg3.c @@ -137,7 +137,7 @@ static bool cg3_update_display(void *opaque) } } else { if (y_start >=3D 0) { - dpy_gfx_update(s->con, 0, y_start, width, y - y_start); + qemu_console_update(s->con, 0, y_start, width, y - y_start= ); y_start =3D -1; } pix +=3D width; @@ -146,7 +146,7 @@ static bool cg3_update_display(void *opaque) } s->full_update =3D 0; if (y_start >=3D 0) { - dpy_gfx_update(s->con, 0, y_start, width, y - y_start); + qemu_console_update(s->con, 0, y_start, width, y - y_start); } /* vsync interrupt? */ if (s->regs[0] & CG3_CR_ENABLE_INTS) { @@ -311,7 +311,7 @@ static void cg3_realizefn(DeviceState *dev, Error **err= p) =20 sysbus_init_irq(sbd, &s->irq); =20 - s->con =3D graphic_console_init(dev, 0, &cg3_ops, s); + s->con =3D qemu_graphic_console_create(dev, 0, &cg3_ops, s); qemu_console_resize(s->con, s->width, s->height); } =20 diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c index 48be3c8a932..0a8c74e1374 100644 --- a/hw/display/cirrus_vga.c +++ b/hw/display/cirrus_vga.c @@ -779,9 +779,9 @@ static int cirrus_do_copy(CirrusVGAState *s, int dst, i= nt src, int w, int h) s->cirrus_blt_width, s->cirrus_blt_height); =20 if (notify) { - dpy_gfx_update(s->vga.con, dx, dy, - s->cirrus_blt_width / depth, - s->cirrus_blt_height); + qemu_console_update(s->vga.con, dx, dy, + s->cirrus_blt_width / depth, + s->cirrus_blt_height); } =20 /* we don't have to notify the display that this portion has @@ -2964,7 +2964,7 @@ static void pci_cirrus_vga_realize(PCIDevice *dev, Er= ror **errp) } cirrus_init_common(s, OBJECT(dev), device_id, 1, pci_address_space(dev= ), pci_address_space_io(dev)); - s->vga.con =3D graphic_console_init(DEVICE(dev), 0, s->vga.hw_ops, &s-= >vga); + s->vga.con =3D qemu_graphic_console_create(DEVICE(dev), 0, s->vga.hw_o= ps, &s->vga); =20 /* setup PCI */ memory_region_init(&s->pci_bar, OBJECT(dev), "cirrus-pci-bar0", 0x2000= 000); diff --git a/hw/display/cirrus_vga_isa.c b/hw/display/cirrus_vga_isa.c index 76034a88605..b8052d1d8ed 100644 --- a/hw/display/cirrus_vga_isa.c +++ b/hw/display/cirrus_vga_isa.c @@ -62,7 +62,7 @@ static void isa_cirrus_vga_realizefn(DeviceState *dev, Er= ror **errp) cirrus_init_common(&d->cirrus_vga, OBJECT(dev), CIRRUS_ID_CLGD5430, 0, isa_address_space(isadev), isa_address_space_io(isadev)); - s->con =3D graphic_console_init(dev, 0, s->hw_ops, s); + s->con =3D qemu_graphic_console_create(dev, 0, s->hw_ops, s); rom_add_vga(VGABIOS_CIRRUS_FILENAME); /* XXX ISA-LFB support */ /* FIXME not qdev yet */ diff --git a/hw/display/dm163.c b/hw/display/dm163.c index 9ea62cb4f76..afade0b98c3 100644 --- a/hw/display/dm163.c +++ b/hw/display/dm163.c @@ -277,8 +277,8 @@ static uint32_t *update_display_of_row(DM163State *s, u= int32_t *dest, } } =20 - dpy_gfx_update(s->console, 0, LED_SQUARE_SIZE * row, - RGB_MATRIX_NUM_COLS * LED_SQUARE_SIZE, LED_SQUARE_SIZE= ); + qemu_console_update(s->console, 0, LED_SQUARE_SIZE * row, + RGB_MATRIX_NUM_COLS * LED_SQUARE_SIZE, LED_SQUARE_= SIZE); s->redraw &=3D ~(1 << row); trace_dm163_redraw(s->redraw); =20 @@ -322,7 +322,7 @@ static void dm163_realize(DeviceState *dev, Error **err= p) qdev_init_gpio_in(dev, dm163_en_b_gpio_handler, 1); qdev_init_gpio_out_named(dev, &s->sout, "sout", 1); =20 - s->console =3D graphic_console_init(dev, 0, &dm163_ops, s); + s->console =3D qemu_graphic_console_create(dev, 0, &dm163_ops, s); qemu_console_resize(s->console, RGB_MATRIX_NUM_COLS * LED_SQUARE_SIZE, RGB_MATRIX_NUM_ROWS * LED_SQUARE_SIZE); } diff --git a/hw/display/exynos4210_fimd.c b/hw/display/exynos4210_fimd.c index a91f04aaf79..5133623ee2e 100644 --- a/hw/display/exynos4210_fimd.c +++ b/hw/display/exynos4210_fimd.c @@ -1340,7 +1340,7 @@ static bool exynos4210_fimd_update(void *opaque) fimd_copy_line_toqemu(global_width, s->ifb + global_width * li= ne * RGBA_SIZE, d + global_width * line * bpp); } - dpy_gfx_update_full(s->console); + qemu_console_update_full(s->console); } s->invalidate =3D false; s->vidintcon[1] |=3D FIMD_VIDINT_INTFRMPEND; @@ -1964,7 +1964,7 @@ static void exynos4210_fimd_realize(DeviceState *dev,= Error **errp) return; } =20 - s->console =3D graphic_console_init(dev, 0, &exynos4210_fimd_ops, s); + s->console =3D qemu_graphic_console_create(dev, 0, &exynos4210_fimd_op= s, s); } =20 static void exynos4210_fimd_class_init(ObjectClass *klass, const void *dat= a) diff --git a/hw/display/g364fb.c b/hw/display/g364fb.c index bd15f6f0acc..af54f1f9005 100644 --- a/hw/display/g364fb.c +++ b/hw/display/g364fb.c @@ -191,8 +191,8 @@ static void g364fb_draw_graphic8(G364State *s) } else { int dy; if (xmax || ymax) { - dpy_gfx_update(s->con, xmin, ymin, - xmax - xmin + 1, ymax - ymin + 1); + qemu_console_update(s->con, xmin, ymin, + xmax - xmin + 1, ymax - ymin + 1); xmin =3D s->width; xmax =3D 0; ymin =3D s->height; @@ -211,7 +211,7 @@ static void g364fb_draw_graphic8(G364State *s) =20 done: if (xmax || ymax) { - dpy_gfx_update(s->con, xmin, ymin, xmax - xmin + 1, ymax - ymin + = 1); + qemu_console_update(s->con, xmin, ymin, xmax - xmin + 1, ymax - ym= in + 1); } g_free(snap); } @@ -234,7 +234,7 @@ static void g364fb_draw_blank(G364State *s) d +=3D surface_stride(surface); } =20 - dpy_gfx_update_full(s->con); + qemu_console_update_full(s->con); s->blanked =3D 1; } =20 @@ -478,7 +478,7 @@ static const GraphicHwOps g364fb_ops =3D { =20 static void g364fb_init(DeviceState *dev, G364State *s) { - s->con =3D graphic_console_init(dev, 0, &g364fb_ops, s); + s->con =3D qemu_graphic_console_create(dev, 0, &g364fb_ops, s); =20 memory_region_init_io(&s->mem_ctrl, OBJECT(dev), &g364fb_ctrl_ops, s, "ctrl", 0x180000); diff --git a/hw/display/imx6ul_lcdif.c b/hw/display/imx6ul_lcdif.c index afcd0805ca4..7b5be2b5a75 100644 --- a/hw/display/imx6ul_lcdif.c +++ b/hw/display/imx6ul_lcdif.c @@ -203,7 +203,7 @@ static bool imx6ul_lcdif_update_display(void *opaque) src_width, surface_stride(surface), 0, s->invalidate, fn, s, &first, &last); if (first >=3D 0) { - dpy_gfx_update(s->con, 0, first, width, last - first + 1); + qemu_console_update(s->con, 0, first, width, last - first + 1); } =20 s->invalidate =3D false; @@ -301,7 +301,7 @@ static void imx6ul_lcdif_write(void *opaque, hwaddr off= set, if (!FIELD_EX32(oldv, CTRL, RUN) && FIELD_EX32(s->regs[idx], CTRL, RUN)) { s->invalidate =3D true; - graphic_hw_invalidate(s->con); + qemu_console_hw_invalidate(s->con); imx6ul_lcdif_maybe_schedule_frame(s); break; } @@ -318,17 +318,17 @@ static void imx6ul_lcdif_write(void *opaque, hwaddr o= ffset, break; case A_V4_TRANSFER_COUNT: s->invalidate =3D true; - graphic_hw_invalidate(s->con); + qemu_console_hw_invalidate(s->con); break; case A_V4_CUR_BUF: s->invalidate =3D true; - graphic_hw_invalidate(s->con); + qemu_console_hw_invalidate(s->con); break; case A_V4_NEXT_BUF: s->regs[IMX6UL_LCDIF_REG_V4_CUR_BUF] =3D s->regs[idx]; imx6ul_lcdif_frame_done(s); s->invalidate =3D true; - graphic_hw_invalidate(s->con); + qemu_console_hw_invalidate(s->con); imx6ul_lcdif_maybe_schedule_frame(s); return; case A_AS_NEXT_BUF: @@ -411,7 +411,7 @@ static void imx6ul_lcdif_realize(DeviceState *dev, Erro= r **errp) TYPE_IMX6UL_LCDIF, LCDIF_MMIO_SIZE); sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem); sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq); - s->con =3D graphic_console_init(dev, 0, &imx6ul_lcdif_graphic_ops, s); + s->con =3D qemu_graphic_console_create(dev, 0, &imx6ul_lcdif_graphic_o= ps, s); } =20 static void imx6ul_lcdif_unrealize(DeviceState *dev) @@ -423,7 +423,7 @@ static void imx6ul_lcdif_unrealize(DeviceState *dev) s->frame_timer =3D NULL; =20 if (s->con) { - graphic_console_close(s->con); + qemu_graphic_console_close(s->con); s->con =3D NULL; } } diff --git a/hw/display/jazz_led.c b/hw/display/jazz_led.c index ee9758a94b5..84fe1058406 100644 --- a/hw/display/jazz_led.c +++ b/hw/display/jazz_led.c @@ -217,7 +217,7 @@ static bool jazz_led_update_display(void *opaque) } =20 s->state =3D REDRAW_NONE; - dpy_gfx_update_full(s->con); + qemu_console_update_full(s->con); =20 return true; } @@ -233,7 +233,7 @@ static void jazz_led_text_update(void *opaque, uint32_t= *chardata) LedState *s =3D opaque; char buf[3]; =20 - dpy_text_cursor(s->con, -1, -1); + qemu_console_text_set_cursor(s->con, -1, -1); qemu_console_resize(s->con, 2, 1); =20 /* TODO: draw the segments */ @@ -243,7 +243,7 @@ static void jazz_led_text_update(void *opaque, uint32_t= *chardata) *chardata++ =3D ATTR2CHTYPE(buf[1], QEMU_COLOR_BLUE, QEMU_COLOR_BLACK, 1); =20 - dpy_text_update(s->con, 0, 0, 2, 1); + qemu_console_text_update(s->con, 0, 0, 2, 1); } =20 static int jazz_led_post_load(void *opaque, int version_id) @@ -284,7 +284,7 @@ static void jazz_led_realize(DeviceState *dev, Error **= errp) { LedState *s =3D JAZZ_LED(dev); =20 - s->con =3D graphic_console_init(dev, 0, &jazz_led_ops, s); + s->con =3D qemu_graphic_console_create(dev, 0, &jazz_led_ops, s); } =20 static void jazz_led_reset(DeviceState *d) diff --git a/hw/display/macfb.c b/hw/display/macfb.c index 848c3c282bd..f40a7ed9f52 100644 --- a/hw/display/macfb.c +++ b/hw/display/macfb.c @@ -320,14 +320,14 @@ static void macfb_draw_graphic(MacfbState *s) } } else { if (ymin >=3D 0) { - dpy_gfx_update(s->con, 0, ymin, s->width, y - ymin); + qemu_console_update(s->con, 0, ymin, s->width, y - ymin); ymin =3D -1; } } } =20 if (ymin >=3D 0) { - dpy_gfx_update(s->con, 0, ymin, s->width, y - ymin); + qemu_console_update(s->con, 0, ymin, s->width, y - ymin); } =20 g_free(snap); @@ -671,7 +671,7 @@ static bool macfb_common_realize(DeviceState *dev, Macf= bState *s, Error **errp) s->regs[DAFB_MODE_CTRL1 >> 2] =3D s->mode->mode_ctrl1; s->regs[DAFB_MODE_CTRL2 >> 2] =3D s->mode->mode_ctrl2; =20 - s->con =3D graphic_console_init(dev, 0, &macfb_ops, s); + s->con =3D qemu_graphic_console_create(dev, 0, &macfb_ops, s); surface =3D qemu_console_surface(s->con); =20 if (surface_bits_per_pixel(surface) !=3D 32) { diff --git a/hw/display/next-fb.c b/hw/display/next-fb.c index e758b223ef7..fa2e0d0da80 100644 --- a/hw/display/next-fb.c +++ b/hw/display/next-fb.c @@ -89,7 +89,7 @@ static bool nextfb_update(void *opaque) src_width, dest_width, 0, 1, nextfb_draw_li= ne, s, &first, &last); =20 - dpy_gfx_update(s->con, 0, 0, s->cols, s->rows); + qemu_console_update(s->con, 0, 0, s->cols, s->rows); =20 return true; } @@ -117,7 +117,7 @@ static void nextfb_realize(DeviceState *dev, Error **er= rp) s->cols =3D 1120; s->rows =3D 832; =20 - s->con =3D graphic_console_init(dev, 0, &nextfb_ops, s); + s->con =3D qemu_graphic_console_create(dev, 0, &nextfb_ops, s); qemu_console_resize(s->con, s->cols, s->rows); } =20 diff --git a/hw/display/omap_lcdc.c b/hw/display/omap_lcdc.c index 1e8385ebffb..2a8d5ffdd57 100644 --- a/hw/display/omap_lcdc.c +++ b/hw/display/omap_lcdc.c @@ -320,7 +320,7 @@ static bool omap_update_display(void *opaque) &first, &last); =20 if (first >=3D 0) { - dpy_gfx_update(omap_lcd->con, 0, first, width, last - first + 1); + qemu_console_update(omap_lcd->con, 0, first, width, last - first += 1); } omap_lcd->invalidate =3D 0; =20 @@ -504,7 +504,7 @@ struct omap_lcd_panel_s *omap_lcdc_init(MemoryRegion *s= ysmem, memory_region_init_io(&s->iomem, NULL, &omap_lcdc_ops, s, "omap.lcdc",= 0x100); memory_region_add_subregion(sysmem, base, &s->iomem); =20 - s->con =3D graphic_console_init(NULL, 0, &omap_ops, s); + s->con =3D qemu_graphic_console_create(NULL, 0, &omap_ops, s); =20 return s; } diff --git a/hw/display/pl110.c b/hw/display/pl110.c index e134ac28eb6..4a93cf4cda9 100644 --- a/hw/display/pl110.c +++ b/hw/display/pl110.c @@ -303,7 +303,7 @@ static bool pl110_update_display(void *opaque) &first, &last); =20 if (first >=3D 0) { - dpy_gfx_update(s->con, 0, first, s->cols, last - first + 1); + qemu_console_update(s->con, 0, first, s->cols, last - first + 1); } s->invalidate =3D 0; return true; @@ -557,7 +557,7 @@ static void pl110_realize(DeviceState *dev, Error **err= p) s->vblank_timer =3D timer_new_ns(QEMU_CLOCK_VIRTUAL, pl110_vblank_interrupt, s); qdev_init_gpio_in(dev, pl110_mux_ctrl_set, 1); - s->con =3D graphic_console_init(dev, 0, &pl110_gfx_ops, s); + s->con =3D qemu_graphic_console_create(dev, 0, &pl110_gfx_ops, s); } =20 static void pl110_init(Object *obj) diff --git a/hw/display/qxl-render.c b/hw/display/qxl-render.c index 5b4f8842011..7b692d5a854 100644 --- a/hw/display/qxl-render.c +++ b/hw/display/qxl-render.c @@ -135,7 +135,7 @@ static void qxl_render_update_area_unlocked(PCIQXLDevic= e *qxl) (width, height); } - dpy_gfx_replace_surface(vga->con, surface); + qemu_console_set_surface(vga->con, surface); } =20 if (!qxl->guest_primary.data) { @@ -154,16 +154,16 @@ static void qxl_render_update_area_unlocked(PCIQXLDev= ice *qxl) continue; } qxl_blit(qxl, qxl->dirty+i); - dpy_gfx_update(vga->con, - qxl->dirty[i].left, qxl->dirty[i].top, - qxl->dirty[i].right - qxl->dirty[i].left, - qxl->dirty[i].bottom - qxl->dirty[i].top); + qemu_console_update(vga->con, + qxl->dirty[i].left, qxl->dirty[i].top, + qxl->dirty[i].right - qxl->dirty[i].left, + qxl->dirty[i].bottom - qxl->dirty[i].top); } qxl->num_dirty_rects =3D 0; =20 end: if (qxl->render_update_cookie_num =3D=3D 0) { - graphic_hw_update_done(qxl->ssd.dcl.con); + qemu_console_hw_update_done(qxl->ssd.dcl.con); } } =20 diff --git a/hw/display/qxl.c b/hw/display/qxl.c index 4244ebe51d2..74258afa582 100644 --- a/hw/display/qxl.c +++ b/hw/display/qxl.c @@ -1153,13 +1153,13 @@ static void qxl_enter_vga_mode(PCIQXLDevice *d) } trace_qxl_enter_vga_mode(d->id); spice_qxl_driver_unload(&d->ssd.qxl); - graphic_console_set_hwops(d->ssd.dcl.con, d->vga.hw_ops, &d->vga); - update_displaychangelistener(&d->ssd.dcl, GUI_REFRESH_INTERVAL_DEFAULT= ); + qemu_graphic_console_set_hwops(d->ssd.dcl.con, d->vga.hw_ops, &d->vga); + qemu_console_listener_set_refresh(&d->ssd.dcl, GUI_REFRESH_INTERVAL_DE= FAULT); qemu_spice_create_host_primary(&d->ssd); d->mode =3D QXL_MODE_VGA; qemu_spice_display_switch(&d->ssd, d->ssd.ds); vga_dirty_log_start(&d->vga); - graphic_hw_update(d->vga.con); + qemu_console_hw_update(d->vga.con); } =20 static void qxl_exit_vga_mode(PCIQXLDevice *d) @@ -1168,8 +1168,8 @@ static void qxl_exit_vga_mode(PCIQXLDevice *d) return; } trace_qxl_exit_vga_mode(d->id); - graphic_console_set_hwops(d->ssd.dcl.con, &qxl_ops, d); - update_displaychangelistener(&d->ssd.dcl, GUI_REFRESH_INTERVAL_IDLE); + qemu_graphic_console_set_hwops(d->ssd.dcl.con, &qxl_ops, d); + qemu_console_listener_set_refresh(&d->ssd.dcl, GUI_REFRESH_INTERVAL_ID= LE); vga_dirty_log_stop(&d->vga); qxl_destroy_primary(d, QXL_SYNC); } @@ -2237,7 +2237,7 @@ static void qxl_realize_primary(PCIDevice *dev, Error= **errp) portio_list_add(&qxl->vga_port_list, pci_address_space_io(dev), 0x3b0); qxl->have_vga =3D true; =20 - vga->con =3D graphic_console_init(DEVICE(dev), 0, &qxl_ops, qxl); + vga->con =3D qemu_graphic_console_create(DEVICE(dev), 0, &qxl_ops, qxl= ); qxl->id =3D qemu_console_get_index(vga->con); /* =3D=3D channel_id */ if (qxl->id !=3D 0) { error_setg(errp, "primary qxl-vga device must be console 0 " @@ -2262,7 +2262,7 @@ static void qxl_realize_secondary(PCIDevice *dev, Err= or **errp) memory_region_init_ram(&qxl->vga.vram, OBJECT(dev), "qxl.vgavram", qxl->vga.vram_size, &error_fatal); qxl->vga.vram_ptr =3D memory_region_get_ram_ptr(&qxl->vga.vram); - qxl->vga.con =3D graphic_console_init(DEVICE(dev), 0, &qxl_ops, qxl); + qxl->vga.con =3D qemu_graphic_console_create(DEVICE(dev), 0, &qxl_ops,= qxl); qxl->ssd.dcl.con =3D qxl->vga.con; qxl->id =3D qemu_console_get_index(qxl->vga.con); /* =3D=3D channel_id= */ =20 diff --git a/hw/display/ramfb-standalone.c b/hw/display/ramfb-standalone.c index 27f0ba19f90..8e8ba37514a 100644 --- a/hw/display/ramfb-standalone.c +++ b/hw/display/ramfb-standalone.c @@ -41,7 +41,7 @@ static void ramfb_realizefn(DeviceState *dev, Error **err= p) { RAMFBStandaloneState *ramfb =3D RAMFB(dev); =20 - ramfb->con =3D graphic_console_init(dev, 0, &wrapper_ops, dev); + ramfb->con =3D qemu_graphic_console_create(dev, 0, &wrapper_ops, dev); ramfb->state =3D ramfb_setup(ramfb->use_legacy_x86_rom, errp); } =20 diff --git a/hw/display/ramfb.c b/hw/display/ramfb.c index 50c25706a52..7a88f934e11 100644 --- a/hw/display/ramfb.c +++ b/hw/display/ramfb.c @@ -111,12 +111,12 @@ void ramfb_display_update(QemuConsole *con, RAMFBStat= e *s) } =20 if (s->ds) { - dpy_gfx_replace_surface(con, s->ds); + qemu_console_set_surface(con, s->ds); s->ds =3D NULL; } =20 /* simple full screen update */ - dpy_gfx_update_full(con); + qemu_console_update_full(con); } =20 static int ramfb_post_load(void *opaque, int version_id) diff --git a/hw/display/sm501.c b/hw/display/sm501.c index a3993ceba29..af870048372 100644 --- a/hw/display/sm501.c +++ b/hw/display/sm501.c @@ -1822,7 +1822,7 @@ static bool sm501_update_display(void *opaque) } else { if (y_start >=3D 0) { /* flush to display */ - dpy_gfx_update(s->con, 0, y_start, width, y - y_start); + qemu_console_update(s->con, 0, y_start, width, y - y_start= ); y_start =3D -1; } } @@ -1831,7 +1831,7 @@ static bool sm501_update_display(void *opaque) =20 /* complete flush to display */ if (y_start >=3D 0) { - dpy_gfx_update(s->con, 0, y_start, width, y - y_start); + qemu_console_update(s->con, 0, y_start, width, y - y_start); } =20 return true; @@ -1936,7 +1936,7 @@ static void sm501_init(SM501State *s, DeviceState *de= v, &s->twoD_engine_region); =20 /* create qemu graphic console */ - s->con =3D graphic_console_init(dev, 0, &sm501_ops, s); + s->con =3D qemu_graphic_console_create(dev, 0, &sm501_ops, s); } =20 static const VMStateDescription vmstate_sm501_state =3D { diff --git a/hw/display/ssd0303.c b/hw/display/ssd0303.c index 229856cc427..4e3dede33f1 100644 --- a/hw/display/ssd0303.c +++ b/hw/display/ssd0303.c @@ -268,7 +268,7 @@ static bool ssd0303_update_display(void *opaque) } } s->redraw =3D 0; - dpy_gfx_update(s->con, 0, 0, 96 * MAGNIFY, 16 * MAGNIFY); + qemu_console_update(s->con, 0, 0, 96 * MAGNIFY, 16 * MAGNIFY); =20 return true; } @@ -309,7 +309,7 @@ static void ssd0303_realize(DeviceState *dev, Error **e= rrp) { ssd0303_state *s =3D SSD0303(dev); =20 - s->con =3D graphic_console_init(dev, 0, &ssd0303_ops, s); + s->con =3D qemu_graphic_console_create(dev, 0, &ssd0303_ops, s); qemu_console_resize(s->con, 96 * MAGNIFY, 16 * MAGNIFY); } =20 diff --git a/hw/display/ssd0323.c b/hw/display/ssd0323.c index 67db16086c8..9309d4d10c4 100644 --- a/hw/display/ssd0323.c +++ b/hw/display/ssd0323.c @@ -270,7 +270,8 @@ static bool ssd0323_update_display(void *opaque) } } s->redraw =3D 0; - dpy_gfx_update(s->con, 0, 0, 128 * MAGNIFY, 64 * MAGNIFY); + qemu_console_update(s->con, 0, 0, 128 * MAGNIFY, 64 * MAGNIFY); + return true; } =20 @@ -356,7 +357,7 @@ static void ssd0323_realize(SSIPeripheral *d, Error **e= rrp) =20 s->col_end =3D 63; s->row_end =3D 79; - s->con =3D graphic_console_init(dev, 0, &ssd0323_ops, s); + s->con =3D qemu_graphic_console_create(dev, 0, &ssd0323_ops, s); qemu_console_resize(s->con, 128 * MAGNIFY, 64 * MAGNIFY); =20 qdev_init_gpio_in(dev, ssd0323_cd, 1); diff --git a/hw/display/tcx.c b/hw/display/tcx.c index cedbf5c7acd..2c33a9c4a32 100644 --- a/hw/display/tcx.c +++ b/hw/display/tcx.c @@ -243,8 +243,7 @@ static bool tcx_update_display(void *opaque) } else { if (y_start >=3D 0) { /* flush to display */ - dpy_gfx_update(ts->con, 0, y_start, - ts->width, y - y_start); + qemu_console_update(ts->con, 0, y_start, ts->width, y - y_= start); y_start =3D -1; } } @@ -253,8 +252,7 @@ static bool tcx_update_display(void *opaque) } if (y_start >=3D 0) { /* flush to display */ - dpy_gfx_update(ts->con, 0, y_start, - ts->width, y - y_start); + qemu_console_update(ts->con, 0, y_start, ts->width, y - y_start); } g_free(snap); return true; @@ -297,8 +295,7 @@ static bool tcx24_update_display(void *opaque) } else { if (y_start >=3D 0) { /* flush to display */ - dpy_gfx_update(ts->con, 0, y_start, - ts->width, y - y_start); + qemu_console_update(ts->con, 0, y_start, ts->width, y - y_= start); y_start =3D -1; } } @@ -309,8 +306,7 @@ static bool tcx24_update_display(void *opaque) } if (y_start >=3D 0) { /* flush to display */ - dpy_gfx_update(ts->con, 0, y_start, - ts->width, y - y_start); + qemu_console_update(ts->con, 0, y_start, ts->width, y - y_start); } g_free(snap); return true; @@ -864,9 +860,9 @@ static void tcx_realize(DeviceState *dev, Error **errp) sysbus_init_irq(sbd, &s->irq); =20 if (s->depth =3D=3D 8) { - s->con =3D graphic_console_init(dev, 0, &tcx_ops, s); + s->con =3D qemu_graphic_console_create(dev, 0, &tcx_ops, s); } else { - s->con =3D graphic_console_init(dev, 0, &tcx24_ops, s); + s->con =3D qemu_graphic_console_create(dev, 0, &tcx24_ops, s); } s->thcmisc =3D 0; =20 diff --git a/hw/display/vga-isa.c b/hw/display/vga-isa.c index 5f55c884a1b..2cccb0ef12e 100644 --- a/hw/display/vga-isa.c +++ b/hw/display/vga-isa.c @@ -79,7 +79,7 @@ static void vga_isa_realizefn(DeviceState *dev, Error **e= rrp) 0x000a0000, vga_io_memory, 1); memory_region_set_coalescing(vga_io_memory); - s->con =3D graphic_console_init(dev, 0, s->hw_ops, s); + s->con =3D qemu_graphic_console_create(dev, 0, s->hw_ops, s); =20 memory_region_add_subregion(isa_address_space(isadev), VBE_DISPI_LFB_PHYSICAL_ADDRESS, diff --git a/hw/display/vga-mmio.c b/hw/display/vga-mmio.c index 1a9608d865f..3cd64951c09 100644 --- a/hw/display/vga-mmio.c +++ b/hw/display/vga-mmio.c @@ -108,7 +108,7 @@ static void vga_mmio_realizefn(DeviceState *dev, Error = **errp) } =20 sysbus_init_mmio(sbd, &s->vga.vram); - s->vga.con =3D graphic_console_init(dev, 0, s->vga.hw_ops, &s->vga); + s->vga.con =3D qemu_graphic_console_create(dev, 0, s->vga.hw_ops, &s->= vga); } =20 static const Property vga_mmio_properties[] =3D { diff --git a/hw/display/vga-pci.c b/hw/display/vga-pci.c index 4e68dd57a17..d089847bdae 100644 --- a/hw/display/vga-pci.c +++ b/hw/display/vga-pci.c @@ -247,7 +247,7 @@ static void pci_std_vga_realize(PCIDevice *dev, Error *= *errp) vga_init(s, OBJECT(dev), pci_address_space(dev), pci_address_space_io(= dev), true); =20 - s->con =3D graphic_console_init(DEVICE(dev), 0, s->hw_ops, s); + s->con =3D qemu_graphic_console_create(DEVICE(dev), 0, s->hw_ops, s); =20 /* XXX: VGA_RAM_SIZE must be a power of two */ pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->vram); @@ -282,7 +282,7 @@ static void pci_secondary_vga_realize(PCIDevice *dev, E= rror **errp) if (!vga_common_init(s, OBJECT(dev), errp)) { return; } - s->con =3D graphic_console_init(DEVICE(dev), 0, s->hw_ops, s); + s->con =3D qemu_graphic_console_create(DEVICE(dev), 0, s->hw_ops, s); =20 /* mmio bar */ memory_region_init_io(&d->mmio, OBJECT(dev), &unassigned_io_ops, NULL, @@ -306,7 +306,7 @@ static void pci_secondary_vga_exit(PCIDevice *dev) PCIVGAState *d =3D PCI_VGA(dev); VGACommonState *s =3D &d->vga; =20 - graphic_console_close(s->con); + qemu_graphic_console_close(s->con); memory_region_del_subregion(&d->mmio, &d->mrs[0]); memory_region_del_subregion(&d->mmio, &d->mrs[1]); if (d->flags & (1 << PCI_VGA_FLAG_ENABLE_QEXT)) { diff --git a/hw/display/vga.c b/hw/display/vga.c index 2f266f47a39..0ac4bf37310 100644 --- a/hw/display/vga.c +++ b/hw/display/vga.c @@ -1246,7 +1246,7 @@ static void vga_draw_text(VGACommonState *s, int full= _update) s->last_scr_height =3D height * cheight; qemu_console_resize(s->con, s->last_scr_width, s->last_scr_height); surface =3D qemu_console_surface(s->con); - dpy_text_resize(s->con, width, height); + qemu_console_text_resize(s->con, width, height); s->last_depth =3D 0; s->last_width =3D width; s->last_height =3D height; @@ -1365,8 +1365,8 @@ static void vga_draw_text(VGACommonState *s, int full= _update) ch_attr_ptr++; } if (cx_max !=3D -1) { - dpy_gfx_update(s->con, cx_min * cw, cy * cheight, - (cx_max - cx_min + 1) * cw, cheight); + qemu_console_update(s->con, cx_min * cw, cy * cheight, + (cx_max - cx_min + 1) * cw, cheight); } dest +=3D linesize * cheight; line1 =3D line + cheight; @@ -1610,7 +1610,7 @@ static void vga_draw_graphic(VGACommonState *s, int f= ull_update) */ format =3D qemu_default_pixman_format(depth, !byteswap); if (format) { - allocate_surface =3D !dpy_gfx_check_format(s->con, format) + allocate_surface =3D !qemu_console_check_format(s->con, format) || s->force_shadow || force_shadow; } else { allocate_surface =3D true; @@ -1647,7 +1647,7 @@ static void vga_draw_graphic(VGACommonState *s, int f= ull_update) surface =3D qemu_create_displaysurface_from(disp_width, height, format, s->params.line_offset, s->vram_ptr + (s->params.start_addr * 4)); - dpy_gfx_replace_surface(s->con, surface); + qemu_console_set_surface(s->con, surface); } else { qemu_console_resize(s->con, disp_width, height); surface =3D qemu_console_surface(s->con); @@ -1720,8 +1720,7 @@ static void vga_draw_graphic(VGACommonState *s, int f= ull_update) } else { if (y_start >=3D 0) { /* flush to display */ - dpy_gfx_update(s->con, 0, y_start, - disp_width, y - y_start); + qemu_console_update(s->con, 0, y_start, disp_width, y - y_= start); y_start =3D -1; } } @@ -1745,8 +1744,7 @@ static void vga_draw_graphic(VGACommonState *s, int f= ull_update) } if (y_start >=3D 0) { /* flush to display */ - dpy_gfx_update(s->con, 0, y_start, - disp_width, y - y_start); + qemu_console_update(s->con, 0, y_start, disp_width, y - y_start); } g_free(snap); memset(s->invalidated_y_table, 0, sizeof(s->invalidated_y_table)); @@ -1767,7 +1765,7 @@ static void vga_draw_blank(VGACommonState *s, int ful= l_update) /* unshare buffer, otherwise the blanking corrupts vga vram */ surface =3D qemu_create_displaysurface(s->last_scr_width, s->last_scr_height); - dpy_gfx_replace_surface(s->con, surface); + qemu_console_set_surface(s->con, surface); } =20 w =3D s->last_scr_width * surface_bytes_per_pixel(surface); @@ -1776,7 +1774,7 @@ static void vga_draw_blank(VGACommonState *s, int ful= l_update) memset(d, 0, w); d +=3D surface_stride(surface); } - dpy_gfx_update_full(s->con); + qemu_console_update_full(s->con); } =20 #define GMODE_TEXT 0 @@ -1967,7 +1965,7 @@ static void vga_update_text(void *opaque, uint32_t *c= hardata) s->last_scr_width =3D width * cw; s->last_scr_height =3D height * cheight; qemu_console_resize(s->con, s->last_scr_width, s->last_scr_hei= ght); - dpy_text_resize(s->con, width, height); + qemu_console_text_resize(s->con, width, height); s->last_depth =3D 0; s->last_width =3D width; s->last_height =3D height; @@ -1992,11 +1990,11 @@ static void vga_update_text(void *opaque, uint32_t = *chardata) s->cr[VGA_CRTC_CURSOR_END] !=3D s->cursor_end || full_update) { cursor_visible =3D !(s->cr[VGA_CRTC_CURSOR_START] & 0x20); if (cursor_visible && cursor_offset < size && cursor_offset >= =3D 0) - dpy_text_cursor(s->con, - TEXTMODE_X(cursor_offset), - TEXTMODE_Y(cursor_offset)); + qemu_console_text_set_cursor(s->con, + TEXTMODE_X(cursor_offset), + TEXTMODE_Y(cursor_offset)); else - dpy_text_cursor(s->con, -1, -1); + qemu_console_text_set_cursor(s->con, -1, -1); s->cursor_offset =3D cursor_offset; s->cursor_start =3D s->cr[VGA_CRTC_CURSOR_START]; s->cursor_end =3D s->cr[VGA_CRTC_CURSOR_END]; @@ -2009,7 +2007,7 @@ static void vga_update_text(void *opaque, uint32_t *c= hardata) for (i =3D 0; i < size; src ++, dst ++, i ++) *dst =3D VMEM2CHTYPE(le32_to_cpu(*src)); =20 - dpy_text_update(s->con, 0, 0, width, height); + qemu_console_text_update(s->con, 0, 0, width, height); } else { c_max =3D 0; =20 @@ -2032,7 +2030,7 @@ static void vga_update_text(void *opaque, uint32_t *c= hardata) =20 if (c_min <=3D c_max) { i =3D TEXTMODE_Y(c_min); - dpy_text_update(s->con, 0, i, width, TEXTMODE_Y(c_max) - i= + 1); + qemu_console_text_update(s->con, 0, i, width, TEXTMODE_Y(c= _max) - i + 1); } } =20 @@ -2057,8 +2055,8 @@ static void vga_update_text(void *opaque, uint32_t *c= hardata) /* Display a message */ s->last_width =3D 60; s->last_height =3D height =3D 3; - dpy_text_cursor(s->con, -1, -1); - dpy_text_resize(s->con, s->last_width, height); + qemu_console_text_set_cursor(s->con, -1, -1); + qemu_console_text_resize(s->con, s->last_width, height); =20 for (dst =3D chardata, i =3D 0; i < s->last_width * height; i ++) *dst++ =3D ' '; @@ -2070,7 +2068,7 @@ static void vga_update_text(void *opaque, uint32_t *c= hardata) *dst++ =3D ATTR2CHTYPE(msg_buffer[i], QEMU_COLOR_BLUE, QEMU_COLOR_BLACK, 1); =20 - dpy_text_update(s->con, 0, 0, s->last_width, height); + qemu_console_text_update(s->con, 0, 0, s->last_width, height); } =20 static uint64_t vga_mem_read(void *opaque, hwaddr addr, diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index 3f6fb7a8033..6e5e6540a46 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -142,11 +142,11 @@ vhost_user_gpu_handle_cursor(VhostUserGPU *g, VhostUs= erGpuMsg *msg) memcpy(s->current_cursor->data, up->data, 64 * 64 * sizeof(uint32_t)); =20 - dpy_cursor_define(s->con, s->current_cursor); + qemu_console_set_cursor(s->con, s->current_cursor); } =20 - dpy_mouse_set(s->con, pos->x, pos->y, - msg->request !=3D VHOST_USER_GPU_CURSOR_POS_HIDE); + qemu_console_set_mouse(s->con, pos->x, pos->y, + msg->request !=3D VHOST_USER_GPU_CURSOR_POS_HID= E); } =20 static void @@ -238,7 +238,7 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUse= rGpuMsg *msg) con =3D s->con; =20 if (m->width =3D=3D 0) { - dpy_gfx_replace_surface(con, NULL); + qemu_console_set_surface(con, NULL); } else { s->ds =3D qemu_create_displaysurface(m->width, m->height); /* replace surface on next update */ @@ -269,12 +269,12 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostU= serGpuMsg *msg) =20 if (dmabuf) { qemu_dmabuf_close(dmabuf); - dpy_gl_release_dmabuf(con, dmabuf); + qemu_console_gl_release_dmabuf(con, dmabuf); g_clear_pointer(&dmabuf, qemu_dmabuf_free); } =20 if (fd =3D=3D -1) { - dpy_gl_scanout_disable(con); + qemu_console_gl_scanout_disable(con); g->dmabuf[m->scanout_id] =3D NULL; break; } @@ -291,7 +291,7 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUse= rGpuMsg *msg) &fd, 1, false, m->fd_flags & VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP); =20 - dpy_gl_scanout_dmabuf(con, dmabuf); + qemu_console_gl_scanout_dmabuf(con, dmabuf); g->dmabuf[m->scanout_id] =3D dmabuf; break; } @@ -306,13 +306,13 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostU= serGpuMsg *msg) } =20 con =3D g->parent_obj.scanout[m->scanout_id].con; - if (!console_has_gl(con)) { + if (!qemu_console_has_gl(con)) { error_report("console doesn't support GL!"); vhost_user_gpu_unblock(g); break; } g->backend_blocked =3D true; - dpy_gl_update(con, m->x, m->y, m->width, m->height); + qemu_console_gl_update(con, m->x, m->y, m->width, m->height); break; } #ifdef CONFIG_PIXMAN @@ -337,9 +337,9 @@ vhost_user_gpu_handle_display(VhostUserGPU *g, VhostUse= rGpuMsg *msg) =20 pixman_image_unref(image); if (qemu_console_surface(con) !=3D s->ds) { - dpy_gfx_replace_surface(con, s->ds); + qemu_console_set_surface(con, s->ds); } else { - dpy_gfx_update(con, m->x, m->y, m->width, m->height); + qemu_console_update(con, m->x, m->y, m->width, m->height); } break; } diff --git a/hw/display/virtio-gpu-base.c b/hw/display/virtio-gpu-base.c index bdc24492850..a68b1848295 100644 --- a/hw/display/virtio-gpu-base.c +++ b/hw/display/virtio-gpu-base.c @@ -253,7 +253,7 @@ virtio_gpu_base_device_realize(DeviceState *qdev, g->hw_ops =3D &virtio_gpu_ops; for (i =3D 0; i < g->conf.max_outputs; i++) { g->scanout[i].con =3D - graphic_console_init(DEVICE(g), i, &virtio_gpu_ops, g); + qemu_graphic_console_create(DEVICE(g), i, &virtio_gpu_ops, g); } =20 return true; diff --git a/hw/display/virtio-gpu-rutabaga.c b/hw/display/virtio-gpu-rutab= aga.c index ebb6c783fb0..6ff12639012 100644 --- a/hw/display/virtio-gpu-rutabaga.c +++ b/hw/display/virtio-gpu-rutabaga.c @@ -282,7 +282,7 @@ rutabaga_cmd_resource_flush(VirtIOGPU *g, struct virtio= _gpu_ctrl_command *cmd) rf.resource_id, &transfer, &transfer_iovec); CHECK(!result, cmd); - dpy_gfx_update_full(scanout->con); + qemu_console_update_full(scanout->con); } =20 static void @@ -306,8 +306,8 @@ rutabaga_cmd_set_scanout(VirtIOGPU *g, struct virtio_gp= u_ctrl_command *cmd) scanout =3D &vb->scanout[ss.scanout_id]; =20 if (ss.resource_id =3D=3D 0) { - dpy_gfx_replace_surface(scanout->con, NULL); - dpy_gl_scanout_disable(scanout->con); + qemu_console_set_surface(scanout->con, NULL); + qemu_console_gl_scanout_disable(scanout->con); return; } =20 @@ -331,8 +331,8 @@ rutabaga_cmd_set_scanout(VirtIOGPU *g, struct virtio_gp= u_ctrl_command *cmd) =20 /* realloc the surface ptr */ scanout->ds =3D qemu_create_displaysurface_pixman(res->image); - dpy_gfx_replace_surface(scanout->con, NULL); - dpy_gfx_replace_surface(scanout->con, scanout->ds); + qemu_console_set_surface(scanout->con, NULL); + qemu_console_set_surface(scanout->con, scanout->ds); res->scanout_bitmask =3D ss.scanout_id; } =20 diff --git a/hw/display/virtio-gpu-udmabuf.c b/hw/display/virtio-gpu-udmabu= f.c index 74b6a7766af..d5ac1cfca0e 100644 --- a/hw/display/virtio-gpu-udmabuf.c +++ b/hw/display/virtio-gpu-udmabuf.c @@ -156,7 +156,7 @@ static void virtio_gpu_free_dmabuf(VirtIOGPU *g, VGPUDM= ABuf *dmabuf) struct virtio_gpu_scanout *scanout; =20 scanout =3D &g->parent_obj.scanout[dmabuf->scanout_id]; - dpy_gl_release_dmabuf(scanout->con, dmabuf->buf); + qemu_console_gl_release_dmabuf(scanout->con, dmabuf->buf); g_clear_pointer(&dmabuf->buf, qemu_dmabuf_free); QTAILQ_REMOVE(&g->dmabuf.bufs, dmabuf, next); g_free(dmabuf); @@ -232,7 +232,7 @@ int virtio_gpu_update_dmabuf(VirtIOGPU *g, height =3D qemu_dmabuf_get_height(new_primary->buf); g->dmabuf.primary[scanout_id] =3D new_primary; qemu_console_resize(scanout->con, width, height); - dpy_gl_scanout_dmabuf(scanout->con, new_primary->buf); + qemu_console_gl_scanout_dmabuf(scanout->con, new_primary->buf); =20 if (old_primary) { virtio_gpu_free_dmabuf(g, old_primary); diff --git a/hw/display/virtio-gpu-virgl.c b/hw/display/virtio-gpu-virgl.c index add85bd4e61..60c78af06a4 100644 --- a/hw/display/virtio-gpu-virgl.c +++ b/hw/display/virtio-gpu-virgl.c @@ -521,7 +521,7 @@ static void virtio_gpu_rect_update(VirtIOGPU *g, int id= x, int x, int y, return; } =20 - dpy_gl_update(g->parent_obj.scanout[idx].con, x, y, width, height); + qemu_console_gl_update(g->parent_obj.scanout[idx].con, x, y, width, he= ight); } =20 static void virgl_cmd_resource_flush(VirtIOGPU *g, @@ -584,16 +584,15 @@ static void virgl_cmd_set_scanout(VirtIOGPU *g, qemu_console_resize(g->parent_obj.scanout[ss.scanout_id].con, ss.r.width, ss.r.height); virgl_renderer_force_ctx_0(); - dpy_gl_scanout_texture( + qemu_console_gl_scanout_texture( g->parent_obj.scanout[ss.scanout_id].con, info.tex_id, info.flags & VIRTIO_GPU_RESOURCE_FLAG_Y_0_TOP, info.width, info.height, ss.r.x, ss.r.y, ss.r.width, ss.r.height, d3d_tex2d); } else { - dpy_gfx_replace_surface( - g->parent_obj.scanout[ss.scanout_id].con, NULL); - dpy_gl_scanout_disable(g->parent_obj.scanout[ss.scanout_id].con); + qemu_console_set_surface(g->parent_obj.scanout[ss.scanout_id].con,= NULL); + qemu_console_gl_scanout_disable(g->parent_obj.scanout[ss.scanout_i= d].con); } g->parent_obj.scanout[ss.scanout_id].resource_id =3D ss.resource_id; } @@ -1315,7 +1314,7 @@ virgl_create_context(void *opaque, int scanout_idx, qparams.major_ver =3D params->major_ver; qparams.minor_ver =3D params->minor_ver; =20 - ctx =3D dpy_gl_ctx_create(g->parent_obj.scanout[scanout_idx].con, &qpa= rams); + ctx =3D qemu_console_gl_ctx_create(g->parent_obj.scanout[scanout_idx].= con, &qparams); return (virgl_renderer_gl_context)ctx; } =20 @@ -1324,7 +1323,7 @@ static void virgl_destroy_context(void *opaque, virgl= _renderer_gl_context ctx) VirtIOGPU *g =3D opaque; QEMUGLContext qctx =3D (QEMUGLContext)ctx; =20 - dpy_gl_ctx_destroy(g->parent_obj.scanout[0].con, qctx); + qemu_console_gl_ctx_destroy(g->parent_obj.scanout[0].con, qctx); } =20 static int virgl_make_context_current(void *opaque, int scanout_idx, @@ -1333,8 +1332,7 @@ static int virgl_make_context_current(void *opaque, i= nt scanout_idx, VirtIOGPU *g =3D opaque; QEMUGLContext qctx =3D (QEMUGLContext)ctx; =20 - return dpy_gl_ctx_make_current(g->parent_obj.scanout[scanout_idx].con, - qctx); + return qemu_console_gl_ctx_make_current(g->parent_obj.scanout[scanout_= idx].con, qctx); } =20 static struct virgl_renderer_callbacks virtio_gpu_3d_cbs =3D { @@ -1399,8 +1397,8 @@ void virtio_gpu_virgl_reset_scanout(VirtIOGPU *g) int i; =20 for (i =3D 0; i < g->parent_obj.conf.max_outputs; i++) { - dpy_gfx_replace_surface(g->parent_obj.scanout[i].con, NULL); - dpy_gl_scanout_disable(g->parent_obj.scanout[i].con); + qemu_console_set_surface(g->parent_obj.scanout[i].con, NULL); + qemu_console_gl_scanout_disable(g->parent_obj.scanout[i].con); } } =20 diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index dbb72bbb22d..88526051a99 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -103,14 +103,14 @@ static void update_cursor(VirtIOGPU *g, struct virtio= _gpu_update_cursor *cursor) if (cursor->resource_id > 0) { vgc->update_cursor_data(g, s, cursor->resource_id); } - dpy_cursor_define(s->con, s->current_cursor); + qemu_console_set_cursor(s->con, s->current_cursor); =20 s->cursor =3D *cursor; } else { s->cursor.pos.x =3D cursor->pos.x; s->cursor.pos.y =3D cursor->pos.y; } - dpy_mouse_set(s->con, cursor->pos.x, cursor->pos.y, cursor->resource_i= d); + qemu_console_set_mouse(s->con, cursor->pos.x, cursor->pos.y, cursor->r= esource_id); } =20 struct virtio_gpu_simple_resource * @@ -390,7 +390,7 @@ void virtio_gpu_disable_scanout(VirtIOGPU *g, int scano= ut_id) res->scanout_bitmask &=3D ~(1 << scanout_id); } =20 - dpy_gfx_replace_surface(scanout->con, NULL); + qemu_console_set_surface(scanout->con, NULL); scanout->resource_id =3D 0; scanout->ds =3D NULL; scanout->width =3D 0; @@ -531,8 +531,8 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g, rf.r.y + rf.r.height >=3D scanout->y) { within_bounds =3D true; =20 - if (console_has_gl(scanout->con)) { - dpy_gl_update(scanout->con, 0, 0, scanout->width, + if (qemu_console_has_gl(scanout->con)) { + qemu_console_gl_update(scanout->con, 0, 0, scanout->wi= dth, scanout->height); update_submitted =3D true; } @@ -582,8 +582,8 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g, /* work out the area we need to update for each console */ if (qemu_rect_intersect(&flush_rect, &rect, &rect)) { qemu_rect_translate(&rect, -scanout->x, -scanout->y); - dpy_gfx_update(g->parent_obj.scanout[i].con, - rect.x, rect.y, rect.width, rect.height); + qemu_console_update(g->parent_obj.scanout[i].con, + rect.x, rect.y, rect.width, rect.height); } } } @@ -649,7 +649,7 @@ static bool virtio_gpu_do_set_scanout(VirtIOGPU *g, g->parent_obj.enable =3D 1; =20 if (res->blob) { - if (console_has_gl(scanout->con)) { + if (qemu_console_has_gl(scanout->con)) { if (!virtio_gpu_update_dmabuf(g, scanout_id, res, fb, r)) { virtio_gpu_update_scanout(g, scanout_id, res, fb, r); } else { @@ -665,7 +665,7 @@ static bool virtio_gpu_do_set_scanout(VirtIOGPU *g, } =20 /* create a surface for this scanout */ - if ((res->blob && !console_has_gl(scanout->con)) || + if ((res->blob && !qemu_console_has_gl(scanout->con)) || !scanout->ds || surface_data(scanout->ds) !=3D data + fb->offset || scanout->width !=3D r->width || @@ -686,7 +686,7 @@ static bool virtio_gpu_do_set_scanout(VirtIOGPU *g, qemu_displaysurface_set_share_handle(scanout->ds, res->share_handl= e, fb->offset); =20 pixman_image_unref(rect); - dpy_gfx_replace_surface(g->parent_obj.scanout[scanout_id].con, + qemu_console_set_surface(g->parent_obj.scanout[scanout_id].con, scanout->ds); } =20 @@ -1483,10 +1483,10 @@ static int virtio_gpu_post_load(void *opaque, int v= ersion_id) } scanout->ds =3D qemu_create_displaysurface_pixman(res->image); qemu_displaysurface_set_share_handle(scanout->ds, res->share_h= andle, 0); - dpy_gfx_replace_surface(scanout->con, scanout->ds); + qemu_console_set_surface(scanout->con, scanout->ds); } =20 - dpy_gfx_update_full(scanout->con); + qemu_console_update_full(scanout->con); if (scanout->cursor.resource_id) { update_cursor(g, &scanout->cursor); } @@ -1602,7 +1602,7 @@ static void virtio_gpu_reset_bh(void *opaque) } =20 for (i =3D 0; i < g->parent_obj.conf.max_outputs; i++) { - dpy_gfx_replace_surface(g->parent_obj.scanout[i].con, NULL); + qemu_console_set_surface(g->parent_obj.scanout[i].con, NULL); } =20 g->reset_finished =3D true; diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c index efd4858f3d0..2ae649c91ae 100644 --- a/hw/display/virtio-vga.c +++ b/hw/display/virtio-vga.c @@ -172,7 +172,7 @@ static void virtio_vga_base_realize(VirtIOPCIProxy *vpc= i_dev, Error **errp) vvga->vga_mrs, true, false); =20 vga->con =3D g->scanout[0].con; - graphic_console_set_hwops(vga->con, &virtio_vga_base_ops, vvga); + qemu_graphic_console_set_hwops(vga->con, &virtio_vga_base_ops, vvga); =20 for (i =3D 0; i < g->conf.max_outputs; i++) { object_property_set_link(OBJECT(g->scanout[i].con), "device", diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c index 11f13c98d7a..f6f9edfd1d9 100644 --- a/hw/display/vmware_vga.c +++ b/hw/display/vmware_vga.c @@ -378,7 +378,7 @@ static inline void vmsvga_update_rect(struct vmsvga_sta= te_s *s, for (line =3D h; line > 0; line--, src +=3D bypl, dst +=3D bypl) { memcpy(dst, src, width); } - dpy_gfx_update(s->vga.con, x, y, w, h); + qemu_console_update(s->vga.con, x, y, w, h); } =20 static inline void vmsvga_update_rect_flush(struct vmsvga_state_s *s) @@ -554,7 +554,7 @@ static inline void vmsvga_cursor_define(struct vmsvga_s= tate_s *s, qc =3D cursor_builtin_left_ptr(); } =20 - dpy_cursor_define(s->vga.con, qc); + qemu_console_set_cursor(s->vga.con, qc); cursor_unref(qc); } #endif @@ -1082,7 +1082,7 @@ static void vmsvga_value_write(void *opaque, uint32_t= address, uint32_t value) s->cursor.on &=3D (value !=3D SVGA_CURSOR_ON_HIDE); #ifdef HW_MOUSE_ACCEL if (value <=3D SVGA_CURSOR_ON_SHOW) { - dpy_mouse_set(s->vga.con, s->cursor.x, s->cursor.y, s->cursor.= on); + qemu_console_set_mouse(s->vga.con, s->cursor.x, s->cursor.y, s= ->cursor.on); } #endif break; @@ -1130,7 +1130,7 @@ static inline void vmsvga_check_size(struct vmsvga_st= ate_s *s) surface =3D qemu_create_displaysurface_from(s->new_width, s->new_h= eight, format, stride, s->vga.vram_ptr); - dpy_gfx_replace_surface(s->vga.con, surface); + qemu_console_set_surface(s->vga.con, surface); s->invalidated =3D 1; } } @@ -1151,7 +1151,7 @@ static bool vmsvga_update_display(void *opaque) =20 if (s->invalidated) { s->invalidated =3D 0; - dpy_gfx_update_full(s->vga.con); + qemu_console_update_full(s->vga.con); } =20 return true; @@ -1254,7 +1254,7 @@ static void vmsvga_init(DeviceState *dev, struct vmsv= ga_state_s *s, s->scratch_size =3D SVGA_SCRATCH_SIZE; s->scratch =3D g_malloc(s->scratch_size * 4); =20 - s->vga.con =3D graphic_console_init(dev, 0, &vmsvga_ops, s); + s->vga.con =3D qemu_graphic_console_create(dev, 0, &vmsvga_ops, s); =20 s->fifo_size =3D SVGA_FIFO_SIZE; memory_region_init_ram(&s->fifo_ram, NULL, "vmsvga.fifo", s->fifo_size, diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c index 2e431e27be6..8e9953bda43 100644 --- a/hw/display/xenfb.c +++ b/hw/display/xenfb.c @@ -657,7 +657,7 @@ static void xenfb_guest_copy(struct XenFB *xenfb, int x= , int y, int w, int h) xen_pv_printf(&xenfb->c.xendev, 0, "%s: oops: convert %d -> %d bpp= ?\n", __func__, xenfb->depth, bpp); =20 - dpy_gfx_update(xenfb->con, x, y, w, h); + qemu_console_update(xenfb->con, x, y, w, h); } =20 #ifdef XENFB_TYPE_REFRESH_PERIOD @@ -743,7 +743,7 @@ static bool xenfb_update(void *opaque) surface =3D qemu_create_displaysurface(xenfb->width, xenfb->he= ight); break; } - dpy_gfx_replace_surface(xenfb->con, surface); + qemu_console_set_surface(xenfb->con, surface); xen_pv_printf(&xenfb->c.xendev, 1, "update: resizing: %dx%d @ %d bpp%s\n", xenfb->width, xenfb->height, xenfb->depth, @@ -903,7 +903,7 @@ static int fb_initialise(struct XenLegacyDevice *xendev) if (rc !=3D 0) return rc; =20 - fb->con =3D graphic_console_init(NULL, 0, &xenfb_ops, fb); + fb->con =3D qemu_graphic_console_create(NULL, 0, &xenfb_ops, fb); =20 if (xenstore_read_fe_int(xendev, "feature-update", &fb->feature_update= ) =3D=3D -1) fb->feature_update =3D 0; diff --git a/hw/display/xlnx_dp.c b/hw/display/xlnx_dp.c index 50e6ef10984..2486d9e5825 100644 --- a/hw/display/xlnx_dp.c +++ b/hw/display/xlnx_dp.c @@ -605,7 +605,7 @@ static void xlnx_dp_recreate_surface(XlnxDPState *s) =20 if ((width !=3D 0) && (height !=3D 0)) { /* - * As dpy_gfx_replace_surface calls qemu_free_displaysurface on the + * As qemu_console_replace_surface calls qemu_free_displaysurface = on the * surface we need to be careful and don't free the surface associ= ated * to the console or double free will happen. */ @@ -631,10 +631,10 @@ static void xlnx_dp_recreate_surface(XlnxDPState *s) height, s->g_plane.for= mat, 0, NULL); - dpy_gfx_replace_surface(s->console, s->bout_plane.surface); + qemu_console_set_surface(s->console, s->bout_plane.surface); } else { s->bout_plane.surface =3D NULL; - dpy_gfx_replace_surface(s->console, s->g_plane.surface); + qemu_console_set_surface(s->console, s->g_plane.surface); } =20 xlnx_dpdma_set_host_data_location(s->dpdma, DP_GRAPHIC_DMA_CHANNEL, @@ -1287,7 +1287,7 @@ static bool xlnx_dp_update_display(void *opaque) /* * XXX: We might want to update only what changed. */ - dpy_gfx_update_full(s->console); + qemu_console_update_full(s->console); =20 return true; } @@ -1387,7 +1387,7 @@ static void xlnx_dp_realize(DeviceState *dev, Error *= *errp) qdev_realize(DEVICE(s->edid), BUS(aux_get_i2c_bus(s->aux_bus)), &error_fatal); =20 - s->console =3D graphic_console_init(dev, 0, &xlnx_dp_gfx_ops, s); + s->console =3D qemu_graphic_console_create(dev, 0, &xlnx_dp_gfx_ops, s= ); surface =3D qemu_console_surface(s->console); xlnx_dpdma_set_host_data_location(s->dpdma, DP_GRAPHIC_DMA_CHANNEL, surface_data(surface)); diff --git a/hw/vfio/display.c b/hw/vfio/display.c index 4a9a58036e3..8f91e83da88 100644 --- a/hw/vfio/display.c +++ b/hw/vfio/display.c @@ -264,7 +264,7 @@ static void vfio_display_free_one_dmabuf(VFIODisplay *d= py, VFIODMABuf *dmabuf) QTAILQ_REMOVE(&dpy->dmabuf.bufs, dmabuf, next); =20 qemu_dmabuf_close(dmabuf->buf); - dpy_gl_release_dmabuf(dpy->con, dmabuf->buf); + qemu_console_gl_release_dmabuf(dpy->con, dmabuf->buf); g_clear_pointer(&dmabuf->buf, qemu_dmabuf_free); g_free(dmabuf); } @@ -307,7 +307,7 @@ static bool vfio_display_dmabuf_update(void *opaque) if (dpy->dmabuf.primary !=3D primary) { dpy->dmabuf.primary =3D primary; qemu_console_resize(dpy->con, width, height); - dpy_gl_scanout_dmabuf(dpy->con, primary->buf); + qemu_console_gl_scanout_dmabuf(dpy->con, primary->buf); free_bufs =3D true; } =20 @@ -321,21 +321,21 @@ static bool vfio_display_dmabuf_update(void *opaque) if (cursor && (new_cursor || cursor->hot_updates)) { bool have_hot =3D (cursor->hot_x !=3D 0xffffffff && cursor->hot_y !=3D 0xffffffff); - dpy_gl_cursor_dmabuf(dpy->con, cursor->buf, have_hot, - cursor->hot_x, cursor->hot_y); + qemu_console_gl_cursor_dmabuf(dpy->con, cursor->buf, have_hot, + cursor->hot_x, cursor->hot_y); cursor->hot_updates =3D 0; } else if (!cursor && new_cursor) { - dpy_gl_cursor_dmabuf(dpy->con, NULL, false, 0, 0); + qemu_console_gl_cursor_dmabuf(dpy->con, NULL, false, 0, 0); } =20 if (cursor && cursor->pos_updates) { - dpy_gl_cursor_position(dpy->con, + qemu_console_gl_cursor_position(dpy->con, cursor->pos_x, cursor->pos_y); cursor->pos_updates =3D 0; } =20 - dpy_gl_update(dpy->con, 0, 0, width, height); + qemu_console_gl_update(dpy->con, 0, 0, width, height); =20 if (free_bufs) { vfio_display_free_dmabufs(vdev); @@ -363,7 +363,7 @@ static bool vfio_display_dmabuf_init(VFIOPCIDevice *vde= v, Error **errp) } =20 vdev->dpy =3D g_new0(VFIODisplay, 1); - vdev->dpy->con =3D graphic_console_init(DEVICE(vdev), 0, + vdev->dpy->con =3D qemu_graphic_console_create(DEVICE(vdev), 0, &vfio_display_dmabuf_ops, vdev); if (vdev->enable_ramfb) { @@ -396,9 +396,9 @@ void vfio_display_reset(VFIOPCIDevice *vdev) return; } =20 - dpy_gl_scanout_disable(vdev->dpy->con); + qemu_console_gl_scanout_disable(vdev->dpy->con); vfio_display_dmabuf_exit(vdev->dpy); - dpy_gfx_update_full(vdev->dpy->con); + qemu_console_update_full(vdev->dpy->con); } =20 static bool vfio_display_region_update(void *opaque) @@ -471,13 +471,13 @@ static bool vfio_display_region_update(void *opaque) dpy->region.surface =3D qemu_create_displaysurface_from (plane.width, plane.height, format, plane.stride, dpy->region.buffer.mmaps[0].mmap); - dpy_gfx_replace_surface(dpy->con, dpy->region.surface); + qemu_console_set_surface(dpy->con, dpy->region.surface); } =20 /* full screen update */ - dpy_gfx_update(dpy->con, 0, 0, - surface_width(dpy->region.surface), - surface_height(dpy->region.surface)); + qemu_console_update(dpy->con, 0, 0, + surface_width(dpy->region.surface), + surface_height(dpy->region.surface)); return true; =20 err: @@ -493,7 +493,7 @@ static const GraphicHwOps vfio_display_region_ops =3D { static bool vfio_display_region_init(VFIOPCIDevice *vdev, Error **errp) { vdev->dpy =3D g_new0(VFIODisplay, 1); - vdev->dpy->con =3D graphic_console_init(DEVICE(vdev), 0, + vdev->dpy->con =3D qemu_graphic_console_create(DEVICE(vdev), 0, &vfio_display_region_ops, vdev); if (vdev->enable_ramfb) { @@ -553,7 +553,7 @@ void vfio_display_finalize(VFIOPCIDevice *vdev) return; } =20 - graphic_console_close(vdev->dpy->con); + qemu_graphic_console_close(vdev->dpy->con); vfio_display_dmabuf_exit(vdev->dpy); vfio_display_region_exit(vdev->dpy); vfio_display_edid_exit(vdev->dpy); diff --git a/ui/console-vc.c b/ui/console-vc.c index 99ad6d079df..828e78c41ea 100644 --- a/ui/console-vc.c +++ b/ui/console-vc.c @@ -90,15 +90,15 @@ static void text_console_update(void *opaque, uint32_t = *chardata) s->vt.cells[src].t_attrib.bgcol, s->vt.cells[src].t_attrib.bold); } - dpy_text_update(QEMU_CONSOLE(s), s->vt.text_x[0], s->vt.text_y[0], - s->vt.text_x[1] - s->vt.text_x[0], i - s->vt.text_= y[0]); + qemu_console_text_update(QEMU_CONSOLE(s), s->vt.text_x[0], s->vt.t= ext_y[0], + s->vt.text_x[1] - s->vt.text_x[0], i - s-= >vt.text_y[0]); s->vt.text_x[0] =3D s->vt.width; s->vt.text_y[0] =3D s->vt.height; s->vt.text_x[1] =3D 0; s->vt.text_y[1] =3D 0; } if (s->vt.cursor_invalidate) { - dpy_text_cursor(QEMU_CONSOLE(s), s->vt.x, s->vt.y); + qemu_console_text_set_cursor(QEMU_CONSOLE(s), s->vt.x, s->vt.y); s->vt.cursor_invalidate =3D 0; } } @@ -186,14 +186,14 @@ static void vc_chr_set_echo(Chardev *chr, bool echo) =20 void qemu_text_console_update_size(QemuTextConsole *c) { - dpy_text_resize(QEMU_CONSOLE(c), c->vt.width, c->vt.height); + qemu_console_text_resize(QEMU_CONSOLE(c), c->vt.width, c->vt.height); } =20 static void text_console_image_update(QemuVT100 *vt, int x, int y, int wid= th, int height) { QemuTextConsole *console =3D container_of(vt, QemuTextConsole, vt); =20 - dpy_gfx_update(QEMU_CONSOLE(console), x, y, width, height); + qemu_console_update(QEMU_CONSOLE(console), x, y, width, height); } =20 static void text_console_out_flush(QemuVT100 *vt) @@ -232,7 +232,7 @@ static bool vc_chr_open(Chardev *chr, ChardevBackend *b= ackend, Error **errp) s =3D QEMU_TEXT_CONSOLE(object_new(TYPE_QEMU_FIXED_TEXT_CONSOLE)); } =20 - dpy_gfx_replace_surface(QEMU_CONSOLE(s), qemu_create_displaysurface(wi= dth, height)); + qemu_console_set_surface(QEMU_CONSOLE(s), qemu_create_displaysurface(w= idth, height)); if (vc->has_encoding) { drv->encoding =3D vc->encoding; } diff --git a/ui/console.c b/ui/console.c index 22ca1c35db3..6f6330d61f1 100644 --- a/ui/console.c +++ b/ui/console.c @@ -129,26 +129,26 @@ static void gui_setup_refresh(DisplayState *ds) } } =20 -void graphic_hw_update_done(QemuConsole *con) +void qemu_console_hw_update_done(QemuConsole *con) { if (con) { qemu_co_enter_all(&con->dump_queue, NULL); } } =20 -void graphic_hw_update(QemuConsole *con) +void qemu_console_hw_update(QemuConsole *con) { if (!con) { return; } if (!con->hw_ops->gfx_update || con->hw_ops->gfx_update(con->hw)) { - graphic_hw_update_done(con); + qemu_console_hw_update_done(con); } } =20 -static void graphic_hw_update_bh(void *con) +static void console_hw_update_bh(void *con) { - graphic_hw_update(con); + qemu_console_hw_update(con); } =20 void qemu_console_co_wait_update(QemuConsole *con) @@ -156,18 +156,18 @@ void qemu_console_co_wait_update(QemuConsole *con) if (qemu_co_queue_empty(&con->dump_queue)) { /* Defer the update, it will restart the pending coroutines */ aio_bh_schedule_oneshot(qemu_get_aio_context(), - graphic_hw_update_bh, con); + console_hw_update_bh, con); } qemu_co_queue_wait(&con->dump_queue, NULL); =20 } =20 -static void graphic_hw_gl_unblock_timer(void *opaque) +static void console_hw_gl_unblock_timer(void *opaque) { warn_report("console: no gl-unblock within one second"); } =20 -void graphic_hw_gl_block(QemuConsole *con, bool block) +void qemu_console_hw_gl_block(QemuConsole *con, bool block) { uint64_t timeout; assert(con !=3D NULL); @@ -205,14 +205,14 @@ void qemu_console_set_window_id(QemuConsole *con, int= window_id) con->window_id =3D window_id; } =20 -void graphic_hw_invalidate(QemuConsole *con) +void qemu_console_hw_invalidate(QemuConsole *con) { if (con && con->hw_ops->invalidate) { con->hw_ops->invalidate(con->hw); } } =20 -void graphic_hw_text_update(QemuConsole *con, uint32_t *chardata) +void qemu_console_hw_text_update(QemuConsole *con, uint32_t *chardata) { if (con && con->hw_ops->text_update) { con->hw_ops->text_update(con->hw, chardata); @@ -502,7 +502,7 @@ qemu_graphic_console_init(Object *obj) { } =20 -bool console_has_gl(QemuConsole *con) +bool qemu_console_has_gl(QemuConsole *con) { return con->gl !=3D NULL; } @@ -527,7 +527,7 @@ static bool console_compatible_with(QemuConsole *con, =20 flags =3D con->hw_ops->get_flags ? con->hw_ops->get_flags(con->hw) : 0; =20 - if (console_has_gl(con) && + if (qemu_console_has_gl(con) && !con->gl->ops->dpy_gl_ctx_is_compatible_dcl(con->gl, dcl)) { error_setg(errp, "Display %s is incompatible with the GL context", dcl->ops->dpy_name); @@ -535,7 +535,7 @@ static bool console_compatible_with(QemuConsole *con, } =20 if (flags & GRAPHIC_FLAGS_GL && - !console_has_gl(con)) { + !qemu_console_has_gl(con)) { error_setg(errp, "The console requires a GL context."); return false; =20 @@ -605,8 +605,8 @@ void qemu_console_register_listener(QemuConsole *con, vt100_update_cursor(); } =20 -void update_displaychangelistener(DisplayChangeListener *dcl, - uint64_t interval) +void qemu_console_listener_set_refresh(DisplayChangeListener *dcl, + uint64_t interval) { DisplayState *ds =3D dcl->ds; =20 @@ -645,7 +645,7 @@ static void dpy_set_ui_info_timer(void *opaque) con->hw_ops->ui_info(con->hw, head, &con->ui_info); } =20 -bool dpy_ui_info_supported(const QemuConsole *con) +bool qemu_console_ui_info_supported(const QemuConsole *con) { if (con =3D=3D NULL) { return false; @@ -654,16 +654,16 @@ bool dpy_ui_info_supported(const QemuConsole *con) return con->hw_ops->ui_info !=3D NULL; } =20 -const QemuUIInfo *dpy_get_ui_info(const QemuConsole *con) +const QemuUIInfo *qemu_console_get_ui_info(const QemuConsole *con) { - assert(dpy_ui_info_supported(con)); + assert(qemu_console_ui_info_supported(con)); =20 return &con->ui_info; } =20 -int dpy_set_ui_info(QemuConsole *con, QemuUIInfo *info, bool delay) +int qemu_console_set_ui_info(QemuConsole *con, QemuUIInfo *info, bool dela= y) { - if (!dpy_ui_info_supported(con)) { + if (!qemu_console_ui_info_supported(con)) { return -1; } if (memcmp(&con->ui_info, info, sizeof(con->ui_info)) =3D=3D 0) { @@ -682,7 +682,7 @@ int dpy_set_ui_info(QemuConsole *con, QemuUIInfo *info,= bool delay) return 0; } =20 -void dpy_gfx_update(QemuConsole *con, int x, int y, int w, int h) +void qemu_console_update(QemuConsole *con, int x, int y, int w, int h) { DisplayState *s =3D con->ds; DisplayChangeListener *dcl; @@ -707,15 +707,15 @@ void dpy_gfx_update(QemuConsole *con, int x, int y, i= nt w, int h) } } =20 -void dpy_gfx_update_full(QemuConsole *con) +void qemu_console_update_full(QemuConsole *con) { int w =3D qemu_console_get_width(con, 0); int h =3D qemu_console_get_height(con, 0); =20 - dpy_gfx_update(con, 0, 0, w, h); + qemu_console_update(con, 0, 0, w, h); } =20 -void dpy_gfx_replace_surface(QemuConsole *con, +void qemu_console_set_surface(QemuConsole *con, DisplaySurface *surface) { static const char placeholder_msg[] =3D "Display output is not active.= "; @@ -753,8 +753,8 @@ void dpy_gfx_replace_surface(QemuConsole *con, qemu_free_displaysurface(old_surface); } =20 -bool dpy_gfx_check_format(QemuConsole *con, - pixman_format_code_t format) +bool qemu_console_check_format(QemuConsole *con, + pixman_format_code_t format) { DisplayChangeListener *dcl; DisplayState *s =3D con->ds; @@ -789,7 +789,7 @@ static void dpy_refresh(DisplayState *s) } } =20 -void dpy_text_cursor(QemuConsole *con, int x, int y) +void qemu_console_text_set_cursor(QemuConsole *con, int x, int y) { DisplayState *s =3D con->ds; DisplayChangeListener *dcl; @@ -804,7 +804,7 @@ void dpy_text_cursor(QemuConsole *con, int x, int y) } } =20 -void dpy_text_update(QemuConsole *con, int x, int y, int w, int h) +void qemu_console_text_update(QemuConsole *con, int x, int y, int w, int h) { DisplayState *s =3D con->ds; DisplayChangeListener *dcl; @@ -819,7 +819,7 @@ void dpy_text_update(QemuConsole *con, int x, int y, in= t w, int h) } } =20 -void dpy_text_resize(QemuConsole *con, int w, int h) +void qemu_console_text_resize(QemuConsole *con, int w, int h) { DisplayState *s =3D con->ds; DisplayChangeListener *dcl; @@ -834,7 +834,7 @@ void dpy_text_resize(QemuConsole *con, int w, int h) } } =20 -void dpy_mouse_set(QemuConsole *c, int x, int y, bool on) +void qemu_console_set_mouse(QemuConsole *c, int x, int y, bool on) { QemuGraphicConsole *con =3D QEMU_GRAPHIC_CONSOLE(c); DisplayState *s =3D c->ds; @@ -853,7 +853,7 @@ void dpy_mouse_set(QemuConsole *c, int x, int y, bool o= n) } } =20 -void dpy_cursor_define(QemuConsole *c, QEMUCursor *cursor) +void qemu_console_set_cursor(QemuConsole *c, QEMUCursor *cursor) { QemuGraphicConsole *con =3D QEMU_GRAPHIC_CONSOLE(c); DisplayState *s =3D c->ds; @@ -871,26 +871,26 @@ void dpy_cursor_define(QemuConsole *c, QEMUCursor *cu= rsor) } } =20 -QEMUGLContext dpy_gl_ctx_create(QemuConsole *con, - struct QEMUGLParams *qparams) +QEMUGLContext qemu_console_gl_ctx_create(QemuConsole *con, + QEMUGLParams *qparams) { assert(con->gl); return con->gl->ops->dpy_gl_ctx_create(con->gl, qparams); } =20 -void dpy_gl_ctx_destroy(QemuConsole *con, QEMUGLContext ctx) +void qemu_console_gl_ctx_destroy(QemuConsole *con, QEMUGLContext ctx) { assert(con->gl); con->gl->ops->dpy_gl_ctx_destroy(con->gl, ctx); } =20 -int dpy_gl_ctx_make_current(QemuConsole *con, QEMUGLContext ctx) +int qemu_console_gl_ctx_make_current(QemuConsole *con, QEMUGLContext ctx) { assert(con->gl); return con->gl->ops->dpy_gl_ctx_make_current(con->gl, ctx); } =20 -void dpy_gl_scanout_disable(QemuConsole *con) +void qemu_console_gl_scanout_disable(QemuConsole *con) { DisplayState *s =3D con->ds; DisplayChangeListener *dcl; @@ -908,14 +908,14 @@ void dpy_gl_scanout_disable(QemuConsole *con) } } =20 -void dpy_gl_scanout_texture(QemuConsole *con, - uint32_t backing_id, - bool backing_y_0_top, - uint32_t backing_width, - uint32_t backing_height, - uint32_t x, uint32_t y, - uint32_t width, uint32_t height, - void *d3d_tex2d) +void qemu_console_gl_scanout_texture(QemuConsole *con, + uint32_t backing_id, + bool backing_y_0_top, + uint32_t backing_width, + uint32_t backing_height, + uint32_t x, uint32_t y, + uint32_t width, uint32_t height, + void *d3d_tex2d) { DisplayState *s =3D con->ds; DisplayChangeListener *dcl; @@ -939,8 +939,8 @@ void dpy_gl_scanout_texture(QemuConsole *con, } } =20 -void dpy_gl_scanout_dmabuf(QemuConsole *con, - QemuDmaBuf *dmabuf) +void qemu_console_gl_scanout_dmabuf(QemuConsole *con, + QemuDmaBuf *dmabuf) { DisplayState *s =3D con->ds; DisplayChangeListener *dcl; @@ -957,8 +957,8 @@ void dpy_gl_scanout_dmabuf(QemuConsole *con, } } =20 -void dpy_gl_cursor_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf, - bool have_hot, uint32_t hot_x, uint32_t hot_y) +void qemu_console_gl_cursor_dmabuf(QemuConsole *con, QemuDmaBuf *dmabuf, + bool have_hot, uint32_t hot_x, uint32_t= hot_y) { DisplayState *s =3D con->ds; DisplayChangeListener *dcl; @@ -974,8 +974,8 @@ void dpy_gl_cursor_dmabuf(QemuConsole *con, QemuDmaBuf = *dmabuf, } } =20 -void dpy_gl_cursor_position(QemuConsole *con, - uint32_t pos_x, uint32_t pos_y) +void qemu_console_gl_cursor_position(QemuConsole *con, + uint32_t pos_x, uint32_t pos_y) { DisplayState *s =3D con->ds; DisplayChangeListener *dcl; @@ -990,8 +990,8 @@ void dpy_gl_cursor_position(QemuConsole *con, } } =20 -void dpy_gl_release_dmabuf(QemuConsole *con, - QemuDmaBuf *dmabuf) +void qemu_console_gl_release_dmabuf(QemuConsole *con, + QemuDmaBuf *dmabuf) { DisplayState *s =3D con->ds; DisplayChangeListener *dcl; @@ -1006,15 +1006,15 @@ void dpy_gl_release_dmabuf(QemuConsole *con, } } =20 -void dpy_gl_update(QemuConsole *con, - uint32_t x, uint32_t y, uint32_t w, uint32_t h) +void qemu_console_gl_update(QemuConsole *con, + uint32_t x, uint32_t y, uint32_t w, uint32_t h) { DisplayState *s =3D con->ds; DisplayChangeListener *dcl; =20 assert(con->gl); =20 - graphic_hw_gl_block(con, true); + qemu_console_hw_gl_block(con, true); QLIST_FOREACH(dcl, &s->listeners, next) { if (con !=3D dcl->con) { continue; @@ -1023,7 +1023,7 @@ void dpy_gl_update(QemuConsole *con, dcl->ops->dpy_gl_update(dcl, x, y, w, h); } } - graphic_hw_gl_block(con, false); + qemu_console_hw_gl_block(con, false); } =20 /***********************************************************/ @@ -1060,17 +1060,17 @@ DisplayState *init_displaystate(void) return display_state; } =20 -void graphic_console_set_hwops(QemuConsole *con, - const GraphicHwOps *hw_ops, - void *opaque) +void qemu_graphic_console_set_hwops(QemuConsole *con, + const GraphicHwOps *hw_ops, + void *opaque) { con->hw_ops =3D hw_ops; con->hw =3D opaque; } =20 -QemuConsole *graphic_console_init(DeviceState *dev, uint32_t head, - const GraphicHwOps *hw_ops, - void *opaque) +QemuConsole *qemu_graphic_console_create(DeviceState *dev, uint32_t head, + const GraphicHwOps *hw_ops, + void *opaque) { static const char noinit[] =3D "Guest has not initialized the display (yet)."; @@ -1089,16 +1089,16 @@ QemuConsole *graphic_console_init(DeviceState *dev,= uint32_t head, s =3D (QemuConsole *)object_new(TYPE_QEMU_GRAPHIC_CONSOLE); } QEMU_GRAPHIC_CONSOLE(s)->head =3D head; - graphic_console_set_hwops(s, hw_ops, opaque); + qemu_graphic_console_set_hwops(s, hw_ops, opaque); if (dev) { object_property_set_link(OBJECT(s), "device", OBJECT(dev), &error_abort); } =20 surface =3D qemu_create_placeholder_surface(width, height, noinit); - dpy_gfx_replace_surface(s, surface); + qemu_console_set_surface(s, surface); s->gl_unblock_timer =3D timer_new_ms(QEMU_CLOCK_REALTIME, - graphic_hw_gl_unblock_timer, s); + console_hw_gl_unblock_timer, s); return s; } =20 @@ -1106,7 +1106,7 @@ static const GraphicHwOps unused_ops =3D { /* no callbacks */ }; =20 -void graphic_console_close(QemuConsole *con) +void qemu_graphic_console_close(QemuConsole *con) { static const char unplugged[] =3D "Guest display has been unplugged"; @@ -1116,13 +1116,13 @@ void graphic_console_close(QemuConsole *con) =20 trace_console_gfx_close(con->index); object_property_set_link(OBJECT(con), "device", NULL, &error_abort); - graphic_console_set_hwops(con, &unused_ops, NULL); + qemu_graphic_console_set_hwops(con, &unused_ops, NULL); =20 if (con->gl) { - dpy_gl_scanout_disable(con); + qemu_console_gl_scanout_disable(con); } surface =3D qemu_create_placeholder_surface(width, height, unplugged); - dpy_gfx_replace_surface(con, surface); + qemu_console_set_surface(con, surface); } =20 QemuConsole *qemu_console_lookup_default(void) @@ -1308,7 +1308,7 @@ void qemu_console_resize(QemuConsole *s, int width, i= nt height) } =20 surface =3D qemu_create_displaysurface(width, height); - dpy_gfx_replace_surface(s, surface); + qemu_console_set_surface(s, surface); } =20 DisplaySurface *qemu_console_surface(QemuConsole *console) diff --git a/ui/curses.c b/ui/curses.c index dbb5992981c..24d3713e57d 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -1,8 +1,8 @@ /* * QEMU curses/ncurses display driver - *=20 + * * Copyright (c) 2005 Andrzej Zaborowski - *=20 + * * Permission is hereby granted, free of charge, to any person obtaining a= copy * of this software and associated documentation files (the "Software"), t= o deal * in the Software without restriction, including without limitation the r= ights @@ -275,11 +275,11 @@ static void curses_refresh(DisplayChangeListener *dcl) clear(); refresh(); curses_calc_pad(); - graphic_hw_invalidate(dcl->con); + qemu_console_hw_invalidate(dcl->con); invalidate =3D 0; } =20 - graphic_hw_text_update(dcl->con, screen); + qemu_console_hw_text_update(dcl->con, screen); =20 while (1) { /* while there are any pending key strokes to process */ diff --git a/ui/dbus-console.c b/ui/dbus-console.c index 23f547a673d..b8e5c57b148 100644 --- a/ui/dbus-console.c +++ b/ui/dbus-console.c @@ -200,7 +200,7 @@ dbus_console_set_ui_info(DBusDisplayConsole *ddc, .height =3D arg_height, }; =20 - if (!dpy_ui_info_supported(ddc->dcl.con)) { + if (!qemu_console_ui_info_supported(ddc->dcl.con)) { g_dbus_method_invocation_return_error(invocation, DBUS_DISPLAY_ERROR, DBUS_DISPLAY_ERROR_UNSUPPORT= ED, @@ -208,7 +208,7 @@ dbus_console_set_ui_info(DBusDisplayConsole *ddc, return DBUS_METHOD_INVOCATION_HANDLED; } =20 - dpy_set_ui_info(ddc->dcl.con, &info, false); + qemu_console_set_ui_info(ddc->dcl.con, &info, false); qemu_dbus_display1_console_complete_set_uiinfo(ddc->iface, invocation); return DBUS_METHOD_INVOCATION_HANDLED; } diff --git a/ui/dbus-listener.c b/ui/dbus-listener.c index cc2c969686e..2e2f6ba4183 100644 --- a/ui/dbus-listener.c +++ b/ui/dbus-listener.c @@ -241,7 +241,7 @@ static void dbus_update_gl_cb(GObject *source_object, } #endif =20 - graphic_hw_gl_block(ddl->dcl.con, false); + qemu_console_hw_gl_block(ddl->dcl.con, false); g_object_unref(ddl); } #endif @@ -257,7 +257,7 @@ static void dbus_call_update_gl(DisplayChangeListener *= dcl, =20 glFlush(); #ifdef CONFIG_GBM - graphic_hw_gl_block(ddl->dcl.con, true); + qemu_console_hw_gl_block(ddl->dcl.con, true); qemu_dbus_display1_listener_call_update_dmabuf(ddl->proxy, x, y, w, h, G_DBUS_CALL_FLAGS_NONE, @@ -276,7 +276,7 @@ static void dbus_call_update_gl(DisplayChangeListener *= dcl, Error *err =3D NULL; assert(ddl->d3d_texture); =20 - graphic_hw_gl_block(ddl->dcl.con, true); + qemu_console_hw_gl_block(ddl->dcl.con, true); if (!d3d_texture2d_release0(ddl->d3d_texture, &err)) { error_report_err(err); return; @@ -711,7 +711,7 @@ static void dbus_gl_refresh(DisplayChangeListener *dcl) { DBusDisplayListener *ddl =3D container_of(dcl, DBusDisplayListener, dc= l); =20 - graphic_hw_update(dcl->con); + qemu_console_hw_update(dcl->con); =20 if (!ddl->ds || qemu_console_is_gl_blocked(ddl->dcl.con)) { return; @@ -740,7 +740,7 @@ static void dbus_gl_refresh(DisplayChangeListener *dcl) =20 static void dbus_refresh(DisplayChangeListener *dcl) { - graphic_hw_update(dcl->con); + qemu_console_hw_update(dcl->con); } =20 #ifdef CONFIG_OPENGL diff --git a/ui/egl-headless.c b/ui/egl-headless.c index 4f046c975a9..878bfebb40c 100644 --- a/ui/egl-headless.c +++ b/ui/egl-headless.c @@ -23,7 +23,7 @@ typedef struct egl_dpy { =20 static void egl_refresh(DisplayChangeListener *dcl) { - graphic_hw_update(dcl->con); + qemu_console_hw_update(dcl->con); } =20 static void egl_gfx_update(DisplayChangeListener *dcl, @@ -161,7 +161,7 @@ static void egl_scanout_flush(DisplayChangeListener *dc= l, } =20 egl_fb_read(edpy->ds, &edpy->blit_fb); - dpy_gfx_update(edpy->dcl.con, x, y, w, h); + qemu_console_update(edpy->dcl.con, x, y, w, h); } =20 static const DisplayChangeListenerOps egl_ops =3D { diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index fa8fe8970c1..7c5c9b2428c 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -108,7 +108,7 @@ void gd_egl_draw(VirtualConsole *vc) qemu_set_fd_handler(fence_fd, gd_hw_gl_flushed, NULL, vc); return; } - graphic_hw_gl_block(vc->gfx.dcl.con, false); + qemu_console_hw_gl_block(vc->gfx.dcl.con, false); } #endif } else { @@ -176,7 +176,7 @@ void gd_egl_refresh(DisplayChangeListener *dcl) return; } =20 - graphic_hw_update(dcl->con); + qemu_console_hw_update(dcl->con); =20 if (vc->gfx.glupdates) { vc->gfx.glupdates =3D 0; @@ -405,7 +405,7 @@ void gd_egl_flush(DisplayChangeListener *dcl, =20 if (vc->gfx.guest_fb.dmabuf && !qemu_dmabuf_get_draw_submitted(vc->gfx.guest_fb.dmabuf)) { - graphic_hw_gl_block(vc->gfx.dcl.con, true); + qemu_console_hw_gl_block(vc->gfx.dcl.con, true); qemu_dmabuf_set_draw_submitted(vc->gfx.guest_fb.dmabuf, true); gtk_egl_set_scanout_mode(vc, true); gtk_widget_queue_draw_area(area, x, y, w, h); diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c index ce49000d3f1..23806b9d01b 100644 --- a/ui/gtk-gl-area.c +++ b/ui/gtk-gl-area.c @@ -131,7 +131,7 @@ void gd_gl_area_draw(VirtualConsole *vc) qemu_set_fd_handler(fence_fd, gd_hw_gl_flushed, NULL, vc); return; } - graphic_hw_gl_block(vc->gfx.dcl.con, false); + qemu_console_hw_gl_block(vc->gfx.dcl.con, false); } #endif } else { @@ -195,7 +195,7 @@ void gd_gl_area_refresh(DisplayChangeListener *dcl) } } =20 - graphic_hw_update(dcl->con); + qemu_console_hw_update(dcl->con); =20 if (vc->gfx.glupdates) { vc->gfx.glupdates =3D 0; @@ -347,7 +347,7 @@ void gd_gl_area_scanout_flush(DisplayChangeListener *dc= l, =20 if (vc->gfx.guest_fb.dmabuf && !qemu_dmabuf_get_draw_submitted(vc->gfx.guest_fb.dmabuf)) { - graphic_hw_gl_block(vc->gfx.dcl.con, true); + qemu_console_hw_gl_block(vc->gfx.dcl.con, true); qemu_dmabuf_set_draw_submitted(vc->gfx.guest_fb.dmabuf, true); gtk_gl_area_set_scanout_mode(vc, true); } diff --git a/ui/gtk.c b/ui/gtk.c index ef3707b3634..2c61b601f78 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -436,7 +436,7 @@ static void gd_update(DisplayChangeListener *dcl, =20 static void gd_refresh(DisplayChangeListener *dcl) { - graphic_hw_update(dcl->con); + qemu_console_hw_update(dcl->con); } =20 static GdkDevice *gd_get_pointer(GdkDisplay *dpy) @@ -602,7 +602,7 @@ void gd_hw_gl_flushed(void *vcon) qemu_set_fd_handler(fence_fd, NULL, NULL, NULL); close(fence_fd); qemu_dmabuf_set_fence_fd(dmabuf, -1); - graphic_hw_gl_block(vc->gfx.dcl.con, false); + qemu_console_hw_gl_block(vc->gfx.dcl.con, false); } } =20 @@ -729,27 +729,27 @@ static void gd_set_ui_refresh_rate(VirtualConsole *vc= , int refresh_rate) { QemuUIInfo info; =20 - if (!dpy_ui_info_supported(vc->gfx.dcl.con)) { + if (!qemu_console_ui_info_supported(vc->gfx.dcl.con)) { return; } =20 - info =3D *dpy_get_ui_info(vc->gfx.dcl.con); + info =3D *qemu_console_get_ui_info(vc->gfx.dcl.con); info.refresh_rate =3D refresh_rate; - dpy_set_ui_info(vc->gfx.dcl.con, &info, true); + qemu_console_set_ui_info(vc->gfx.dcl.con, &info, true); } =20 static void gd_set_ui_size(VirtualConsole *vc, gint width, gint height) { QemuUIInfo info; =20 - if (!dpy_ui_info_supported(vc->gfx.dcl.con)) { + if (!qemu_console_ui_info_supported(vc->gfx.dcl.con)) { return; } =20 - info =3D *dpy_get_ui_info(vc->gfx.dcl.con); + info =3D *qemu_console_get_ui_info(vc->gfx.dcl.con); info.width =3D width; info.height =3D height; - dpy_set_ui_info(vc->gfx.dcl.con, &info, true); + qemu_console_set_ui_info(vc->gfx.dcl.con, &info, true); } =20 #if defined(CONFIG_OPENGL) @@ -2333,7 +2333,7 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, Vir= tualConsole *vc, gd_connect_vc_gfx_signals(vc); group =3D gd_vc_menu_init(s, vc, idx, group, view_menu); =20 - if (dpy_ui_info_supported(vc->gfx.dcl.con)) { + if (qemu_console_ui_info_supported(vc->gfx.dcl.con)) { zoom_to_fit =3D true; } if (s->opts->u.gtk.has_zoom_to_fit) { diff --git a/ui/sdl2-2d.c b/ui/sdl2-2d.c index 73052383c2e..68a3aff7151 100644 --- a/ui/sdl2-2d.c +++ b/ui/sdl2-2d.c @@ -129,7 +129,7 @@ void sdl2_2d_refresh(DisplayChangeListener *dcl) struct sdl2_console *scon =3D container_of(dcl, struct sdl2_console, d= cl); =20 assert(!scon->opengl); - graphic_hw_update(dcl->con); + qemu_console_hw_update(dcl->con); sdl2_poll_events(scon); } =20 diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c index bb066cdd885..1547ad2f6f8 100644 --- a/ui/sdl2-gl.c +++ b/ui/sdl2-gl.c @@ -115,7 +115,7 @@ void sdl2_gl_refresh(DisplayChangeListener *dcl) =20 assert(scon->opengl); =20 - graphic_hw_update(dcl->con); + qemu_console_hw_update(dcl->con); if (scon->updates && scon->real_window) { scon->updates =3D 0; sdl2_gl_render_surface(scon); diff --git a/ui/sdl2.c b/ui/sdl2.c index 89516f95c41..4fcdbd79d3c 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -604,7 +604,7 @@ static void handle_windowevent(SDL_Event *ev) .width =3D ev->window.data1, .height =3D ev->window.data2, }; - dpy_set_ui_info(scon->dcl.con, &info, true); + qemu_console_set_ui_info(scon->dcl.con, &info, true); } sdl2_redraw(scon); break; @@ -632,10 +632,10 @@ static void handle_windowevent(SDL_Event *ev) } break; case SDL_WINDOWEVENT_RESTORED: - update_displaychangelistener(&scon->dcl, GUI_REFRESH_INTERVAL_DEFA= ULT); + qemu_console_listener_set_refresh(&scon->dcl, GUI_REFRESH_INTERVAL= _DEFAULT); break; case SDL_WINDOWEVENT_MINIMIZED: - update_displaychangelistener(&scon->dcl, 500); + qemu_console_listener_set_refresh(&scon->dcl, 500); break; case SDL_WINDOWEVENT_CLOSE: if (qemu_console_is_graphic(scon->dcl.con)) { diff --git a/ui/spice-display.c b/ui/spice-display.c index 56d8140fad8..e3716127203 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -468,7 +468,7 @@ void qemu_spice_cursor_refresh_bh(void *opaque) assert(ssd->dcl.con); cursor_ref(c); qemu_mutex_unlock(&ssd->lock); - dpy_cursor_define(ssd->dcl.con, c); + qemu_console_set_cursor(ssd->dcl.con, c); qemu_mutex_lock(&ssd->lock); cursor_unref(c); } @@ -481,7 +481,7 @@ void qemu_spice_cursor_refresh_bh(void *opaque) ssd->mouse_x =3D -1; ssd->mouse_y =3D -1; qemu_mutex_unlock(&ssd->lock); - dpy_mouse_set(ssd->dcl.con, x, y, true); + qemu_console_set_mouse(ssd->dcl.con, x, y, true); } else { qemu_mutex_unlock(&ssd->lock); } @@ -489,7 +489,7 @@ void qemu_spice_cursor_refresh_bh(void *opaque) =20 void qemu_spice_display_refresh(SimpleSpiceDisplay *ssd) { - graphic_hw_update(ssd->dcl.con); + qemu_console_hw_update(ssd->dcl.con); =20 WITH_QEMU_LOCK_GUARD(&ssd->lock) { if (QTAILQ_EMPTY(&ssd->updates) && ssd->ds) { @@ -668,7 +668,7 @@ static int interface_client_monitors_config(QXLInstance= *sin, QemuUIInfo info; int head; =20 - if (!dpy_ui_info_supported(ssd->dcl.con)) { + if (!qemu_console_ui_info_supported(ssd->dcl.con)) { return 0; /* =3D=3D not supported by guest */ } =20 @@ -676,7 +676,7 @@ static int interface_client_monitors_config(QXLInstance= *sin, return 1; } =20 - info =3D *dpy_get_ui_info(ssd->dcl.con); + info =3D *qemu_console_get_ui_info(ssd->dcl.con); =20 head =3D qemu_console_get_index(ssd->dcl.con); if (mc->num_of_monitors > head) { @@ -690,7 +690,7 @@ static int interface_client_monitors_config(QXLInstance= *sin, } =20 trace_qemu_spice_ui_info(ssd->qxl.id, info.width, info.height); - dpy_set_ui_info(ssd->dcl.con, &info, false); + qemu_console_set_ui_info(ssd->dcl.con, &info, false); return 1; } =20 @@ -817,7 +817,7 @@ static void qemu_spice_gl_block(SimpleSpiceDisplay *ssd= , bool block) } else { timer_del(ssd->gl_unblock_timer); } - graphic_hw_gl_block(ssd->dcl.con, block); + qemu_console_hw_gl_block(ssd->dcl.con, block); } =20 static void qemu_spice_gl_unblock_bh(void *opaque) @@ -861,7 +861,7 @@ static void spice_gl_refresh(DisplayChangeListener *dcl) return; } =20 - graphic_hw_update(dcl->con); + qemu_console_hw_update(dcl->con); if (ssd->gl_updates && ssd->have_surface) { qemu_spice_gl_block(ssd, true); glFlush(); diff --git a/ui/vnc.c b/ui/vnc.c index e8c8773a36e..d3dfabede03 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -2325,8 +2325,8 @@ static void set_pixel_format(VncState *vs, int bits_p= er_pixel, =20 set_pixel_conversion(vs); =20 - graphic_hw_invalidate(vs->vd->dcl.con); - graphic_hw_update(vs->vd->dcl.con); + qemu_console_hw_invalidate(vs->vd->dcl.con); + qemu_console_hw_update(vs->vd->dcl.con); } =20 static void pixel_format_message (VncState *vs) { @@ -2384,7 +2384,7 @@ static int protocol_client_msg(VncState *vs, uint8_t = *data, size_t len) VncDisplay *vd =3D vs->vd; =20 if (data[0] > 3) { - update_displaychangelistener(&vd->dcl, VNC_REFRESH_INTERVAL_BASE); + qemu_console_listener_set_refresh(&vd->dcl, VNC_REFRESH_INTERVAL_B= ASE); } =20 switch (data[0]) { @@ -2638,9 +2638,9 @@ static int protocol_client_msg(VncState *vs, uint8_t = *data, size_t len) h =3D read_u16(data, 4); =20 trace_vnc_msg_client_set_desktop_size(vs, vs->ioc, w, h, screens); - if (dpy_ui_info_supported(vs->vd->dcl.con)) { + if (qemu_console_ui_info_supported(vs->vd->dcl.con)) { QemuUIInfo info =3D { .width =3D w, .height =3D h }; - dpy_set_ui_info(vs->vd->dcl.con, &info, false); + qemu_console_set_ui_info(vs->vd->dcl.con, &info, false); vnc_desktop_resize_ext(vs, 4 /* Request forwarded */); } else { vnc_desktop_resize_ext(vs, 3 /* Invalid screen layout */); @@ -3242,14 +3242,14 @@ static void vnc_refresh(DisplayChangeListener *dcl) int has_dirty, rects =3D 0; =20 if (QTAILQ_EMPTY(&vd->clients)) { - update_displaychangelistener(&vd->dcl, VNC_REFRESH_INTERVAL_MAX); + qemu_console_listener_set_refresh(&vd->dcl, VNC_REFRESH_INTERVAL_M= AX); return; } =20 - graphic_hw_update(vd->dcl.con); + qemu_console_hw_update(vd->dcl.con); =20 if (vnc_trylock_display(vd)) { - update_displaychangelistener(&vd->dcl, VNC_REFRESH_INTERVAL_BASE); + qemu_console_listener_set_refresh(&vd->dcl, VNC_REFRESH_INTERVAL_B= ASE); return; } =20 @@ -3323,7 +3323,7 @@ static void vnc_connect(VncDisplay *vd, QIOChannelSoc= ket *sioc, sioc, websocket, vs->auth, vs->subauth); =20 VNC_DEBUG("New client on socket %p\n", vs->sioc); - update_displaychangelistener(&vd->dcl, VNC_REFRESH_INTERVAL_BASE); + qemu_console_listener_set_refresh(&vd->dcl, VNC_REFRESH_INTERVAL_BASE); qio_channel_set_blocking(vs->ioc, false, &error_abort); g_clear_handle_id(&vs->ioc_tag, g_source_remove); if (websocket) { @@ -3363,7 +3363,7 @@ static void vnc_connect(VncDisplay *vd, QIOChannelSoc= ket *sioc, vnc_update_server_surface(vd); } =20 - graphic_hw_update(vd->dcl.con); + qemu_console_hw_update(vd->dcl.con); =20 if (!vs->websocket) { vnc_start_protocol(vs); @@ -3419,7 +3419,7 @@ static void vmstate_change_handler(void *opaque, bool= running, RunState state) if (state !=3D RUN_STATE_RUNNING) { return; } - update_displaychangelistener(&vd->dcl, VNC_REFRESH_INTERVAL_BASE); + qemu_console_listener_set_refresh(&vd->dcl, VNC_REFRESH_INTERVAL_BASE); } =20 static bool vnc_display_open(VncDisplay *vd, Error **errp); diff --git a/hw/display/apple-gfx.m b/hw/display/apple-gfx.m index 77d80fb7cef..be0061b9db2 100644 --- a/hw/display/apple-gfx.m +++ b/hw/display/apple-gfx.m @@ -317,8 +317,8 @@ static void apple_gfx_render_frame_completed_bh(void *o= paque) copy_mtl_texture_to_surface_mem(s->texture, surface_data(s->su= rface)); if (s->gfx_update_requested) { s->gfx_update_requested =3D false; - dpy_gfx_update_full(s->con); - graphic_hw_update_done(s->con); + qemu_console_update_full(s->con); + qemu_console_hw_update_done(s->con); s->new_frame_ready =3D false; } else { s->new_frame_ready =3D true; @@ -337,7 +337,7 @@ static bool apple_gfx_fb_update_display(void *opaque) =20 assert(bql_locked()); if (s->new_frame_ready) { - dpy_gfx_update_full(s->con); + qemu_console_update_full(s->con); s->new_frame_ready =3D false; } else if (s->pending_frames > 0) { s->gfx_update_requested =3D true; @@ -380,14 +380,14 @@ static void set_mode(AppleGFXState *s, uint32_t width= , uint32_t height) (s->texture.storageMode =3D=3D MTLStorageModeManaged); } =20 - dpy_gfx_replace_surface(s->con, s->surface); + qemu_console_set_surface(s->con, s->surface); } =20 static void update_cursor(AppleGFXState *s) { assert(bql_locked()); - dpy_mouse_set(s->con, s->pgdisp.cursorPosition.x, - s->pgdisp.cursorPosition.y, qatomic_read(&s->cursor_show= )); + qemu_console_set_mouse(s->con, s->pgdisp.cursorPosition.x, + s->pgdisp.cursorPosition.y, qatomic_read(&s->cu= rsor_show)); } =20 static void update_cursor_bh(void *opaque) @@ -443,7 +443,7 @@ static void set_cursor_glyph(void *opaque) } px_data +=3D padding_bytes_per_row; } - dpy_cursor_define(s->con, s->cursor); + qemu_console_set_cursor(s->con, s->cursor); update_cursor(s); } [glyph release]; @@ -792,7 +792,7 @@ bool apple_gfx_common_realize(AppleGFXState *s, DeviceS= tate *dev, apple_gfx_create_display_mode_array(display_modes, num_display_mod= es); [mode_array release]; =20 - s->con =3D graphic_console_init(dev, 0, &apple_gfx_fb_ops, s); + s->con =3D qemu_graphic_console_create(dev, 0, &apple_gfx_fb_ops, s); return true; } =20 diff --git a/ui/cocoa.m b/ui/cocoa.m index aaf82421589..98394cdc507 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -421,7 +421,7 @@ - (void) selectConsoleLocked:(unsigned int)index return; } =20 - unregister_displaychangelistener(&dcl); + qemu_console_unregister_listener(&dcl); qkbd_state_switch_console(kbd, con); qemu_console_register_listener(con, &dcl, &dcl_ops); [self notifyMouseModeChange]; @@ -669,8 +669,8 @@ - (void) updateUIInfoLocked CVTime period =3D CVDisplayLinkGetNominalOutputVideoRefreshPer= iod(displayLink); CVDisplayLinkRelease(displayLink); if (!(period.flags & kCVTimeIsIndefinite)) { - update_displaychangelistener(&dcl, - 1000 * period.timeValue / per= iod.timeScale); + qemu_console_listener_set_refresh(&dcl, + 1000 * period.timeValue = / period.timeScale); info.refresh_rate =3D (int64_t)1000 * period.timeScale / p= eriod.timeValue; } } @@ -688,7 +688,7 @@ - (void) updateUIInfoLocked info.width =3D frameSize.width * [[self window] backingScaleFactor]; info.height =3D frameSize.height * [[self window] backingScaleFactor]; =20 - dpy_set_ui_info(dcl.con, &info, TRUE); + qemu_console_set_ui_info(dcl.con, &info, TRUE); } =20 #pragma clang diagnostic pop @@ -2056,7 +2056,7 @@ static void cocoa_refresh(DisplayChangeListener *dcl) NSAutoreleasePool * pool =3D [[NSAutoreleasePool alloc] init]; =20 COCOA_DEBUG("qemu_cocoa: cocoa_refresh\n"); - graphic_hw_update(dcl->con); + qemu_console_hw_update(dcl->con); =20 if (cbchangecount !=3D [[NSPasteboard generalPasteboard] changeCount])= { qemu_clipboard_info_unref(cbinfo); --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778347144; cv=none; d=zohomail.com; s=zohoarc; b=OYGYoH3FhgygUcCg1CaxYIwkdMmmOiYh5oWAiQRxFifGEvyxArMtVKACUDaCsSBktTboyY14eGTrM8ALX/D2WXRzILl3/viCk3c1RLAT3eTHgyL6HB1vejJvwcF0usfxpa3iJNh43V58xxpbgt6tBVHJ+cV76kAb/Sw0oJf90m4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778347144; 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=x9HfPgCd6Efsa5oTjlVY/lDr783HcOZnf69yIWnUX8U=; b=iqH9g3pZcGJA3eC6opBk28vhsAAeWFy7MqfOUZ6RK6bPMu8yDyQOPaUvbaT6l7Ula4L3iSbqkXGSM2w3pecuj4sA/UcgWm6XBDoWxXyCo6a62GhLMmMXE8/t0x9u+wDxse/R7cShOm7/PnouazjS0WQzs+6LNvbMbSsItZ9/CBw= 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 1778347144790696.9933300205608; Sat, 9 May 2026 10:19:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlIf-00015r-5n; Sat, 09 May 2026 13:17:13 -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 1wLlIU-0000bc-7i for qemu-devel@nongnu.org; Sat, 09 May 2026 13:17:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wLlIR-0005OP-Fh for qemu-devel@nongnu.org; Sat, 09 May 2026 13:17:02 -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-119-baGHNcGsOrCQo2danUsUCA-1; Sat, 09 May 2026 13:16:57 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 6B72C19560AA; Sat, 9 May 2026 17:16:56 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BE9281955D84; Sat, 9 May 2026 17:16:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778347018; 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=x9HfPgCd6Efsa5oTjlVY/lDr783HcOZnf69yIWnUX8U=; b=VGT/oufLp8KbmWK8fOxAkw3p7s7/YTuyETbuWvTPD/riVJHw/Jal1lOi6nwoN6EJEY4qGL QXwM+RjVz8Ilqce9dwaodPAVBm3xnJ79XbUqX1OVtcHF9W6lIZJ/4366GkmjaT9ti/Jixs DkdF61z9LZ2VgjVzYnJWtr02t4WrrUw= X-MC-Unique: baGHNcGsOrCQo2danUsUCA-1 X-Mimecast-MFC-AGG-ID: baGHNcGsOrCQo2danUsUCA_1778347016 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 29/33] ui/vnc: replace VNC_DEBUG with trace-events Date: Sat, 9 May 2026 21:13:50 +0400 Message-ID: <20260509171356.1157879-30-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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.129.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_H4=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: 1778347146533158500 From: Marc-Andr=C3=A9 Lureau Replace #ifdef printf() with run-time trace events. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/vnc.h | 8 ----- ui/vnc-auth-sasl.c | 13 +++----- ui/vnc-enc-tight.c | 4 +-- ui/vnc-enc-zlib.c | 4 +-- ui/vnc-ws.c | 10 +++--- ui/vnc.c | 83 +++++++++++++++++----------------------------- ui/trace-events | 29 +++++++++++++++- 7 files changed, 73 insertions(+), 78 deletions(-) diff --git a/ui/vnc.h b/ui/vnc.h index 0b345246c8e..0750bf5f72f 100644 --- a/ui/vnc.h +++ b/ui/vnc.h @@ -46,14 +46,6 @@ #include "vnc-enc-zrle.h" #include "ui/kbd-state.h" =20 -// #define _VNC_DEBUG 1 - -#ifdef _VNC_DEBUG -#define VNC_DEBUG(fmt, ...) do { fprintf(stderr, fmt, ## __VA_ARGS__); } w= hile (0) -#else -#define VNC_DEBUG(fmt, ...) do { } while (0) -#endif - /*************************************************************************= **** * * Core data structures diff --git a/ui/vnc-auth-sasl.c b/ui/vnc-auth-sasl.c index 3f4cfc471d5..9964b969ac2 100644 --- a/ui/vnc-auth-sasl.c +++ b/ui/vnc-auth-sasl.c @@ -73,10 +73,10 @@ size_t vnc_client_write_sasl(VncState *vs) { size_t ret; =20 - VNC_DEBUG("Write SASL: Pending output %p size %zd offset %zd " - "Encoded: %p size %d offset %d\n", - vs->output.buffer, vs->output.capacity, vs->output.offset, - vs->sasl.encoded, vs->sasl.encodedLength, vs->sasl.encodedOf= fset); + trace_vnc_sasl_write_pending(vs, vs->output.buffer, vs->output.capacit= y, + vs->output.offset, vs->sasl.encoded, + vs->sasl.encodedLength, + vs->sasl.encodedOffset); =20 if (!vs->sasl.encoded) { int err; @@ -157,8 +157,7 @@ size_t vnc_client_read_sasl(VncState *vs) =20 if (err !=3D SASL_OK) return vnc_client_io_error(vs, -1, NULL); - VNC_DEBUG("Read SASL Encoded %p size %ld Decoded %p size %d\n", - encoded, ret, decoded, decodedLen); + trace_vnc_sasl_read_decoded(vs, encoded, ret, decoded, decodedLen); buffer_reserve(&vs->input, decodedLen); buffer_append(&vs->input, decoded, decodedLen); return decodedLen; @@ -717,5 +716,3 @@ void start_auth_sasl(VncState *vs) error_free(local_err); vnc_client_error(vs); } - - diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c index 9dfe6ae5a24..ca671427018 100644 --- a/ui/vnc-enc-tight.c +++ b/ui/vnc-enc-tight.c @@ -46,6 +46,7 @@ #include "vnc.h" #include "vnc-enc-tight.h" #include "vnc-palette.h" +#include "trace.h" =20 /* Compression level stuff. The following array contains various encoder parameters for each of 10 compression levels (0..9). @@ -795,8 +796,7 @@ static int tight_init_stream(VncState *vs, VncTight *ti= ght, int stream_id, if (zstream->opaque =3D=3D NULL) { int err; =20 - VNC_DEBUG("VNC: TIGHT: initializing zlib stream %d\n", stream_id); - VNC_DEBUG("VNC: TIGHT: opaque =3D %p | vs =3D %p\n", zstream->opaq= ue, vs); + trace_vnc_tight_zlib_init(vs, stream_id, zstream->opaque); zstream->zalloc =3D vnc_zlib_zalloc; zstream->zfree =3D vnc_zlib_zfree; =20 diff --git a/ui/vnc-enc-zlib.c b/ui/vnc-enc-zlib.c index a6d287118aa..657b47ceb2b 100644 --- a/ui/vnc-enc-zlib.c +++ b/ui/vnc-enc-zlib.c @@ -26,6 +26,7 @@ =20 #include "qemu/osdep.h" #include "vnc.h" +#include "trace.h" =20 #define ZALLOC_ALIGNMENT 16 =20 @@ -71,8 +72,7 @@ static int vnc_zlib_stop(VncState *vs, VncWorker *worker) if (zstream->opaque !=3D vs) { int err; =20 - VNC_DEBUG("VNC: initializing zlib stream\n"); - VNC_DEBUG("VNC: opaque =3D %p | vs =3D %p\n", zstream->opaque, vs); + trace_vnc_zlib_init(vs, zstream->opaque); zstream->zalloc =3D vnc_zlib_zalloc; zstream->zfree =3D vnc_zlib_zfree; =20 diff --git a/ui/vnc-ws.c b/ui/vnc-ws.c index 65e8b344b65..fad5dbce342 100644 --- a/ui/vnc-ws.c +++ b/ui/vnc-ws.c @@ -32,11 +32,11 @@ static void vncws_tls_handshake_done(QIOTask *task, Error *err =3D NULL; =20 if (qio_task_propagate_error(task, &err)) { - VNC_DEBUG("Handshake failed %s\n", error_get_pretty(err)); + trace_vnc_ws_tls_handshake_fail(vs, error_get_pretty(err)); vnc_client_error(vs); error_free(err); } else { - VNC_DEBUG("TLS handshake complete, starting websocket handshake\n"= ); + trace_vnc_ws_tls_handshake_complete(vs); if (vs->ioc_tag) { g_source_remove(vs->ioc_tag); } @@ -67,7 +67,7 @@ gboolean vncws_tls_handshake_io(QIOChannel *ioc G_GNUC_UN= USED, vs->vd->tlsauthzid, &err); if (!tls) { - VNC_DEBUG("Failed to setup TLS %s\n", error_get_pretty(err)); + trace_vnc_ws_tls_setup_fail(vs, error_get_pretty(err)); error_free(err); vnc_client_error(vs); return TRUE; @@ -97,11 +97,11 @@ static void vncws_handshake_done(QIOTask *task, Error *err =3D NULL; =20 if (qio_task_propagate_error(task, &err)) { - VNC_DEBUG("Websock handshake failed %s\n", error_get_pretty(err)); + trace_vnc_ws_handshake_fail(vs, error_get_pretty(err)); vnc_client_error(vs); error_free(err); } else { - VNC_DEBUG("Websock handshake complete, starting VNC protocol\n"); + trace_vnc_ws_handshake_complete(vs); vnc_start_protocol(vs); if (vs->ioc_tag) { g_source_remove(vs->ioc_tag); diff --git a/ui/vnc.c b/ui/vnc.c index d3dfabede03..56dd43d53ff 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -75,17 +75,7 @@ static void vnc_disconnect_finish(VncState *vs); =20 static void vnc_set_share_mode(VncState *vs, VncShareMode mode) { -#ifdef _VNC_DEBUG - static const char *mn[] =3D { - [0] =3D "undefined", - [VNC_SHARE_MODE_CONNECTING] =3D "connecting", - [VNC_SHARE_MODE_SHARED] =3D "shared", - [VNC_SHARE_MODE_EXCLUSIVE] =3D "exclusive", - [VNC_SHARE_MODE_DISCONNECTED] =3D "disconnected", - }; - fprintf(stderr, "%s/%p: %s -> %s\n", __func__, - vs->ioc, mn[vs->share_mode], mn[mode]); -#endif + trace_vnc_set_share_mode(vs, vs->ioc, vs->share_mode, mode); =20 switch (vs->share_mode) { case VNC_SHARE_MODE_CONNECTING: @@ -185,8 +175,9 @@ static void vnc_init_basic_info_from_remote_addr(QIOCha= nnelSocket *ioc, qapi_free_SocketAddress(addr); } =20 -static const char *vnc_auth_name(VncDisplay *vd) { - switch (vd->auth) { +static const char *vnc_auth_name(int auth, int subauth) +{ + switch (auth) { case VNC_AUTH_INVALID: return "invalid"; case VNC_AUTH_NONE: @@ -204,7 +195,7 @@ static const char *vnc_auth_name(VncDisplay *vd) { case VNC_AUTH_TLS: return "tls"; case VNC_AUTH_VENCRYPT: - switch (vd->subauth) { + switch (subauth) { case VNC_AUTH_VENCRYPT_PLAIN: return "vencrypt+plain"; case VNC_AUTH_VENCRYPT_TLSNONE: @@ -244,7 +235,7 @@ static VncServerInfo *vnc_server_info_get(VncDisplay *v= d) info =3D g_malloc0(sizeof(*info)); vnc_init_basic_info_from_server_addr(qio_net_listener_sioc(vd->listene= r, 0), qapi_VncServerInfo_base(info), &e= rr); - info->auth =3D g_strdup(vnc_auth_name(vd)); + info->auth =3D g_strdup(vnc_auth_name(vd->auth, vd->subauth)); if (err) { qapi_free_VncServerInfo(info); info =3D NULL; @@ -421,7 +412,7 @@ VncInfo *qmp_query_vnc(Error **errp) =20 info->has_family =3D true; =20 - info->auth =3D g_strdup(vnc_auth_name(vd)); + info->auth =3D g_strdup(vnc_auth_name(vd->auth, vd->subauth)); } =20 qapi_free_SocketAddress(addr); @@ -1383,7 +1374,7 @@ size_t vnc_client_io_error(VncState *vs, ssize_t ret,= Error *err) =20 void vnc_client_error(VncState *vs) { - VNC_DEBUG("Closing down client sock: protocol error\n"); + trace_vnc_client_protocol_error(vs); vnc_disconnect_start(vs); } =20 @@ -1408,7 +1399,7 @@ size_t vnc_client_write_buf(VncState *vs, const uint8= _t *data, size_t datalen) Error *err =3D NULL; ssize_t ret; ret =3D qio_channel_write(vs->ioc, (const char *)data, datalen, &err); - VNC_DEBUG("Wrote wire %p %zd -> %ld\n", data, datalen, ret); + trace_vnc_client_write_wire(vs, data, datalen, ret); return vnc_client_io_error(vs, ret, err); } =20 @@ -1429,9 +1420,9 @@ static size_t vnc_client_write_plain(VncState *vs) size_t ret; =20 #ifdef CONFIG_VNC_SASL - VNC_DEBUG("Write Plain: Pending output %p size %zd offset %zd. Wait SS= F %d\n", - vs->output.buffer, vs->output.capacity, vs->output.offset, - vs->sasl.waitWriteSSF); + trace_vnc_client_write_plain(vs, vs->output.buffer, + vs->output.capacity, vs->output.offset, + vs->sasl.waitWriteSSF); =20 if (vs->sasl.conn && vs->sasl.runSSF && @@ -1532,7 +1523,7 @@ size_t vnc_client_read_buf(VncState *vs, uint8_t *dat= a, size_t datalen) ssize_t ret; Error *err =3D NULL; ret =3D qio_channel_read(vs->ioc, (char *)data, datalen, &err); - VNC_DEBUG("Read wire %p %zd -> %ld\n", data, datalen, ret); + trace_vnc_client_read_wire(vs, data, datalen, ret); return vnc_client_io_error(vs, ret, err); } =20 @@ -1549,8 +1540,8 @@ size_t vnc_client_read_buf(VncState *vs, uint8_t *dat= a, size_t datalen) static size_t vnc_client_read_plain(VncState *vs) { size_t ret; - VNC_DEBUG("Read plain %p size %zd offset %zd\n", - vs->input.buffer, vs->input.capacity, vs->input.offset); + trace_vnc_client_read_plain(vs, vs->input.buffer, + vs->input.capacity, vs->input.offset); buffer_reserve(&vs->input, 4096); ret =3D vnc_client_read_buf(vs, buffer_end(&vs->input), 4096); if (!ret) @@ -2213,7 +2204,7 @@ static void set_encodings(VncState *vs, int32_t *enco= dings, size_t n_encodings) } break; default: - VNC_DEBUG("Unknown encoding: %d (0x%.8x): %d\n", i, enc, enc); + trace_vnc_client_unknown_encoding(vs, i, enc); break; } } @@ -2581,14 +2572,13 @@ static int protocol_client_msg(VncState *vs, uint8_= t *data, size_t len) case 4: vs->as.fmt =3D AUDIO_FORMAT_U32; break; case 5: vs->as.fmt =3D AUDIO_FORMAT_S32; break; default: - VNC_DEBUG("Invalid audio format %d\n", read_u8(data, 4= )); + trace_vnc_client_invalid_audio_format(vs, read_u8(data= , 4)); vnc_client_error(vs); break; } vs->as.nchannels =3D read_u8(data, 5); if (vs->as.nchannels !=3D 1 && vs->as.nchannels !=3D 2) { - VNC_DEBUG("Invalid audio channel count %d\n", - read_u8(data, 5)); + trace_vnc_client_invalid_audio_channels(vs, read_u8(da= ta, 5)); vnc_client_error(vs); break; } @@ -2598,7 +2588,7 @@ static int protocol_client_msg(VncState *vs, uint8_t = *data, size_t len) * protects calculations involving 'vs->as.freq' later. */ if (freq > 48000) { - VNC_DEBUG("Invalid audio frequency %u > 48000", freq); + trace_vnc_client_invalid_audio_freq(vs, freq); vnc_client_error(vs); break; } @@ -2607,14 +2597,14 @@ static int protocol_client_msg(VncState *vs, uint8_= t *data, size_t len) vs, vs->ioc, vs->as.fmt, vs->as.nchannels, vs->as.freq= ); break; default: - VNC_DEBUG("Invalid audio message %d\n", read_u8(data, 2)); + trace_vnc_client_invalid_audio_msg(vs, read_u8(data, 2)); vnc_client_error(vs); break; } break; =20 default: - VNC_DEBUG("Msg: %d\n", read_u16(data, 0)); + trace_vnc_client_unknown_qemu_msg(vs, read_u16(data, 0)); vnc_client_error(vs); break; } @@ -2649,7 +2639,7 @@ static int protocol_client_msg(VncState *vs, uint8_t = *data, size_t len) break; } default: - VNC_DEBUG("Msg: %d\n", data[0]); + trace_vnc_client_unknown_msg(vs, data[0]); vnc_client_error(vs); break; } @@ -2929,18 +2919,18 @@ static int protocol_version(VncState *vs, uint8_t *= version, size_t len) local[12] =3D 0; =20 if (sscanf(local, "RFB %03d.%03d\n", &vs->major, &vs->minor) !=3D 2) { - VNC_DEBUG("Malformed protocol version %s\n", local); + trace_vnc_client_protocol_version_malformed(vs, local); vnc_client_error(vs); return 0; } - VNC_DEBUG("Client request protocol version %d.%d\n", vs->major, vs->mi= nor); + trace_vnc_client_protocol_version(vs, vs->major, vs->minor); if (vs->major !=3D 3 || (vs->minor !=3D 3 && vs->minor !=3D 4 && vs->minor !=3D 5 && vs->minor !=3D 7 && vs->minor !=3D 8)) { - VNC_DEBUG("Unsupported client version\n"); + trace_vnc_client_protocol_version_unsupported(vs); vnc_write_u32(vs, VNC_AUTH_INVALID); vnc_flush(vs); vnc_client_error(vs); @@ -2960,7 +2950,7 @@ static int protocol_version(VncState *vs, uint8_t *ve= rsion, size_t len) trace_vnc_auth_pass(vs, vs->auth); start_client_init(vs); } else if (vs->auth =3D=3D VNC_AUTH_VNC) { - VNC_DEBUG("Tell client VNC auth\n"); + trace_vnc_client_auth_method(vs, vs->auth); vnc_write_u32(vs, vs->auth); vnc_flush(vs); start_auth_vnc(vs); @@ -3319,10 +3309,7 @@ static void vnc_connect(VncDisplay *vd, QIOChannelSo= cket *sioc, vs->subauth =3D vd->subauth; } } - VNC_DEBUG("Client sioc=3D%p ws=3D%d auth=3D%d subauth=3D%d\n", - sioc, websocket, vs->auth, vs->subauth); - - VNC_DEBUG("New client on socket %p\n", vs->sioc); + trace_vnc_client_setup(vs, sioc, websocket, vs->auth, vs->subauth); qemu_console_listener_set_refresh(&vd->dcl, VNC_REFRESH_INTERVAL_BASE); qio_channel_set_blocking(vs->ioc, false, &error_abort); g_clear_handle_id(&vs->ioc_tag, g_source_remove); @@ -3727,13 +3714,10 @@ vnc_display_setup_auth(int *auth, */ if (websocket || !tlscreds) { if (password) { - VNC_DEBUG("Initializing VNC server with password auth\n"); *auth =3D VNC_AUTH_VNC; } else if (sasl) { - VNC_DEBUG("Initializing VNC server with SASL auth\n"); *auth =3D VNC_AUTH_SASL; } else { - VNC_DEBUG("Initializing VNC server with no auth\n"); *auth =3D VNC_AUTH_NONE; } *subauth =3D VNC_AUTH_INVALID; @@ -3752,27 +3736,20 @@ vnc_display_setup_auth(int *auth, *auth =3D VNC_AUTH_VENCRYPT; if (password) { if (is_x509) { - VNC_DEBUG("Initializing VNC server with x509 password auth= \n"); *subauth =3D VNC_AUTH_VENCRYPT_X509VNC; } else { - VNC_DEBUG("Initializing VNC server with TLS password auth\= n"); *subauth =3D VNC_AUTH_VENCRYPT_TLSVNC; } - } else if (sasl) { if (is_x509) { - VNC_DEBUG("Initializing VNC server with x509 SASL auth\n"); *subauth =3D VNC_AUTH_VENCRYPT_X509SASL; } else { - VNC_DEBUG("Initializing VNC server with TLS SASL auth\n"); *subauth =3D VNC_AUTH_VENCRYPT_TLSSASL; } } else { if (is_x509) { - VNC_DEBUG("Initializing VNC server with x509 no auth\n"); *subauth =3D VNC_AUTH_VENCRYPT_X509NONE; } else { - VNC_DEBUG("Initializing VNC server with TLS no auth\n"); *subauth =3D VNC_AUTH_VENCRYPT_TLSNONE; } } @@ -4221,14 +4198,16 @@ static bool vnc_display_open(VncDisplay *vd, Error = **errp) sasl, false, errp) < 0) { return false; } - trace_vnc_auth_init(vd, 0, vd->auth, vd->subauth); + trace_vnc_auth_init(vd, 0, vd->auth, vd->subauth, + vnc_auth_name(vd->auth, vd->subauth)); =20 if (vnc_display_setup_auth(&vd->ws_auth, &vd->ws_subauth, vd->tlscreds, password, sasl, true, errp) < 0) { return false; } - trace_vnc_auth_init(vd, 1, vd->ws_auth, vd->ws_subauth); + trace_vnc_auth_init(vd, 1, vd->ws_auth, vd->ws_subauth, + vnc_auth_name(vd->ws_auth, vd->ws_subauth)); =20 #ifdef CONFIG_VNC_SASL if (sasl && !vnc_sasl_server_init(errp)) { diff --git a/ui/trace-events b/ui/trace-events index 3eba9ca3a82..c1ea56874ee 100644 --- a/ui/trace-events +++ b/ui/trace-events @@ -83,7 +83,7 @@ vnc_job_discard_rect(void *state, void *job, int x, int y= , int w, int h) "VNC jo vnc_job_clamp_rect(void *state, void *job, int x, int y, int w, int h) "VN= C job clamp rect state=3D%p job=3D%p offset=3D%d,%d size=3D%dx%d" vnc_job_clamped_rect(void *state, void *job, int x, int y, int w, int h) "= VNC job clamp rect state=3D%p job=3D%p offset=3D%d,%d size=3D%dx%d" vnc_job_nrects(void *state, void *job, int nrects) "VNC job state=3D%p job= =3D%p nrects=3D%d" -vnc_auth_init(void *display, int websock, int auth, int subauth) "VNC auth= init state=3D%p websock=3D%d auth=3D%d subauth=3D%d" +vnc_auth_init(void *display, int websock, int auth, int subauth, const cha= r *name) "VNC auth init state=3D%p websock=3D%d auth=3D%d subauth=3D%d name= =3D%s" vnc_auth_start(void *state, int method) "VNC client auth start state=3D%p = method=3D%d" vnc_auth_pass(void *state, int method) "VNC client auth passed state=3D%p = method=3D%d" vnc_auth_fail(void *state, int method, const char *message, const char *re= ason) "VNC client auth failed state=3D%p method=3D%d message=3D%s reason=3D= %s" @@ -97,6 +97,33 @@ vnc_auth_sasl_step(void *state, const void *clientdata, = size_t clientlen, const vnc_auth_sasl_ssf(void *state, int ssf) "VNC client auth SASL SSF state=3D= %p size=3D%d" vnc_auth_sasl_username(void *state, const char *name) "VNC client auth SAS= L user state=3D%p name=3D%s" vnc_auth_sasl_acl(void *state, int allow) "VNC client auth SASL ACL state= =3D%p allow=3D%d" +vnc_set_share_mode(void *state, void *ioc, int old_mode, int new_mode) "VN= C set share mode state=3D%p ioc=3D%p old=3D%d new=3D%d" +vnc_client_protocol_error(void *state) "VNC client protocol error state=3D= %p" +vnc_client_write_wire(void *state, const void *data, size_t datalen, ssize= _t ret) "VNC client write wire state=3D%p data=3D%p len=3D%zu ret=3D%zd" +vnc_client_write_plain(void *state, const void *buffer, size_t capacity, s= ize_t offset, int wait_ssf) "VNC client write plain state=3D%p buffer=3D%p = capacity=3D%zu offset=3D%zu wait_ssf=3D%d" +vnc_client_read_wire(void *state, const void *data, size_t datalen, ssize_= t ret) "VNC client read wire state=3D%p data=3D%p len=3D%zu ret=3D%zd" +vnc_client_read_plain(void *state, const void *buffer, size_t capacity, si= ze_t offset) "VNC client read plain state=3D%p buffer=3D%p capacity=3D%zu o= ffset=3D%zu" +vnc_client_unknown_encoding(void *state, int index, int encoding) "VNC cli= ent unknown encoding state=3D%p index=3D%d encoding=3D0x%x" +vnc_client_invalid_audio_format(void *state, int fmt) "VNC client invalid = audio format state=3D%p fmt=3D%d" +vnc_client_invalid_audio_channels(void *state, int channels) "VNC client i= nvalid audio channel count state=3D%p channels=3D%d" +vnc_client_invalid_audio_freq(void *state, unsigned int freq) "VNC client = invalid audio frequency state=3D%p freq=3D%u" +vnc_client_invalid_audio_msg(void *state, int msg) "VNC client invalid aud= io message state=3D%p msg=3D%d" +vnc_client_unknown_qemu_msg(void *state, int msg) "VNC client unknown QEMU= msg state=3D%p msg=3D%d" +vnc_client_unknown_msg(void *state, int msg) "VNC client unknown msg state= =3D%p msg=3D%d" +vnc_client_protocol_version(void *state, int major, int minor) "VNC client= protocol version state=3D%p version=3D%d.%d" +vnc_client_protocol_version_malformed(void *state, const char *version) "V= NC client malformed protocol version state=3D%p version=3D%s" +vnc_client_protocol_version_unsupported(void *state) "VNC client unsupport= ed protocol version state=3D%p" +vnc_client_auth_method(void *state, int auth) "VNC client auth method stat= e=3D%p auth=3D%d" +vnc_client_setup(void *state, void *ioc, int websocket, int auth, int suba= uth) "VNC client setup state=3D%p ioc=3D%p websocket=3D%d auth=3D%d subauth= =3D%d" +vnc_ws_tls_handshake_fail(void *state, const char *msg) "VNC WS TLS handsh= ake failed state=3D%p msg=3D%s" +vnc_ws_tls_handshake_complete(void *state) "VNC WS TLS handshake complete = state=3D%p" +vnc_ws_tls_setup_fail(void *state, const char *msg) "VNC WS TLS setup fail= ed state=3D%p msg=3D%s" +vnc_ws_handshake_fail(void *state, const char *msg) "VNC WS handshake fail= ed state=3D%p msg=3D%s" +vnc_ws_handshake_complete(void *state) "VNC WS handshake complete state=3D= %p" +vnc_sasl_write_pending(void *state, const void *buffer, size_t capacity, s= ize_t offset, const void *encoded, int encoded_len, int encoded_offset) "VN= C SASL write pending state=3D%p buffer=3D%p capacity=3D%zu offset=3D%zu enc= oded=3D%p encoded_len=3D%d encoded_offset=3D%d" +vnc_sasl_read_decoded(void *state, const void *encoded, size_t encoded_len= , const void *decoded, unsigned int decoded_len) "VNC SASL read decoded sta= te=3D%p encoded=3D%p encoded_len=3D%zu decoded=3D%p decoded_len=3D%u" +vnc_zlib_init(void *state, const void *opaque) "VNC zlib init state=3D%p o= paque=3D%p" +vnc_tight_zlib_init(void *state, int stream_id, const void *opaque) "VNC t= ight zlib init state=3D%p stream=3D%d opaque=3D%p" =20 =20 # input.c --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778347108; cv=none; d=zohomail.com; s=zohoarc; b=S7pKglNacx0fag7I/cQQkfwRIcLsfyX1PBGkvOL8WLJ/wHFa9ucuthPXQtSp+kr/H2H2RObJ0PneSWr1rRQNKPLUVlSCprsxmvizT030HscDGh8L4439Klc5NTQg8tiab0yuUv2d2xnz88/MW2/1B9cLafy3lItFBI6RDXqkJkQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778347108; 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=dYXmbRstOh2+gnsYlCTibS3Jum51nlAnN9XXssfmugs=; b=JMueh+dAl2O99fkmd6UELFpDA6jBKI+YT92R7I2+uDxQv5SUfgYMolGfGcebSssQjromAKtIFLpZcJ5P+KSh0zkoYB7sErf+iPmKTUIEzq++m88ayAXzdRKW9HLeBbCeQpWPzQ2rKuhCu96dD7Rc3ptIRzEcAX6lo0rtMG0axio= 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 1778347108377775.1697263673515; Sat, 9 May 2026 10:18:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlIc-0000oJ-P7; Sat, 09 May 2026 13:17:10 -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 1wLlIZ-0000ec-4q for qemu-devel@nongnu.org; Sat, 09 May 2026 13:17:09 -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 1wLlIX-0005Pr-HF for qemu-devel@nongnu.org; Sat, 09 May 2026 13:17:06 -0400 Received: from mx-prod-mc-05.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-38-5n4BRUEZNKi3oNDpkZkRBg-1; Sat, 09 May 2026 13:17:03 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 97A091956088; Sat, 9 May 2026 17:17:02 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 1E7C93002D30; Sat, 9 May 2026 17:17:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778347024; 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=dYXmbRstOh2+gnsYlCTibS3Jum51nlAnN9XXssfmugs=; b=XhNgKojOQo8Vrr6tjHA69nFpQdl98bjiMcwtrouw3rUcj5yrzWhQBU7Y33oECDAnq+0ORo 46WRU/kOY3YNuUjHQvH3KK3sisfD+DmQ0z3NsZJYzHu/Sy09chruegvtxUWwo8jeuX00J2 zGtnYPBgtEgSCBkSZ5fd5cOCiB0gLyg= X-MC-Unique: 5n4BRUEZNKi3oNDpkZkRBg-1 X-Mimecast-MFC-AGG-ID: 5n4BRUEZNKi3oNDpkZkRBg_1778347022 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PULL v2 30/33] ui: extract common sources into a static library Date: Sat, 9 May 2026 21:13:51 +0400 Message-ID: <20260509171356.1157879-31-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 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: 1778347111210154100 From: Marc-Andr=C3=A9 Lureau Move clipboard, cursor, display-surface, input-keymap, kbd-state, keymaps, vt100, and qemu-pixman into a separate static library 'qemuui'. This allows these common UI sources to be linked by targets outside of the system emulator build, such as standalone VNC or D-Bus display binaries. keymaps generation has to be moved earlier, so that header dependency are resolved first. The library objects are re-exported via a dependency so existing system_ss consumers are unaffected. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- ui/meson.build | 103 ++++++++++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 48 deletions(-) diff --git a/ui/meson.build b/ui/meson.build index 74151b05033..1b8f71796e4 100644 --- a/ui/meson.build +++ b/ui/meson.build @@ -1,25 +1,67 @@ -system_ss.add(pixman) +keymaps =3D [ + ['atset1', 'qcode'], + ['linux', 'qcode'], + ['qcode', 'atset1'], + ['qcode', 'atset2'], + ['qcode', 'atset3'], + ['qcode', 'linux'], + ['qcode', 'qnum'], + ['qcode', 'sun'], + ['qnum', 'qcode'], + ['usb', 'qcode'], + ['win32', 'qcode'], + ['x11', 'qcode'], + ['xorgevdev', 'qcode'], + ['xorgkbd', 'qcode'], + ['xorgxquartz', 'qcode'], + ['xorgxwin', 'qcode'], + ['osx', 'qcode'], +] + +if have_system or xkbcommon.found() + keycodemapdb_proj =3D subproject('keycodemapdb', required: true) + foreach e : keymaps + output =3D 'input-keymap-@0@-to-@1@.c.inc'.format(e[0], e[1]) + genh +=3D custom_target(output, + output: output, + capture: true, + input: keycodemapdb_proj.get_variable('keymaps_csv'), + command: [python, keycodemapdb_proj.get_variable('keymap= _gen').full_path(), + 'code-map', '--lang', 'glib2', + '--varname', 'qemu_input_map_@0@_to_@1@'.forma= t(e[0], e[1]), + '@INPUT0@', e[0], e[1]]) + endforeach +endif + +libui_sources =3D files( + 'clipboard.c', + 'console.c', + 'cursor.c', + 'dmabuf.c', + 'display-surface.c', + 'input-keymap.c', + 'kbd-state.c', + 'keymaps.c', + 'qemu-pixman.c', + 'vgafont.c', + ) +if pixman.found() + libui_sources +=3D files('cp437.c', 'vt100.c') +endif +libui =3D static_library('qemuui', libui_sources + genh, + dependencies: [pixman], + build_by_default: false) +ui =3D declare_dependency(objects: libui.extract_all_objects(recursive: fa= lse), dependencies: [pixman]) system_ss.add(png) system_ss.add(files( - 'clipboard.c', - 'console.c', - 'cp437.c', - 'cursor.c', - 'display-surface.c', - 'dmabuf.c', - 'input-keymap.c', 'input-legacy.c', 'input-barrier.c', 'input.c', - 'kbd-state.c', - 'keymaps.c', - 'qemu-pixman.c', 'ui-hmp-cmds.c', 'ui-qmp-cmds.c', 'util.c', - 'vgafont.c', - 'vt100.c', )) +system_ss.add(ui) system_ss.add(when: pixman, if_true: files('console-vc.c'), if_false: file= s('console-vc-stubs.c')) if dbus_display system_ss.add(files('dbus-module.c')) @@ -149,41 +191,6 @@ if spice.found() endif endif =20 -keymaps =3D [ - ['atset1', 'qcode'], - ['linux', 'qcode'], - ['qcode', 'atset1'], - ['qcode', 'atset2'], - ['qcode', 'atset3'], - ['qcode', 'linux'], - ['qcode', 'qnum'], - ['qcode', 'sun'], - ['qnum', 'qcode'], - ['usb', 'qcode'], - ['win32', 'qcode'], - ['x11', 'qcode'], - ['xorgevdev', 'qcode'], - ['xorgkbd', 'qcode'], - ['xorgxquartz', 'qcode'], - ['xorgxwin', 'qcode'], - ['osx', 'qcode'], -] - -if have_system or xkbcommon.found() - keycodemapdb_proj =3D subproject('keycodemapdb', required: true) - foreach e : keymaps - output =3D 'input-keymap-@0@-to-@1@.c.inc'.format(e[0], e[1]) - genh +=3D custom_target(output, - output: output, - capture: true, - input: keycodemapdb_proj.get_variable('keymaps_csv'), - command: [python, keycodemapdb_proj.get_variable('keymap= _gen').full_path(), - 'code-map', '--lang', 'glib2', - '--varname', 'qemu_input_map_@0@_to_@1@'.forma= t(e[0], e[1]), - '@INPUT0@', e[0], e[1]]) - endforeach -endif - subdir('shader') =20 if have_system --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778347122; cv=none; d=zohomail.com; s=zohoarc; b=ajFJ9IUCFFmi629bCzuJZiuSpsbUM9hIlA+vNc/qIY9anYg2i+xEDTzTsbiHhkb/n4w1BlfyqOC6L7lK3Qzi/i+fuqK/Kxe8w9B8E5gOqEdVU5rIz9e+qLywEsyybGrmXEOOCLf3OVF6m7SEgCr667TxFaZ9lNrInDb4KUlNlDY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778347122; 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=wrfgt2+O9xDLwTBdVq4+Tq0EQdn5EuB/u5Gnsjp4egI=; b=PDmiLrbiQ6A2IsXYJkxkACmcSXFIPRBhtNp533UfyuDiEswFeWNL+TWAS1Cd8QbssFgC6MYfDYvK0/h0RjcHcDuq4Jfz9V8bnJTCHMTFaseW6RvV68o8Fxe0zS0D+AWf2cH0kKuiURqp9QV1W/0JcagFgb54e2OWFtZxbJrcryE= 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 1778347122837365.0100932237309; Sat, 9 May 2026 10:18:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlIj-0001Y8-0t; Sat, 09 May 2026 13:17:17 -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 1wLlIh-0001Jv-4I for qemu-devel@nongnu.org; Sat, 09 May 2026 13:17:15 -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 1wLlIf-0005TN-L4 for qemu-devel@nongnu.org; Sat, 09 May 2026 13:17:14 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-300-qkJ2ub0MP8GmEOow1gOUtA-1; Sat, 09 May 2026 13:17:09 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4E39718005B3; Sat, 9 May 2026 17:17:08 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DC92819560A2; Sat, 9 May 2026 17:17:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778347033; 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=wrfgt2+O9xDLwTBdVq4+Tq0EQdn5EuB/u5Gnsjp4egI=; b=H96hF8dZNtnpT/3q8bhxwv8EBXQtlvR2nBNywlaBkLzv/3lfSL9FSv37BIfQFcUADjunTa 3zhTbPGjcdHZUMqWMGL6VomkFB6/Xm+W8KHEz4k8FFF7q0CsIhgD192mOI6n3yjkxWBLzo RKMfiGWwoqDaz8U1VtMerStfzyEUdUk= X-MC-Unique: qkJ2ub0MP8GmEOow1gOUtA-1 X-Mimecast-MFC-AGG-ID: qkJ2ub0MP8GmEOow1gOUtA_1778347028 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Fabiano Rosas , Laurent Vivier , Paolo Bonzini Subject: [PULL v2 31/33] tests/qtest: drop DBUS_VMSTATE_TEST_TMPDIR Date: Sat, 9 May 2026 21:13:52 +0400 Message-ID: <20260509171356.1157879-32-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 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, SPF_HELO_PASS=-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 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: 1778347124288158500 From: Marc-Andr=C3=A9 Lureau It can rely on the location of the temporary configuration instead, so we don't have to set that environment variable on every test. Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Marc-Andr=C3=A9 Lureau --- tests/qtest/dbus-vmstate-test.c | 2 -- tests/dbus-daemon.sh | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/qtest/dbus-vmstate-test.c b/tests/qtest/dbus-vmstate-tes= t.c index 15c35e7c0fa..339b731ceb5 100644 --- a/tests/qtest/dbus-vmstate-test.c +++ b/tests/qtest/dbus-vmstate-test.c @@ -395,8 +395,6 @@ main(int argc, char **argv) exit(1); } =20 - g_setenv("DBUS_VMSTATE_TEST_TMPDIR", workdir, true); - migration_test_add("/dbus-vmstate/without-list", test_dbus_vmstate_without_list); migration_test_add("/dbus-vmstate/with-list", diff --git a/tests/dbus-daemon.sh b/tests/dbus-daemon.sh index 474e2501548..c4a50c73774 100755 --- a/tests/dbus-daemon.sh +++ b/tests/dbus-daemon.sh @@ -26,7 +26,7 @@ write_config() cat > "$CONF" < session - unix:tmpdir=3D$DBUS_VMSTATE_TEST_TMPDIR + unix:tmpdir=3D$(dirname "$CONF") =20 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/qemu-vnc/trace-events b/tools/qemu-vnc/trace-events new file mode 100644 index 00000000000..e3b550de10e --- /dev/null +++ b/tools/qemu-vnc/trace-events @@ -0,0 +1,21 @@ +qemu_vnc_audio_out_fini(uint64_t id) "id=3D%" PRIu64 +qemu_vnc_audio_out_init(uint64_t id, uint32_t freq, uint8_t channels, uint= 8_t bits) "id=3D%" PRIu64 " freq=3D%u ch=3D%u bits=3D%u" +qemu_vnc_audio_out_set_enabled(uint64_t id, bool enabled) "id=3D%" PRIu64 = " enabled=3D%d" +qemu_vnc_audio_out_write(uint64_t id, size_t size) "id=3D%" PRIu64 " size= =3D%zu" +qemu_vnc_chardev_connected(const char *name) "name=3D%s" +qemu_vnc_clipboard_grab(int selection, uint32_t serial) "selection=3D%d se= rial=3D%u" +qemu_vnc_clipboard_release(int selection) "selection=3D%d" +qemu_vnc_clipboard_request(int selection) "selection=3D%d" +qemu_vnc_client_not_found(const char *host, const char *service) "host=3D%= s service=3D%s" +qemu_vnc_console_io_error(const char *name) "name=3D%s" +qemu_vnc_cursor_define(int width, int height, int hot_x, int hot_y) "w=3D%= d h=3D%d hot=3D%d,%d" +qemu_vnc_input_abs(uint32_t x, uint32_t y) "x=3D%u y=3D%u" +qemu_vnc_input_btn(int button, bool press) "button=3D%d press=3D%d" +qemu_vnc_input_rel(int dx, int dy) "dx=3D%d dy=3D%d" +qemu_vnc_key_event(int qcode, bool down) "qcode=3D%d down=3D%d" +qemu_vnc_owner_appeared(const char *name) "peer=3D%s" +qemu_vnc_owner_vanished(const char *name) "peer=3D%s" +qemu_vnc_scanout(uint32_t width, uint32_t height, uint32_t stride, uint32_= t format) "w=3D%u h=3D%u stride=3D%u fmt=3D0x%x" +qemu_vnc_scanout_map(uint32_t width, uint32_t height, uint32_t stride, uin= t32_t format, uint32_t offset) "w=3D%u h=3D%u stride=3D%u fmt=3D0x%x offset= =3D%u" +qemu_vnc_update(int x, int y, int w, int h, uint32_t stride, uint32_t form= at) "x=3D%d y=3D%d w=3D%d h=3D%d stride=3D%u fmt=3D0x%x" +qemu_vnc_update_map(uint32_t x, uint32_t y, uint32_t w, uint32_t h) "x=3D%= u y=3D%u w=3D%u h=3D%u" --=20 2.54.0 From nobody Mon May 25 20:37:28 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=1778347123; cv=none; d=zohomail.com; s=zohoarc; b=j+KVt+/TVme9KRMv1cNsR7zrCx8pHqglgF7ptX6amlEKS4vyc3Ex4yZXo/aJq+2c+M4GbJUByA1FsKNX7iO85livSaCwLB9frGhPTMdGK1Hu7Up4HcnwJMUs8xclXjWZVRR5mb5hBIruevnVFYSddI14OgCnq+rtTkcfqenfqEg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1778347123; 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=t4Slxdzy3hL0v2brTM0N78PBrN0bU27hlHRoj2ilZ3M=; b=RXacnnpoQOfxGmkpbEAP/kLwzkVHDBIZDGS8OvaQePDScBpSdm7NluUbLMiRVlnKRiR1lLZIPzL1ddlPvj5s9uqPxbchZ0dvD48Y+jw4t6BheVfb48PLNq7gfZVunXpCuLZ7igUtp+ULjIyusDlyamcoSGE8SEpT5jc6jsTMKBU= 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 1778347123080205.8259136786894; Sat, 9 May 2026 10:18:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wLlJ0-000204-Db; Sat, 09 May 2026 13:17:34 -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 1wLlIw-0001qE-OS for qemu-devel@nongnu.org; Sat, 09 May 2026 13:17:30 -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 1wLlIu-0005YF-TW for qemu-devel@nongnu.org; Sat, 09 May 2026 13:17:30 -0400 Received: from mx-prod-mc-01.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-508-sEyC3KEeONuqXR9QBMC2wQ-1; Sat, 09 May 2026 13:17:23 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A0EBF195608C; Sat, 9 May 2026 17:17:22 +0000 (UTC) Received: from localhost (unknown [10.44.24.4]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 496F21800352; Sat, 9 May 2026 17:17:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778347047; 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=t4Slxdzy3hL0v2brTM0N78PBrN0bU27hlHRoj2ilZ3M=; b=Wp3CNmNIBcuK8HLWuqa9w5ekFMVppKCaRTbrDw2X6UYexpjhRY3VNvmZQ0eT6CJ6Vf/Ruc FEP81n4QxJv6zPXzTY+0X33pzPVgJj1bfk9DXGIM8R29rSPeS/m4vraSjqZLIQrLKBjbRg su83dwdUfP0nVBLlkzCGB0VWKrqSMr4= X-MC-Unique: sEyC3KEeONuqXR9QBMC2wQ-1 X-Mimecast-MFC-AGG-ID: sEyC3KEeONuqXR9QBMC2wQ_1778347042 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, uchouT Subject: [PULL v2 33/33] qemu-options: document -chardev dbus Date: Sat, 9 May 2026 21:13:54 +0400 Message-ID: <20260509171356.1157879-34-marcandre.lureau@redhat.com> In-Reply-To: <20260509171356.1157879-1-marcandre.lureau@redhat.com> References: <20260509171356.1157879-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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: 1778347124304158500 From: uchouT Document the dbus backend introduced in commit 3e301c8d7ef0 ("ui/dbus: add chardev backend & interface") Signed-off-by: uchouT Reviewed-by: Marc-Andr=C3=A9 Lureau Message-ID: <20260509094801.111103-1-i@uchout.moe> --- qemu-options.hx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/qemu-options.hx b/qemu-options.hx index 5387bcd751b..96ae41f787b 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -4077,6 +4077,9 @@ DEF("chardev", HAS_ARG, QEMU_OPTION_chardev, #if defined(CONFIG_SPICE) "-chardev spicevmc,id=3Did,name=3Dname[,debug=3Ddebug][,logfile=3DPATH= ][,logappend=3Don|off]\n" "-chardev spiceport,id=3Did,name=3Dname[,debug=3Ddebug][,logfile=3DPAT= H][,logappend=3Don|off]\n" +#endif +#if defined(CONFIG_DBUS_DISPLAY) + "-chardev dbus,id=3Did,name=3Dname[,mux=3Don|off][,logfile=3DPATH][,lo= gappend=3Don|off]\n" #endif , QEMU_ARCH_ALL ) @@ -4088,8 +4091,8 @@ The general form of a character device option is: Backend is one of: ``null``, ``socket``, ``udp``, ``msmouse``, ``hub``, ``vc``, ``ringbuf``, ``file``, ``pipe``, ``console``, ``serial``, ``pty``, ``stdio``, ``braille``, ``parallel``, - ``spicevmc``, ``spiceport``. The specific backend will determine the - applicable options. + ``spicevmc``, ``spiceport``, ``dbus``. The specific backend will + determine the applicable options. =20 Use ``-chardev help`` to print all available chardev backend types. =20 @@ -4408,6 +4411,15 @@ The available backends are: =20 Connect to a spice port, allowing a Spice client to handle the traffic identified by a name (preferably a fqdn). + +``-chardev dbus,id=3Did,name=3Dname`` + ``dbus`` is only available when D-Bus display support is built in. + + ``name`` name of the chardev as exported on the D-Bus display + interface + + Export the character device on the D-Bus display interface, so that + a D-Bus client can connect to it. ERST =20 DEFHEADING() --=20 2.54.0