{"id":2226212,"url":"http://patchwork.ozlabs.org/api/patches/2226212/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260422104042.3936506-16-marcandre.lureau@redhat.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260422104042.3936506-16-marcandre.lureau@redhat.com>","list_archive_url":null,"date":"2026-04-22T10:40:16","name":"[PULL,15/40] ui/console: dispatch get_label() through QOM virtual method","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"59fa24a951443c2e259332a1beda7fb2011fa513","submitter":{"id":66774,"url":"http://patchwork.ozlabs.org/api/people/66774/?format=json","name":"Marc-André Lureau","email":"marcandre.lureau@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260422104042.3936506-16-marcandre.lureau@redhat.com/mbox/","series":[{"id":500973,"url":"http://patchwork.ozlabs.org/api/series/500973/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=500973","date":"2026-04-22T10:40:02","name":"[PULL,01/40] ui/input-linux: close evdev fd when qemu_set_blocking fails","version":1,"mbox":"http://patchwork.ozlabs.org/series/500973/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2226212/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2226212/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=K7ciPqBQ;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g0wm63J7vz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 20:42:46 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wFV2U-0006fo-9O; Wed, 22 Apr 2026 06:42:38 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <marcandre.lureau@redhat.com>)\n id 1wFV2N-000676-2W\n for qemu-devel@nongnu.org; Wed, 22 Apr 2026 06:42:33 -0400","from us-smtp-delivery-124.mimecast.com ([170.10.133.124])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <marcandre.lureau@redhat.com>)\n id 1wFV2J-0002bi-8T\n for qemu-devel@nongnu.org; Wed, 22 Apr 2026 06:42:30 -0400","from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com\n (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by\n relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n cipher=TLS_AES_256_GCM_SHA384) id us-mta-526-Sj7Vx2BCMfiB3pFDpd-V2w-1; Wed,\n 22 Apr 2026 06:42:22 -0400","from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com\n (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS\n id C89261956095; Wed, 22 Apr 2026 10:42:21 +0000 (UTC)","from localhost (unknown [10.44.22.21])\n by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP\n id 5FAA919560AB; Wed, 22 Apr 2026 10:42:19 +0000 (UTC)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1776854546;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=pdPo0VF+rmFefq/Qp3UuNmLrEm9l8ULREvMW1s7C/OA=;\n b=K7ciPqBQSdXMU62nubXAI0FxHH+Sa5+xkMKwYVOh9A2VYw4J2R30Wk/DQB5TqXAGln324C\n r0yz2XnYFbmHkvNQJ5wYzZ2ECZnIVmH82gsesaT3SvBrWEsG//BKOLpnVBoUmQXlpJ++zM\n oPsELxWNJO0DM9oKUMLBtDJWTNSJT7c=","X-MC-Unique":"Sj7Vx2BCMfiB3pFDpd-V2w-1","X-Mimecast-MFC-AGG-ID":"Sj7Vx2BCMfiB3pFDpd-V2w_1776854541","From":"marcandre.lureau@redhat.com","To":"qemu-devel@nongnu.org","Cc":"peter.maydell@linaro.org,\n =?utf-8?q?Marc-Andr=C3=A9_Lureau?= <marcandre.lureau@redhat.com>","Subject":"[PULL 15/40] ui/console: dispatch get_label() through QOM virtual\n method","Date":"Wed, 22 Apr 2026 14:40:16 +0400","Message-ID":"<20260422104042.3936506-16-marcandre.lureau@redhat.com>","In-Reply-To":"<20260422104042.3936506-1-marcandre.lureau@redhat.com>","References":"<20260422104042.3936506-1-marcandre.lureau@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","X-Scanned-By":"MIMEDefang 3.0 on 10.30.177.12","Received-SPF":"pass client-ip=170.10.133.124;\n envelope-from=marcandre.lureau@redhat.com;\n helo=us-smtp-delivery-124.mimecast.com","X-Spam_score_int":"-20","X-Spam_score":"-2.1","X-Spam_bar":"--","X-Spam_report":"(-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001,\n SPF_PASS=-0.001 autolearn=ham autolearn_force=no","X-Spam_action":"no action","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"qemu development <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"From: Marc-André Lureau <marcandre.lureau@redhat.com>\n\nReplace the type-checking chain in qemu_console_get_label() (using\nQEMU_IS_GRAPHIC_CONSOLE/QEMU_IS_TEXT_CONSOLE) with a QemuConsoleClass\nvirtual method, allowing each console subclass to provide its own\nget_label implementation.\n\nReviewed-by: Daniel P. Berrangé <berrange@redhat.com>\nReviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>\nSigned-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>\n---\n include/ui/console.h  |   2 +\n ui/console-priv.h     |   1 -\n ui/console-vc-stubs.c |   6 ---\n ui/console-vc.c       |  12 +++--\n ui/console.c          | 101 ++++++++++++++++++++++--------------------\n 5 files changed, 65 insertions(+), 57 deletions(-)","diff":"diff --git a/include/ui/console.h b/include/ui/console.h\nindex 08082389f71..788ff103ada 100644\n--- a/include/ui/console.h\n+++ b/include/ui/console.h\n@@ -129,6 +129,8 @@ void console_handle_touch_event(QemuConsole *con,\n \n struct QemuConsoleClass {\n     ObjectClass parent_class;\n+\n+    char * (*get_label)(const QemuConsole *con);\n };\n \n typedef struct ScanoutTexture {\ndiff --git a/ui/console-priv.h b/ui/console-priv.h\nindex 43ceb8122f1..2c2cfd99570 100644\n--- a/ui/console-priv.h\n+++ b/ui/console-priv.h\n@@ -36,7 +36,6 @@ struct QemuConsole {\n };\n \n void qemu_text_console_update_size(QemuTextConsole *c);\n-const char * qemu_text_console_get_label(QemuTextConsole *c);\n void qemu_text_console_update_cursor(void);\n void qemu_text_console_handle_keysym(QemuTextConsole *s, int keysym);\n \ndiff --git a/ui/console-vc-stubs.c b/ui/console-vc-stubs.c\nindex b63e2fb2345..8a7f19c1f44 100644\n--- a/ui/console-vc-stubs.c\n+++ b/ui/console-vc-stubs.c\n@@ -14,12 +14,6 @@ void qemu_text_console_update_size(QemuTextConsole *c)\n {\n }\n \n-const char *\n-qemu_text_console_get_label(QemuTextConsole *c)\n-{\n-    return NULL;\n-}\n-\n void qemu_text_console_update_cursor(void)\n {\n }\ndiff --git a/ui/console-vc.c b/ui/console-vc.c\nindex 0881a2148c1..ce35abaf402 100644\n--- a/ui/console-vc.c\n+++ b/ui/console-vc.c\n@@ -122,10 +122,12 @@ static const pixman_color_t color_table_rgb[2][8] = {\n static bool cursor_visible_phase;\n static QEMUTimer *cursor_timer;\n \n-const char *\n-qemu_text_console_get_label(QemuTextConsole *c)\n+static char *\n+qemu_text_console_get_label(const QemuConsole *c)\n {\n-    return c->chr ? c->chr->label : NULL;\n+    QemuTextConsole *tc = QEMU_TEXT_CONSOLE(c);\n+\n+    return tc->chr ? g_strdup(tc->chr->label) : NULL;\n }\n \n static void qemu_console_fill_rect(QemuConsole *con, int posx, int posy,\n@@ -1053,9 +1055,13 @@ qemu_text_console_finalize(Object *obj)\n static void\n qemu_text_console_class_init(ObjectClass *oc, const void *data)\n {\n+    QemuConsoleClass *cc = QEMU_CONSOLE_CLASS(oc);\n+\n     if (!cursor_timer) {\n         cursor_timer = timer_new_ms(QEMU_CLOCK_REALTIME, cursor_timer_cb, NULL);\n     }\n+\n+    cc->get_label = qemu_text_console_get_label;\n }\n \n static const GraphicHwOps text_console_ops = {\ndiff --git a/ui/console.c b/ui/console.c\nindex f445db11389..beaef4ad8b8 100644\n--- a/ui/console.c\n+++ b/ui/console.c\n@@ -436,9 +436,58 @@ qemu_graphic_console_prop_get_head(Object *obj, Visitor *v, const char *name,\n     visit_type_uint32(v, name, &c->head, errp);\n }\n \n+static bool\n+qemu_graphic_console_is_multihead(QemuGraphicConsole *c)\n+{\n+    QemuConsole *con;\n+\n+    QTAILQ_FOREACH(con, &consoles, next) {\n+        QemuGraphicConsole *candidate;\n+\n+        if (!QEMU_IS_GRAPHIC_CONSOLE(con)) {\n+            continue;\n+        }\n+\n+        candidate = QEMU_GRAPHIC_CONSOLE(con);\n+        if (candidate->device != c->device) {\n+            continue;\n+        }\n+\n+        if (candidate->head != c->head) {\n+            return true;\n+        }\n+    }\n+    return false;\n+}\n+\n+static char *\n+qemu_graphic_console_get_label(const QemuConsole *con)\n+{\n+    QemuGraphicConsole *c = QEMU_GRAPHIC_CONSOLE(con);\n+\n+    if (c->device) {\n+        DeviceState *dev;\n+        bool multihead;\n+\n+        dev = DEVICE(c->device);\n+        multihead = qemu_graphic_console_is_multihead(c);\n+        if (multihead) {\n+            return g_strdup_printf(\"%s.%d\", dev->id ?\n+                                   dev->id :\n+                                   object_get_typename(c->device),\n+                                   c->head);\n+        } else {\n+            return g_strdup(dev->id ? : object_get_typename(c->device));\n+        }\n+    }\n+    return g_strdup(\"VGA\");\n+}\n+\n static void\n qemu_graphic_console_class_init(ObjectClass *oc, const void *data)\n {\n+    QemuConsoleClass *cc = QEMU_CONSOLE_CLASS(oc);\n+\n     object_class_property_add_link(oc, \"device\", TYPE_DEVICE,\n                                    offsetof(QemuGraphicConsole, device),\n                                    object_property_allow_set_link,\n@@ -446,6 +495,8 @@ qemu_graphic_console_class_init(ObjectClass *oc, const void *data)\n     object_class_property_add(oc, \"head\", \"uint32\",\n                               qemu_graphic_console_prop_get_head,\n                               NULL, NULL, NULL);\n+\n+    cc->get_label = qemu_graphic_console_get_label;\n }\n \n static void\n@@ -1347,56 +1398,12 @@ bool qemu_console_is_gl_blocked(QemuConsole *con)\n     return con->gl_block;\n }\n \n-static bool qemu_graphic_console_is_multihead(QemuGraphicConsole *c)\n-{\n-    QemuConsole *con;\n-\n-    QTAILQ_FOREACH(con, &consoles, next) {\n-        QemuGraphicConsole *candidate;\n-\n-        if (!QEMU_IS_GRAPHIC_CONSOLE(con)) {\n-            continue;\n-        }\n-\n-        candidate = QEMU_GRAPHIC_CONSOLE(con);\n-        if (candidate->device != c->device) {\n-            continue;\n-        }\n-\n-        if (candidate->head != c->head) {\n-            return true;\n-        }\n-    }\n-    return false;\n-}\n-\n char *qemu_console_get_label(QemuConsole *con)\n {\n-    if (QEMU_IS_GRAPHIC_CONSOLE(con)) {\n-        QemuGraphicConsole *c = QEMU_GRAPHIC_CONSOLE(con);\n-        if (c->device) {\n-            DeviceState *dev;\n-            bool multihead;\n-\n-            dev = DEVICE(c->device);\n-            multihead = qemu_graphic_console_is_multihead(c);\n-            if (multihead) {\n-                return g_strdup_printf(\"%s.%d\", dev->id ?\n-                                       dev->id :\n-                                       object_get_typename(c->device),\n-                                       c->head);\n-            } else {\n-                return g_strdup(dev->id ? : object_get_typename(c->device));\n-            }\n-        }\n-        return g_strdup(\"VGA\");\n-    } else if (QEMU_IS_TEXT_CONSOLE(con)) {\n-        const char *label = qemu_text_console_get_label(QEMU_TEXT_CONSOLE(con));\n-        if (label) {\n-            return g_strdup(label);\n-        }\n+    char *label = QEMU_CONSOLE_GET_CLASS(con)->get_label(con);\n+    if (label) {\n+        return label;\n     }\n-\n     return g_strdup_printf(\"vc%d\", con->index);\n }\n \n","prefixes":["PULL","15/40"]}