From nobody Fri Apr 4 18:12:16 2025 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=1741156929; cv=none; d=zohomail.com; s=zohoarc; b=NZiZ2WnJF62FlSM5vlmVMipLz2u7aojAN4kOxWnzlNX4/U5pnlNx3ZsUDMhW8CZYphpb/Gmo4iswcgjQ/gknGCuTv4veA3OIS8nz2OQoCnow5iRD6R/h3Ym1ER06UbDsQLbEB2ke4BE/qNkD+gW8kAXhyEiRk1/SAL2HhNgtCN8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1741156929; 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=h6WtSV2HfPPKPY4jjs82QphitS5TNefKH9Qq4m892qg=; b=bXjqU3wk3nhFet6uz3Y5oRh7I++FIjHskffDj2LNCTHjiOpI9JkJOGJnpSTRxQo2XE8iT1QAmPB+30JTvj5LRdVS3GrDaMif9LCeH0O+wvsxB0eZxU4XaunXFVn7FJhxBtJHYY6kTBltJpadaYNvCMp7UXL5OyVEbehcEVNiE78= 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=<marcandre.lureau@redhat.com> (p=none dis=none) Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 174115692919238.90805214641455; Tue, 4 Mar 2025 22:42:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <qemu-devel-bounces@nongnu.org>) id 1tpiSC-0001Rn-TY; Wed, 05 Mar 2025 01:42:04 -0500 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 <marcandre.lureau@redhat.com>) id 1tpiS9-0001QW-Vr for qemu-devel@nongnu.org; Wed, 05 Mar 2025 01:42:02 -0500 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 <marcandre.lureau@redhat.com>) id 1tpiS8-0001hf-1l for qemu-devel@nongnu.org; Wed, 05 Mar 2025 01:42:01 -0500 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-373-BneeBSL_MI6McrXtG-zH-g-1; Wed, 05 Mar 2025 01:41:49 -0500 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 97B4E1801A09; Wed, 5 Mar 2025 06:41:48 +0000 (UTC) Received: from localhost (unknown [10.44.22.6]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C5DA4180049D; Wed, 5 Mar 2025 06:41:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741156919; 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=h6WtSV2HfPPKPY4jjs82QphitS5TNefKH9Qq4m892qg=; b=Mo9pMxXgWw9ATKSJ4OsD8qCkJjAd0zdn6bGhITUG/ROnkgwc2DwuaXwEuR3/re+eOb1Rl8 GO9GaOgbrI9pelNE12h1ZTZyKWBwbZLf7W4YmLVDxmux8SVq1I59LhiCjHgR9rW8J96AOi Ci5kTw7eZTp1VToxf+lPRjH/meel3OI= X-MC-Unique: BneeBSL_MI6McrXtG-zH-g-1 X-Mimecast-MFC-AGG-ID: BneeBSL_MI6McrXtG-zH-g_1741156908 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, Roman Penyaev <r.peniaev@gmail.com>, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com> Subject: [PULL 1/6] ui/console-vc: introduce parsing of the 'ESC ( <ch>' sequence Date: Wed, 5 Mar 2025 10:41:27 +0400 Message-ID: <20250305064132.87441-2-marcandre.lureau@redhat.com> In-Reply-To: <20250305064132.87441-1-marcandre.lureau@redhat.com> References: <20250305064132.87441-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=lists.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: -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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <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>, <mailto:qemu-devel-request@nongnu.org?subject=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: 1741156931300019000 From: Roman Penyaev <r.peniaev@gmail.com> This change introduces parsing of the 'ESC ( <ch>' sequence, which is supposed to change character set [1]. In the QEMU case, the introduced parsing logic does not actually change the character set, but simply parses the sequence and does not let output of a tool to be corrupted with leftovers: `top` sends 'ESC ( B', so if character sequence is not parsed correctly, chracter 'B' appears in the output: Btop - 11:08:42 up 5 min, 1 user, load average: 0BB Tasks:B 158 Btotal,B 1 Brunning,B 157 Bsleeping,B 0 BsBB %Cpu(s):B 0.0 Bus,B 0.0 Bsy,B 0.0 Bni,B 99.8 Bid,B 0.2 BB MiB Mem :B 7955.6 Btotal,B 7778.6 Bfree,B 79.6 BB MiB Swap:B 0.0 Btotal,B 0.0 Bfree,B 0.0 BB PID USER PR NI VIRT RES SHR S B B 735 root 20 0 9328 3540 3152 R B B 1 root 20 0 20084 10904 8404 S B B 2 root 20 0 0 0 0 S B [1] https://vt100.net/docs/vt100-ug/chapter3.html#SCS Signed-off-by: Roman Penyaev <r.peniaev@gmail.com> Cc: "Marc-Andr=C3=A9 Lureau" <marcandre.lureau@redhat.com> Cc: qemu-devel@nongnu.org Reviewed-by: Marc-Andr=C3=A9 Lureau <marcandre.lureau@redhat.com> Message-ID: <20250226075913.353676-2-r.peniaev@gmail.com> --- ui/console-vc.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ui/console-vc.c b/ui/console-vc.c index fe20579832..90ff0ffda8 100644 --- a/ui/console-vc.c +++ b/ui/console-vc.c @@ -42,6 +42,8 @@ enum TTYState { TTY_STATE_NORM, TTY_STATE_ESC, TTY_STATE_CSI, + TTY_STATE_G0, + TTY_STATE_G1, }; =20 typedef struct QemuTextConsole { @@ -694,6 +696,10 @@ static void vc_putchar(VCChardev *vc, int ch) vc->esc_params[i] =3D 0; vc->nb_esc_params =3D 0; vc->state =3D TTY_STATE_CSI; + } else if (ch =3D=3D '(') { + vc->state =3D TTY_STATE_G0; + } else if (ch =3D=3D ')') { + vc->state =3D TTY_STATE_G1; } else { vc->state =3D TTY_STATE_NORM; } @@ -844,6 +850,16 @@ static void vc_putchar(VCChardev *vc, int ch) } break; } + break; + case TTY_STATE_G0: /* set character sets */ + case TTY_STATE_G1: /* set character sets */ + switch (ch) { + case 'B': + /* Latin-1 map */ + break; + } + vc->state =3D TTY_STATE_NORM; + break; } } =20 --=20 2.47.0 From nobody Fri Apr 4 18:12:16 2025 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=1741156943; cv=none; d=zohomail.com; s=zohoarc; b=M62RyLje9XXS1di8BbuuzUB2vRVnEfkFrlgs2J3E+mTPT5nOHj2Hlu9Lqk4mv5NZGVpN04uh9X+HWRLcIqGCCOZfx6BHMOj8YoIWPCbi8y90dpdf7NCLTu7OMqlP/LB0necocDz9KEzudZ4tnG7nQyyqrSIDgFfyEkIZuC6o5RY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1741156943; 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=YKSkcRwm4AyX10dRmWZH8jGmnsqonQR9vc3Xrup2WzA=; b=kcdl9nVosC7vUZ26NfgKycLKSp0p3nsPxKDLQpJyRSMcHtwmchl141seiZPrgJai2VqhE6zgfjLvqaXPf1gDTXl2tqx9iDFQpmSDZLsHp0J1ozh3y3s5zra4eJ11SRKyz6x6UAcrkGwmM0+peneNH7nebMwSAI2y8EefiGXS2hA= 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=<marcandre.lureau@redhat.com> (p=none dis=none) Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1741156943661727.4167842480192; Tue, 4 Mar 2025 22:42:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <qemu-devel-bounces@nongnu.org>) id 1tpiSN-0001g8-V2; Wed, 05 Mar 2025 01:42:17 -0500 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 <marcandre.lureau@redhat.com>) id 1tpiSH-0001cf-MW for qemu-devel@nongnu.org; Wed, 05 Mar 2025 01:42:09 -0500 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 <marcandre.lureau@redhat.com>) id 1tpiSF-0001iD-RU for qemu-devel@nongnu.org; Wed, 05 Mar 2025 01:42:09 -0500 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-356-blGu2EOEOr29YxL9U1jU8g-1; Wed, 05 Mar 2025 01:41:59 -0500 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 D0214180AF57; Wed, 5 Mar 2025 06:41:57 +0000 (UTC) Received: from localhost (unknown [10.44.22.6]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E9170180035F; Wed, 5 Mar 2025 06:41:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741156926; 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=YKSkcRwm4AyX10dRmWZH8jGmnsqonQR9vc3Xrup2WzA=; b=HLMz3Med1a+Vg7ZORR3iQKiqkPwpWrFOEBuYbBP60cwo+2x8M5+F1TVkRnl9ACkSUrtiSz mDTb4V9dGpx47/ZqPP+HeZZY9fYSfTXOgWeBEKOa45J2w6sIFJVT3nzXNk1GMJqpjGan4s oH1d9V6x8204Ongc3v0qBTijSSyhS4M= X-MC-Unique: blGu2EOEOr29YxL9U1jU8g-1 X-Mimecast-MFC-AGG-ID: blGu2EOEOr29YxL9U1jU8g_1741156918 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, Roman Penyaev <r.peniaev@gmail.com>, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com> Subject: [PULL 2/6] ui/console-vc: report to the application instead of screen rendering Date: Wed, 5 Mar 2025 10:41:28 +0400 Message-ID: <20250305064132.87441-3-marcandre.lureau@redhat.com> In-Reply-To: <20250305064132.87441-1-marcandre.lureau@redhat.com> References: <20250305064132.87441-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 127.0.0.2 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_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <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>, <mailto:qemu-devel-request@nongnu.org?subject=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: 1741156945363019000 From: Roman Penyaev <r.peniaev@gmail.com> Terminal Device Status Report (DSR) [1] should be sent to an application, not rendered to the screen. This patch fixes rendering of terminal report, which appear only on the graphical screen of the terminal (console "vc") and can be reproduced by the following command: echo -en '\e[6n'; IFS=3D'[;' read -sdR _ row col; echo $row:$col Command requests cursor position and waits for terminal response, but instead, the response is rendered to the graphical screen and never sent to an application. Why bother? Busybox shell (ash) in Alpine distribution requests cursor position on each shell prompt (once <ENTER> is pressed), which makes a prompt on a graphical screen corrupted with repeating Cursor Position Report (CPR) [2]: [root@alpine ~]# \033[57;1R] Which is very annoying and incorrect. [1] https://vt100.net/docs/vt100-ug/chapter3.html#DSR [2] https://vt100.net/docs/vt100-ug/chapter3.html#CPR Signed-off-by: Roman Penyaev <r.peniaev@gmail.com> Cc: "Marc-Andr=C3=A9 Lureau" <marcandre.lureau@redhat.com> Cc: qemu-devel@nongnu.org Reviewed-by: Marc-Andr=C3=A9 Lureau <marcandre.lureau@redhat.com> Message-ID: <20250226075913.353676-3-r.peniaev@gmail.com> --- ui/console-vc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ui/console-vc.c b/ui/console-vc.c index 90ff0ffda8..d512f57e10 100644 --- a/ui/console-vc.c +++ b/ui/console-vc.c @@ -617,10 +617,9 @@ static void vc_put_one(VCChardev *vc, int ch) =20 static void vc_respond_str(VCChardev *vc, const char *buf) { - while (*buf) { - vc_put_one(vc, *buf); - buf++; - } + QemuTextConsole *s =3D vc->console; + + qemu_chr_be_write(s->chr, (const uint8_t *)buf, strlen(buf)); } =20 /* set cursor, checking bounds */ --=20 2.47.0 From nobody Fri Apr 4 18:12:16 2025 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=1741156949; cv=none; d=zohomail.com; s=zohoarc; b=D+XgEudHxkGb6P9N8sgOTSXVTv5ZlaA3DR+ulr4PDPbciZ7lj4qQd58AxlBOWthv5bAj34KDidajCONmaz8N1fCVVTFf15c02b2cbj9WPKF/91FPbNKyk52L0Ra+B3pEsTIIa7a4ImqjobbncUq4VrxZMOsBTenIjXgPEybW3yg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1741156949; 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=J00pWuUnTDd4NWy1BuTvnygaDXlsFJHg+/zKXZfp87g=; b=Yndea8z6MI16fJ0jUwu2pjsd1rIYq3XgJI1x5uD/GYtvM6QaqXpYPcAKGAHRb0qm3SjBVYOM4NWSg1P9PH30Ik4CMTitHn5SgLAFEfXTGGmSrS4v8oz55sKEBzuZ/c4Jk5x3bWUF78ySQB7EgsWNGFn/tw6kVMNEYeeWRLUvYaM= 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=<marcandre.lureau@redhat.com> (p=none dis=none) Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1741156949941343.09294428879593; Tue, 4 Mar 2025 22:42:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <qemu-devel-bounces@nongnu.org>) id 1tpiSV-0001oQ-W2; Wed, 05 Mar 2025 01:42:24 -0500 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 <marcandre.lureau@redhat.com>) id 1tpiSS-0001kj-5d for qemu-devel@nongnu.org; Wed, 05 Mar 2025 01:42:21 -0500 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 <marcandre.lureau@redhat.com>) id 1tpiSQ-0001jD-L4 for qemu-devel@nongnu.org; Wed, 05 Mar 2025 01:42:19 -0500 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-61-Tw9pfuRAMcGVKM9LDnQlmQ-1; Wed, 05 Mar 2025 01:42:06 -0500 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 C73FC19560B2; Wed, 5 Mar 2025 06:42:05 +0000 (UTC) Received: from localhost (unknown [10.44.22.6]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E1A031954B32; Wed, 5 Mar 2025 06:42:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741156937; 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=J00pWuUnTDd4NWy1BuTvnygaDXlsFJHg+/zKXZfp87g=; b=irIQ/APy29AfnUfv09iChPAmqy214MYkeJvuxbHG23Ma4P6pszvRXmC91CW3FzmnUf8uGk pzqJuNDyXhXgotWfsdZnrt1ks91F7HxINFRkAA14H9DnslN1gsKucsMq2GxjtrOzWs0Nz2 ML5BORCTF0fqhi3Z15SmmOCaY5pABS8= X-MC-Unique: Tw9pfuRAMcGVKM9LDnQlmQ-1 X-Mimecast-MFC-AGG-ID: Tw9pfuRAMcGVKM9LDnQlmQ_1741156925 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, Roman Penyaev <r.peniaev@gmail.com>, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com> Subject: [PULL 3/6] ui/console-vc: report cursor position in the screen not in the scroll buffer Date: Wed, 5 Mar 2025 10:41:29 +0400 Message-ID: <20250305064132.87441-4-marcandre.lureau@redhat.com> In-Reply-To: <20250305064132.87441-1-marcandre.lureau@redhat.com> References: <20250305064132.87441-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.40 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.129.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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <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>, <mailto:qemu-devel-request@nongnu.org?subject=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: 1741156951394019000 From: Roman Penyaev <r.peniaev@gmail.com> The format of the CSI cursor position report is `ESC[row;columnR`, where `row` is a row of a cursor in the screen, not in the scrollback buffer. What's the difference? Let's say the terminal screen has 24 lines, no matter how long the scrollback buffer may be, the last line is the 24th. For example the following command can be executed in xterm on the last screen line: $ echo -en '\e[6n'; IFS=3D'[;' read -sdR _ row col; echo $row:$col 24:1 It shows the cursor position on the current screen and not relative to the backscroll buffer. Before this change the row number was always increasing for the QEMU VC and represents the cursor position relative to the backscroll buffer. Signed-off-by: Roman Penyaev <r.peniaev@gmail.com> Cc: "Marc-Andr=C3=A9 Lureau" <marcandre.lureau@redhat.com> Cc: qemu-devel@nongnu.org Reviewed-by: Marc-Andr=C3=A9 Lureau <marcandre.lureau@redhat.com> Message-ID: <20250226075913.353676-4-r.peniaev@gmail.com> --- ui/console-vc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ui/console-vc.c b/ui/console-vc.c index d512f57e10..87f57f1c52 100644 --- a/ui/console-vc.c +++ b/ui/console-vc.c @@ -827,8 +827,7 @@ static void vc_putchar(VCChardev *vc, int ch) case 6: /* report cursor position */ response =3D g_strdup_printf("\033[%d;%dR", - (s->y_base + s->y) % s->total_height + 1, - s->x + 1); + s->y + 1, s->x + 1); vc_respond_str(vc, response); break; } --=20 2.47.0 From nobody Fri Apr 4 18:12:16 2025 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=1741156975; cv=none; d=zohomail.com; s=zohoarc; b=aHfLr88UXKSTRdulwqVpBED2EO0riacPGFeF/HWx0JMMs597q8yd75DOOUGUWvREqYC84caK+d1fxrbmdYsHcjd4PIllD+hJtROymgbHrMRafEk0ikodgz/Ue1Hg6vBApFuvylvD+oUQvSz8mCItQXmiAtFHQvG91mRdsXbdUlg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1741156975; 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=iHQd6FI+FUaBqzjC9oXg2i3EXTXL8SbQgqa1BG4fkPM=; b=GznKy+FpYIuwKjC1yOg49kxoNscZF+KqMHW6ZQgKE7CGTGKlnCzwOMpwZb5TUmZHTviJt8m69udz4hsvWp2MBp9SlKNus6ZfXnfbWgwDnik172x9LrbmTVcI1+6kg/vlQFc3qsnG6Q4LsuPlBarLHPeVefDwqjYVArFDWtUslb8= 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=<marcandre.lureau@redhat.com> (p=none dis=none) Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1741156975034114.5958791002057; Tue, 4 Mar 2025 22:42:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <qemu-devel-bounces@nongnu.org>) id 1tpiSd-00024I-F1; Wed, 05 Mar 2025 01:42:31 -0500 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 <marcandre.lureau@redhat.com>) id 1tpiSW-0001pG-RN for qemu-devel@nongnu.org; Wed, 05 Mar 2025 01:42:25 -0500 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 <marcandre.lureau@redhat.com>) id 1tpiSV-0001k0-2N for qemu-devel@nongnu.org; Wed, 05 Mar 2025 01:42:24 -0500 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-568-9n3wgY-bOeGXwr8zFyLUCg-1; Wed, 05 Mar 2025 01:42:13 -0500 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 D73B61955BC5; Wed, 5 Mar 2025 06:42:12 +0000 (UTC) Received: from localhost (unknown [10.44.22.6]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7AF2A1800266; Wed, 5 Mar 2025 06:42:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741156942; 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=iHQd6FI+FUaBqzjC9oXg2i3EXTXL8SbQgqa1BG4fkPM=; b=GTJDfFder85Zzk2hCbuzbtBw4D64ypgCa458i0zrFE7ohJIbtog2Ofwgul4C4ObsQc9Kml XfHNgHB6vQ2hnsMmT7dZ6hCz8P6n+d0BqO6hShPrW0sWzHZKoHrgUjNx1H+WJf0MfHlv4c XtXi+fhfuCCPszlqBKnWbZPmqDsJBt0= X-MC-Unique: 9n3wgY-bOeGXwr8zFyLUCg-1 X-Mimecast-MFC-AGG-ID: 9n3wgY-bOeGXwr8zFyLUCg_1741156933 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, Roman Penyaev <r.peniaev@gmail.com>, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com> Subject: [PULL 4/6] ui/console-vc: add support for cursor DECSC and DECRC commands Date: Wed, 5 Mar 2025 10:41:30 +0400 Message-ID: <20250305064132.87441-5-marcandre.lureau@redhat.com> In-Reply-To: <20250305064132.87441-1-marcandre.lureau@redhat.com> References: <20250305064132.87441-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 127.0.0.2 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_H2=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <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>, <mailto:qemu-devel-request@nongnu.org?subject=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: 1741156975464019000 From: Roman Penyaev <r.peniaev@gmail.com> There are aliases for save and restore cursor commands: * save cursor `ESC 7` (DEC Save Cursor [1], older VT100) `ESC [ s` (CSI Save Cursor, standard ANSI) * load cursor `ESC 8` (DEC Restore Cursor [2], older VT100) `ESC [ u` (CSI Restore Cursor, standard ANSI) This change introduces older DEC sequencies for compatibility with some scripts (for example [3]) and tools. This change also adds saving and restoring of character attributes, which is according to the VT spec [1][2] [1] https://vt100.net/docs/vt510-rm/DECSC.html [2] https://vt100.net/docs/vt510-rm/DECRC.html [3] https://wiki.archlinux.org/title/Working_with_the_serial_console#Resizi= ng_a_terminal Signed-off-by: Roman Penyaev <r.peniaev@gmail.com> Cc: "Marc-Andr=C3=A9 Lureau" <marcandre.lureau@redhat.com> Cc: qemu-devel@nongnu.org Reviewed-by: Marc-Andr=C3=A9 Lureau <marcandre.lureau@redhat.com> Message-ID: <20250226075913.353676-5-r.peniaev@gmail.com> --- ui/console-vc.c | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/ui/console-vc.c b/ui/console-vc.c index 87f57f1c52..522adc2806 100644 --- a/ui/console-vc.c +++ b/ui/console-vc.c @@ -90,6 +90,7 @@ struct VCChardev { int esc_params[MAX_ESC_PARAMS]; int nb_esc_params; TextAttributes t_attrib; /* currently active text attributes */ + TextAttributes t_attrib_saved; int x_saved, y_saved; }; typedef struct VCChardev VCChardev; @@ -644,6 +645,31 @@ static void vc_set_cursor(VCChardev *vc, int x, int y) s->y =3D y; } =20 +/** + * vc_save_cursor() - saves cursor position and character attributes. + */ +static void vc_save_cursor(VCChardev *vc) +{ + QemuTextConsole *s =3D vc->console; + + vc->x_saved =3D s->x; + vc->y_saved =3D s->y; + vc->t_attrib_saved =3D vc->t_attrib; +} + +/** + * vc_restore_cursor() - restores cursor position and character + * attributes from saved state. + */ +static void vc_restore_cursor(VCChardev *vc) +{ + QemuTextConsole *s =3D vc->console; + + s->x =3D vc->x_saved; + s->y =3D vc->y_saved; + vc->t_attrib =3D vc->t_attrib_saved; +} + static void vc_putchar(VCChardev *vc, int ch) { QemuTextConsole *s =3D vc->console; @@ -699,6 +725,12 @@ static void vc_putchar(VCChardev *vc, int ch) vc->state =3D TTY_STATE_G0; } else if (ch =3D=3D ')') { vc->state =3D TTY_STATE_G1; + } else if (ch =3D=3D '7') { + vc_save_cursor(vc); + vc->state =3D TTY_STATE_NORM; + } else if (ch =3D=3D '8') { + vc_restore_cursor(vc); + vc->state =3D TTY_STATE_NORM; } else { vc->state =3D TTY_STATE_NORM; } @@ -833,14 +865,10 @@ static void vc_putchar(VCChardev *vc, int ch) } break; case 's': - /* save cursor position */ - vc->x_saved =3D s->x; - vc->y_saved =3D s->y; + vc_save_cursor(vc); break; case 'u': - /* restore cursor position */ - s->x =3D vc->x_saved; - s->y =3D vc->y_saved; + vc_restore_cursor(vc); break; default: trace_console_putchar_unhandled(ch); --=20 2.47.0 From nobody Fri Apr 4 18:12:16 2025 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=1741156993; cv=none; d=zohomail.com; s=zohoarc; b=G0C10IPVLZVQ6akS+tdUTL6MpbocEIyMgfM+ztYM5Kh4EusKBbknko5g0elq/QtvwayTmqD8ThEN6DEcA6V8NLMoun18xMlYSV6Uq91dUuoY7V/jMvjhxAnLD2BzCf1jNIoIviNFxUes4l+8MdxeBI3NuMcaGBPgEcc4GnGS5d8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1741156993; 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=szKeHw66OQkf06T76hhF4jCCjbkVTQWsajG2ol3iiB8=; b=nA04BnG0B/EaXXDIzcXeDYFyKvwvsJILRDZL2EIxCMLLOsjj80H1+m5bk4N3cPoGI8hEub+qD1DU72+w6ZXWjnAYY/1iJZAA1jCz4k3Vc59ayqxyu7XIUGuTQTIuKtGOPCKM3/qGB5kS0uuTbGxREy/56CN9sCrjBWbKnzeDfiQ= 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=<marcandre.lureau@redhat.com> (p=none dis=none) Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1741156993121697.3013252208831; Tue, 4 Mar 2025 22:43:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <qemu-devel-bounces@nongnu.org>) id 1tpiSi-0002Ep-TU; Wed, 05 Mar 2025 01:42:36 -0500 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 <marcandre.lureau@redhat.com>) id 1tpiSc-00024H-GL for qemu-devel@nongnu.org; Wed, 05 Mar 2025 01:42:31 -0500 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 <marcandre.lureau@redhat.com>) id 1tpiSa-0001ke-Id for qemu-devel@nongnu.org; Wed, 05 Mar 2025 01:42:30 -0500 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-299-c_WY4-k-PPeQ1yU7Ua8EuQ-1; Wed, 05 Mar 2025 01:42:21 -0500 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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A4FD319560A1; Wed, 5 Mar 2025 06:42:20 +0000 (UTC) Received: from localhost (unknown [10.44.22.6]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9FBC11944EAA; Wed, 5 Mar 2025 06:42:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741156947; 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=szKeHw66OQkf06T76hhF4jCCjbkVTQWsajG2ol3iiB8=; b=ZxYz2xfPJ56rCck6hTUSCTPahR0t5QV9A7uM4CTxPzk6VNIW2ML8UT/iHu3Hto1vXR1/we 16uCFOXrIwjDA5FVWMk2+Of7VjVwzLcTPRPQynd8vtlsPHKkLFMQTaowt1SGUOs0OeGn8w 0wWfVddmYAylXit848FNwSxtTXZFxG8= X-MC-Unique: c_WY4-k-PPeQ1yU7Ua8EuQ-1 X-Mimecast-MFC-AGG-ID: c_WY4-k-PPeQ1yU7Ua8EuQ_1741156940 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, Roman Penyaev <r.peniaev@gmail.com>, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com> Subject: [PULL 5/6] ui/console-vc: implement DCH (delete) and ICH (insert) commands Date: Wed, 5 Mar 2025 10:41:31 +0400 Message-ID: <20250305064132.87441-6-marcandre.lureau@redhat.com> In-Reply-To: <20250305064132.87441-1-marcandre.lureau@redhat.com> References: <20250305064132.87441-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=lists.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: -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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <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>, <mailto:qemu-devel-request@nongnu.org?subject=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: 1741156993592019000 From: Roman Penyaev <r.peniaev@gmail.com> This patch implements DCH (delete character) and ICH (insert character) commands. DCH - Delete Character: "As characters are deleted, the remaining characters between the cursor and right margin move to the left. Character attributes move with the characters. The terminal adds blank spaces with no visual character attributes at the right margin. DCH has no effect outside the scrolling margins" [1]. ICH - Insert Character: "The ICH sequence inserts Pn blank characters with the normal 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. ICH has no effect outside the scrolling margins" [2]. Without these commands console is barely usable. [1] https://vt100.net/docs/vt510-rm/DCH.html [1] https://vt100.net/docs/vt510-rm/ICH.html Signed-off-by: Roman Penyaev <r.peniaev@gmail.com> Cc: "Marc-Andr=C3=A9 Lureau" <marcandre.lureau@redhat.com> Cc: qemu-devel@nongnu.org Reviewed-by: Marc-Andr=C3=A9 Lureau <marcandre.lureau@redhat.com> Message-ID: <20250226075913.353676-6-r.peniaev@gmail.com> --- ui/console-vc.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/ui/console-vc.c b/ui/console-vc.c index 522adc2806..df1341513d 100644 --- a/ui/console-vc.c +++ b/ui/console-vc.c @@ -645,6 +645,88 @@ static void vc_set_cursor(VCChardev *vc, int x, int y) s->y =3D y; } =20 +/** + * 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 vc_csi_P(struct VCChardev *vc, unsigned int nr) +{ + QemuTextConsole *s =3D vc->console; + TextCell *c1, *c2; + unsigned int x1, x2, y; + unsigned int end, len; + + if (!nr) { + nr =3D 1; + } + if (nr > s->width - s->x) { + nr =3D s->width - s->x; + if (!nr) { + return; + } + } + + x1 =3D s->x; + x2 =3D s->x + nr; + len =3D s->width - x2; + if (len) { + y =3D (s->y_base + s->y) % s->total_height; + c1 =3D &s->cells[y * s->width + x1]; + c2 =3D &s->cells[y * s->width + x2]; + memmove(c1, c2, len * sizeof(*c1)); + for (end =3D x1 + len; x1 < end; x1++) { + vc_update_xy(vc, x1, s->y); + } + } + /* Clear the rest */ + for (; x1 < s->width; x1++) { + vc_clear_xy(vc, x1, s->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 vc_csi_at(struct VCChardev *vc, unsigned int nr) +{ + QemuTextConsole *s =3D vc->console; + TextCell *c1, *c2; + unsigned int x1, x2, y; + unsigned int end, len; + + if (!nr) { + nr =3D 1; + } + if (nr > s->width - s->x) { + nr =3D s->width - s->x; + if (!nr) { + return; + } + } + + x1 =3D s->x + nr; + x2 =3D s->x; + len =3D s->width - x1; + if (len) { + y =3D (s->y_base + s->y) % s->total_height; + c1 =3D &s->cells[y * s->width + x1]; + c2 =3D &s->cells[y * s->width + x2]; + memmove(c1, c2, len * sizeof(*c1)); + for (end =3D x1 + len; x1 < end; x1++) { + vc_update_xy(vc, x1, s->y); + } + } + /* Insert blanks */ + for (x1 =3D s->x; x1 < s->x + nr; x1++) { + vc_clear_xy(vc, x1, s->y); + } +} + /** * vc_save_cursor() - saves cursor position and character attributes. */ @@ -847,6 +929,9 @@ static void vc_putchar(VCChardev *vc, int ch) break; } break; + case 'P': + vc_csi_P(vc, vc->esc_params[0]); + break; case 'm': vc_handle_escape(vc); break; @@ -870,6 +955,9 @@ static void vc_putchar(VCChardev *vc, int ch) case 'u': vc_restore_cursor(vc); break; + case '@': + vc_csi_at(vc, vc->esc_params[0]); + break; default: trace_console_putchar_unhandled(ch); break; --=20 2.47.0 From nobody Fri Apr 4 18:12:16 2025 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=1741156993; cv=none; d=zohomail.com; s=zohoarc; b=gNBvewjlQGg+Dcr8TL0WnSTQeGpXo7m/WLbJn76hFUS8bpoNbq6IDu4QlrJ5LRgYCTn2HdqGY5WC6XgTc0YU/Lp9mofDSFTrWqxSmmVQynE/BOGG0/qfI6EtSInGM7x7RF4g/aeIbhaQ2PKxhCb6rp3wSfUZ8xrtA+yFJqcC7Qo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1741156993; 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=9W1tJivdWNPooAUuBUtSOede854BhYMCV5PWynoL1ok=; b=g9qmXtlSYo89gY72uGZtBnM3yGL+LBEacGFbeA+gmoeSZFq+Q1yXzKY/vyWCWzJDIt7HD8SrOfP1W9DzIPx3xym23a1sPxG8q1H2HNG2oz7sknrcayGyGkUCvEWgjrEx5k5Dyc2d0XmnBw92KEfWAIWRJDnNaTUe6WVFEXNB5kY= 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=<marcandre.lureau@redhat.com> (p=none dis=none) Return-Path: <qemu-devel-bounces+importer=patchew.org@nongnu.org> Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1741156993318321.2670317640001; Tue, 4 Mar 2025 22:43:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <qemu-devel-bounces@nongnu.org>) id 1tpiT5-0002yV-2n; Wed, 05 Mar 2025 01:43:01 -0500 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 <marcandre.lureau@redhat.com>) id 1tpiSv-0002lU-Qa for qemu-devel@nongnu.org; Wed, 05 Mar 2025 01:42:50 -0500 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 <marcandre.lureau@redhat.com>) id 1tpiSt-0001lL-PN for qemu-devel@nongnu.org; Wed, 05 Mar 2025 01:42:49 -0500 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-549-aFa4LCzmNFCr0Hk-Hoix2A-1; Wed, 05 Mar 2025 01:42:29 -0500 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 727FD1955BC5; Wed, 5 Mar 2025 06:42:28 +0000 (UTC) Received: from localhost (unknown [10.44.22.6]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A0AAF180049D; Wed, 5 Mar 2025 06:42:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741156967; 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=9W1tJivdWNPooAUuBUtSOede854BhYMCV5PWynoL1ok=; b=fWEfTzmOuhUD/bbGjBLcf5B60Q5DWP2EC+Z4agnqzfiFUyRCa1tSaYC2Fd5MCIkifmsu+u mA+Ytwzq+B9PV7dcj6yVV4N6U4TWzY5qB3Xoi7CeIKURt8+meFCeXeQj54hA/KF5BdTDoo KxTcDyo4bck5VWT2QBnUTjtaG8wVbcE= X-MC-Unique: aFa4LCzmNFCr0Hk-Hoix2A-1 X-Mimecast-MFC-AGG-ID: aFa4LCzmNFCr0Hk-Hoix2A_1741156948 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, Haoqian He <haoqian.he@smartx.com>, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>, Paolo Bonzini <pbonzini@redhat.com> Subject: [PULL 6/6] chardev: use remoteAddr if the chardev is client Date: Wed, 5 Mar 2025 10:41:32 +0400 Message-ID: <20250305064132.87441-7-marcandre.lureau@redhat.com> In-Reply-To: <20250305064132.87441-1-marcandre.lureau@redhat.com> References: <20250305064132.87441-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=lists.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: -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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <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>, <mailto:qemu-devel-request@nongnu.org?subject=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: 1741156995357019100 From: Haoqian He <haoqian.he@smartx.com> If the chardev is client, the socket file path in localAddr may be NULL. This is because the socket path comes from getsockname(), according to man page, getsockname() returns the current address bound by the socket sockfd. If the chardev is client, it's socket is unbound sockfd. Therefore, when computing the client chardev socket file path, using remoteAddr is more appropriate. Signed-off-by: Haoqian He <haoqian.he@smartx.com> Acked-by: Marc-Andr=C3=A9 Lureau <marcandre.lureau@redhat.com> Message-ID: <20250225104526.2924175-1-haoqian.he@smartx.com> --- chardev/char-socket.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 91496ceda9..2f842f9f88 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -571,9 +571,13 @@ static char *qemu_chr_compute_filename(SocketChardev *= s) =20 switch (ss->ss_family) { case AF_UNIX: - return g_strdup_printf("unix:%s%s", - ((struct sockaddr_un *)(ss))->sun_path, - s->is_listen ? ",server=3Don" : ""); + if (s->is_listen) { + return g_strdup_printf("unix:%s,server=3Don", + ((struct sockaddr_un *)(ss))->sun_path); + } else { + return g_strdup_printf("unix:%s", + ((struct sockaddr_un *)(ps))->sun_path); + } case AF_INET6: left =3D "["; right =3D "]"; --=20 2.47.0