From nobody Thu Nov 28 10:40:55 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1693828498; cv=none; d=zohomail.com; s=zohoarc; b=UmNx/nYU4hSAT2AYG8+fkn4iwTr9cnXW/rhqfBz4vhemR/K7nPK8fc+eIZ+BLyXtIPu3L2C1n7nE4s8VJ99dR94Lt+/KTGjYZENWlURnYyMLqtfRcRXIg/q9wrYrI3RjcjoEhtzoyQddFujk05IfXXZ8xceliGT8Rg4wkGCZ01w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1693828498; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5hRDAfmk3NJflNLFML/RaKbqS0nIVKE/TBiTSoxHrVI=; b=S7u0IK7PI5z6Q3KkZuUlvh9FTcPSaL0QlS3iUcnRa3hZCW7juaABOEYaQP1puFFrHJsiJp7xyAU1rAur/wFJX29uZk/bEhIXPU1LdJQvyVDw8/TUY39JAyTlMwTc/ibDooxi9xK4jyPhhacBTR/J5THSH/o3QDvBfGNDao8zr8s= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1693828498316204.5302022895312; Mon, 4 Sep 2023 04:54:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qd8AF-0003uM-BB; Mon, 04 Sep 2023 07:54:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qd89q-0003Q3-Ki for qemu-devel@nongnu.org; Mon, 04 Sep 2023 07:54: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 1qd89o-0008U1-75 for qemu-devel@nongnu.org; Mon, 04 Sep 2023 07:54:18 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-456-s6ukda_nOfKHNXqW0BoETQ-1; Mon, 04 Sep 2023 07:54:14 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C8AD929DD98D for ; Mon, 4 Sep 2023 11:54:13 +0000 (UTC) Received: from localhost (unknown [10.39.208.42]) by smtp.corp.redhat.com (Postfix) with ESMTP id 817B5C124A; Mon, 4 Sep 2023 11:54:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693828455; 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=5hRDAfmk3NJflNLFML/RaKbqS0nIVKE/TBiTSoxHrVI=; b=fos7DQf6cRn0ZsLzJrkTaHSDAjGzLuSWe8B0qhFq3ptSNQwxgVHKKrBC3k72V/PclGYIOP slrAKe2kvLSHEFrzAXOfISH+nSzbIOLZCcMLpVJFgAaILgjNSLVMhbvktCplAjTiLqc9k/ 3yEbQwTK0ORq/9BwceNsSEclJ4KtcC4= X-MC-Unique: s6ukda_nOfKHNXqW0BoETQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann Subject: [PULL 20/52] ui/console: instantiate a specific console type Date: Mon, 4 Sep 2023 15:52:17 +0400 Message-ID: <20230904115251.4161397-21-marcandre.lureau@redhat.com> In-Reply-To: <20230904115251.4161397-1-marcandre.lureau@redhat.com> References: <20230904115251.4161397-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.1 on 10.11.54.5 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=lists.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: -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, 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_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1693828499272100001 From: Marc-Andr=C3=A9 Lureau This will allow to move code/data to the specific console types. Replace console_type_t with object type check. QemuConsole can be abstract. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Daniel P. Berrang=C3=A9 Message-Id: <20230830093843.3531473-21-marcandre.lureau@redhat.com> --- ui/console.c | 47 +++++++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/ui/console.c b/ui/console.c index 4ca5064cc9..dd8e8db525 100644 --- a/ui/console.c +++ b/ui/console.c @@ -71,17 +71,10 @@ enum TTYState { TTY_STATE_CSI, }; =20 -typedef enum { - GRAPHIC_CONSOLE, - TEXT_CONSOLE, - TEXT_CONSOLE_FIXED_SIZE -} console_type_t; - struct QemuConsole { Object parent; =20 int index; - console_type_t console_type; DisplayState *ds; DisplaySurface *surface; DisplayScanout scanout; @@ -126,7 +119,7 @@ struct QemuConsole { QTAILQ_ENTRY(QemuConsole) next; }; =20 -OBJECT_DEFINE_TYPE(QemuConsole, qemu_console, QEMU_CONSOLE, OBJECT) +OBJECT_DEFINE_ABSTRACT_TYPE(QemuConsole, qemu_console, QEMU_CONSOLE, OBJEC= T) =20 typedef struct QemuGraphicConsole { QemuConsole parent; @@ -1156,7 +1149,7 @@ void kbd_put_keysym_console(QemuConsole *s, int keysy= m) int c; uint32_t num_free; =20 - if (!s || (s->console_type =3D=3D GRAPHIC_CONSOLE)) + if (!s || QEMU_IS_GRAPHIC_CONSOLE(s)) return; =20 switch(keysym) { @@ -1258,7 +1251,7 @@ static void text_console_invalidate(void *opaque) { QemuConsole *s =3D (QemuConsole *) opaque; =20 - if (s->console_type =3D=3D TEXT_CONSOLE) { + if (QEMU_IS_TEXT_CONSOLE(s) && !QEMU_IS_FIXED_TEXT_CONSOLE(s)) { text_console_resize(s); } console_refresh(s); @@ -1294,20 +1287,19 @@ static void text_console_update(void *opaque, conso= le_ch_t *chardata) } =20 static void -qemu_console_register(QemuConsole *c, console_type_t console_type) +qemu_console_register(QemuConsole *c) { int i; =20 - if (!active_console || ((active_console->console_type !=3D GRAPHIC_CON= SOLE) && - (console_type =3D=3D GRAPHIC_CONSOLE))) { + if (!active_console || (!QEMU_IS_GRAPHIC_CONSOLE(active_console) && + QEMU_IS_GRAPHIC_CONSOLE(c))) { active_console =3D c; } - c->console_type =3D console_type; =20 if (QTAILQ_EMPTY(&consoles)) { c->index =3D 0; QTAILQ_INSERT_TAIL(&consoles, c, next); - } else if (console_type !=3D GRAPHIC_CONSOLE || phase_check(PHASE_MACH= INE_READY)) { + } else if (!QEMU_IS_GRAPHIC_CONSOLE(c) || phase_check(PHASE_MACHINE_RE= ADY)) { QemuConsole *last =3D QTAILQ_LAST(&consoles); c->index =3D last->index + 1; QTAILQ_INSERT_TAIL(&consoles, c, next); @@ -1320,11 +1312,10 @@ qemu_console_register(QemuConsole *c, console_type_= t console_type) */ QemuConsole *it =3D QTAILQ_FIRST(&consoles); =20 - while (QTAILQ_NEXT(it, next) !=3D NULL && - it->console_type =3D=3D GRAPHIC_CONSOLE) { + while (QTAILQ_NEXT(it, next) !=3D NULL && QEMU_IS_GRAPHIC_CONSOLE(= it)) { it =3D QTAILQ_NEXT(it, next); } - if (it->console_type =3D=3D GRAPHIC_CONSOLE) { + if (QEMU_IS_GRAPHIC_CONSOLE(it)) { /* have no text consoles */ c->index =3D it->index + 1; QTAILQ_INSERT_AFTER(&consoles, it, c, next); @@ -1422,14 +1413,14 @@ qemu_fixed_text_console_init(Object *obj) { } =20 -static QemuConsole *new_console(console_type_t console_type, +static QemuConsole *new_console(const char *typename, uint32_t head) { - QemuConsole *c =3D QEMU_CONSOLE(object_new(TYPE_QEMU_CONSOLE)); + QemuConsole *c =3D QEMU_CONSOLE(object_new(typename)); =20 c->head =3D head; /* TODO: move to console_init() once there is a type hierarchy */ - qemu_console_register(c, console_type); + qemu_console_register(c); =20 return c; } @@ -2211,7 +2202,7 @@ QemuConsole *graphic_console_init(DeviceState *dev, u= int32_t head, height =3D qemu_console_get_height(s, 0); } else { trace_console_gfx_new(); - s =3D new_console(GRAPHIC_CONSOLE, head); + s =3D new_console(TYPE_QEMU_GRAPHIC_CONSOLE, head); s->ui_timer =3D timer_new_ms(QEMU_CLOCK_REALTIME, dpy_set_ui_info_timer, s); } @@ -2345,7 +2336,7 @@ bool qemu_console_is_graphic(QemuConsole *con) if (con =3D=3D NULL) { con =3D active_console; } - return con && (con->console_type =3D=3D GRAPHIC_CONSOLE); + return con && QEMU_IS_GRAPHIC_CONSOLE(con); } =20 bool qemu_console_is_fixedsize(QemuConsole *con) @@ -2353,7 +2344,7 @@ bool qemu_console_is_fixedsize(QemuConsole *con) if (con =3D=3D NULL) { con =3D active_console; } - return con && (con->console_type !=3D TEXT_CONSOLE); + return con && (QEMU_IS_GRAPHIC_CONSOLE(con) || QEMU_IS_FIXED_TEXT_CONS= OLE(con)); } =20 bool qemu_console_is_gl_blocked(QemuConsole *con) @@ -2389,7 +2380,7 @@ bool qemu_console_is_multihead(DeviceState *dev) =20 char *qemu_console_get_label(QemuConsole *con) { - if (con->console_type =3D=3D GRAPHIC_CONSOLE) { + if (QEMU_IS_GRAPHIC_CONSOLE(con)) { if (con->device) { DeviceState *dev; bool multihead; @@ -2588,9 +2579,9 @@ static void vc_chr_open(Chardev *chr, =20 trace_console_txt_new(width, height); if (width =3D=3D 0 || height =3D=3D 0) { - s =3D new_console(TEXT_CONSOLE, 0); + s =3D new_console(TYPE_QEMU_TEXT_CONSOLE, 0); } else { - s =3D new_console(TEXT_CONSOLE_FIXED_SIZE, 0); + s =3D new_console(TYPE_QEMU_FIXED_TEXT_CONSOLE, 0); s->scanout.kind =3D SCANOUT_SURFACE; s->surface =3D qemu_create_displaysurface(width, height); } @@ -2610,7 +2601,7 @@ void qemu_console_resize(QemuConsole *s, int width, i= nt height) { DisplaySurface *surface =3D qemu_console_surface(s); =20 - assert(s->console_type =3D=3D GRAPHIC_CONSOLE); + assert(QEMU_IS_GRAPHIC_CONSOLE(s)); =20 if ((s->scanout.kind !=3D SCANOUT_SURFACE || (surface && surface->flags & QEMU_ALLOCATED_FLAG)) && --=20 2.41.0