From nobody Sun Feb 8 23:01:26 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1592757156; cv=none; d=zohomail.com; s=zohoarc; b=O0NbrpmOknJtO/oYq64nUIjWveceuZFXSi2xUFfvVuTbZOooqriE20tYTKfXccYnBh3b7zoBiHLXghA+quvMhwV/FNJsU7EDc9ZsdCxcd4I1dnj1k8DkyfNbI0Ri/ECMM4Dq19rJtqK5CdryO7BFBi3Bt1ej1X4HoQ3gEryN5e8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592757156; h=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=v/NS9YgRb0NXpU+G0HRMzylRBMOp+QQCcs98Z10vCR8=; b=aijvmX0bodYKy98CYhotDMzYSz03PaIWZKhUO/o9MG8rcmqvyh93s9lgMaQexANCJV/9rb65otYh+vVhWsq0hWekDJU6CRxyAMhfMcBsOJi1XugJ0EP1v/6mP4r2Kj6rudzSiZyWjDbU5UwNh2aDxOffptbNRUlLh4soweg9JrM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592757156264182.31076795304693; Sun, 21 Jun 2020 09:32:36 -0700 (PDT) Received: from localhost ([::1]:48202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jn2tW-0003OQ-FS for importer@patchew.org; Sun, 21 Jun 2020 12:32:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52582) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jn2jk-0006nh-40 for qemu-devel@nongnu.org; Sun, 21 Jun 2020 12:22:28 -0400 Received: from mail-lf1-x143.google.com ([2a00:1450:4864:20::143]:42323) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jn2ji-0007xW-Gp for qemu-devel@nongnu.org; Sun, 21 Jun 2020 12:22:27 -0400 Received: by mail-lf1-x143.google.com with SMTP id y13so8239858lfe.9 for ; Sun, 21 Jun 2020 09:22:26 -0700 (PDT) Received: from localhost.localdomain (193-239-39-51.ksi-system.net. [193.239.39.51]) by smtp.gmail.com with ESMTPSA id k7sm2822838lfd.67.2020.06.21.09.22.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jun 2020 09:22:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=v/NS9YgRb0NXpU+G0HRMzylRBMOp+QQCcs98Z10vCR8=; b=Fl6juc9m46LV+oHRHe9VO8kWadqNYGjqrFVuqvbQ/rXGkcpXT+TOYbbeKyp2u9GxW1 fQP6VJujj1I8RiE+gigLM3ZXVQKqLCBTq63nq9XwVBKT3vJNKHh1fxCKxg2Dmp4jbYYt G1mdP2YphL4alq1cj61tfYzW2KzpW7GAdu3dt4/F7xt6Yx3Pfmyivbgri7yETuvk1gTb +FqWtPmu6rITNDx2/XtE/iSrpDl+F+f8fnJaPBAMwC402QTZkKAtjkaxm6cMmaE0fpFk pbCMElfAzVaf38pALAQ00kp862El19ORcmRbzuAVvPczS2YrHR41ag06wfOzXLWoHLkF 2/yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=v/NS9YgRb0NXpU+G0HRMzylRBMOp+QQCcs98Z10vCR8=; b=YAMEv/gnM1JQ1MxtgKDpHpQreiwyqVKDPceCW1sS+HYFbusGcf3vbnE8HzvcjIqK1d YdPC2SsMUIZyMqUnl/M/0fH99vVCeSpA7cCXCZlVEK4QfTF8TimrZ9ZWbtRf28RNZLoJ 9lHMuWimZUlf/GXRdusVdIY6SyfNO184m0Uo8yPhkl1KhUR5XRnUHHE/X74iZyicSAQ3 ODPoJUOELhwkZg3X2fevsVDGM7M0TwF7CPNThdHLsWVmNvQNZ5g8tDA4Exks9wcTNejC hdnDff+2MuIgVm7njsxEpjkwtkCe+cESD2k1K2VaKUv+Fx0f6dZs3hbZEJPrTXenFSTE TFpw== X-Gm-Message-State: AOAM531xz8Z4vApC0Xpr6OFLRi2TXpHRGW2s6hPX29f1s80GBJ9Eon5Y cnsh0I9w/z22+Mna7B9ZBn2lcHFXFvbI9A== X-Google-Smtp-Source: ABdhPJxjOwNYgW7L8jvYte2Rm0tqVcFW7O3aNCX8qsjyRMEIOq/pCtzOE0/qSYra4cSKYIqpL0H86w== X-Received: by 2002:ac2:5a01:: with SMTP id q1mr7641227lfn.182.1592756544487; Sun, 21 Jun 2020 09:22:24 -0700 (PDT) From: Szymon Lukasz To: qemu-devel@nongnu.org Subject: [PATCH 1/6] main-loop: change the handling of SIGWINCH Date: Sun, 21 Jun 2020 18:21:27 +0200 Message-Id: <20200621162132.62797-2-noh4hss@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200621162132.62797-1-noh4hss@gmail.com> References: <20200621162132.62797-1-noh4hss@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::143; envelope-from=noh4hss@gmail.com; helo=mail-lf1-x143.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Mailman-Approved-At: Sun, 21 Jun 2020 12:30:17 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, amit@kernel.org, mst@redhat.com, Szymon Lukasz , marcandre.lureau@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Block SIGWINCH, so it is delivered only via signalfd. Install a handler that uses NotifierList to tell interested parties about SIGWINCH delivery. Signed-off-by: Szymon Lukasz --- include/qemu/main-loop.h | 4 ++++ ui/curses.c | 11 ++++++----- util/main-loop.c | 21 +++++++++++++++++++++ 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/include/qemu/main-loop.h b/include/qemu/main-loop.h index a6d20b0719..f27dba1fd8 100644 --- a/include/qemu/main-loop.h +++ b/include/qemu/main-loop.h @@ -325,4 +325,8 @@ typedef struct MainLoopPoll { void main_loop_poll_add_notifier(Notifier *notify); void main_loop_poll_remove_notifier(Notifier *notify); =20 +#ifndef _WIN32 +void sigwinch_add_notifier(Notifier *n); +#endif + #endif diff --git a/ui/curses.c b/ui/curses.c index a59b23a9cf..e5895d506f 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -34,6 +34,7 @@ #include =20 #include "qapi/error.h" +#include "qemu/main-loop.h" #include "qemu/module.h" #include "ui/console.h" #include "ui/input.h" @@ -146,7 +147,7 @@ static void curses_resize(DisplayChangeListener *dcl, } =20 #if !defined(_WIN32) && defined(SIGWINCH) && defined(KEY_RESIZE) -static volatile sig_atomic_t got_sigwinch; +static bool got_sigwinch; static void curses_winch_check(void) { struct winsize { @@ -169,17 +170,17 @@ static void curses_winch_check(void) invalidate =3D 1; } =20 -static void curses_winch_handler(int signum) +static void curses_winch_handler(Notifier *n, void *data) { got_sigwinch =3D true; } =20 static void curses_winch_init(void) { - struct sigaction old, winch =3D { - .sa_handler =3D curses_winch_handler, + static Notifier n =3D { + .notify =3D curses_winch_handler }; - sigaction(SIGWINCH, &winch, &old); + sigwinch_add_notifier(&n); } #else static void curses_winch_check(void) {} diff --git a/util/main-loop.c b/util/main-loop.c index eda63fe4e0..0f5c8f3af1 100644 --- a/util/main-loop.c +++ b/util/main-loop.c @@ -90,6 +90,7 @@ static int qemu_signal_init(Error **errp) sigaddset(&set, SIGIO); sigaddset(&set, SIGALRM); sigaddset(&set, SIGBUS); + sigaddset(&set, SIGWINCH); /* SIGINT cannot be handled via signalfd, so that ^C can be used * to interrupt QEMU when it is being run under gdb. SIGHUP and * SIGTERM are also handled asynchronously, even though it is not @@ -111,6 +112,26 @@ static int qemu_signal_init(Error **errp) return 0; } =20 +static NotifierList sigwinch_notifiers =3D + NOTIFIER_LIST_INITIALIZER(sigwinch_notifiers); + +static void sigwinch_handler(int signum) +{ + notifier_list_notify(&sigwinch_notifiers, NULL); +} + +void sigwinch_add_notifier(Notifier *n) +{ + if (notifier_list_empty(&sigwinch_notifiers)) { + struct sigaction action =3D { + .sa_handler =3D sigwinch_handler, + }; + sigaction(SIGWINCH, &action, NULL); + } + + notifier_list_add(&sigwinch_notifiers, n); +} + #else /* _WIN32 */ =20 static int qemu_signal_init(Error **errp) --=20 2.27.0 From nobody Sun Feb 8 23:01:26 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1592757357; cv=none; d=zohomail.com; s=zohoarc; b=fN/zaAqM2mrPQrFGSPEF5fVPSZQDYf+HGo/wHUfjASsTK7oKASWoPfzEZiuMetCfCKcuYzJ2cubW9zk8z+6xsn4t7qlBqkx/kLwMuYuV8MeqCsG17gNIuHAXx5bnpDSa1bUNQnQ5udFhXS4KMpCwRZsNNsxf/p8eoHzQYAgglng= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592757357; h=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=/OUUBKDsy3J40KxRYAgVxdYTHQyEXQLdkmrBWWB58eM=; b=Qds1au+tpf3vCGmQSg1CH1gxWBHzcd6YjI/BRV+dqmLbDgqEWimLw5GEIwGiRPWpA6X8mm72xud09kTi+xc5wVJwcAdia+JGX9OgD1xyBtyqnzDWk8r8CK1Rk5QTbMZtr3q3JKvlxXxyPstuAKvJCjRt9cSbjU/TwNyGLVLAx5k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592757357731599.9339594956504; Sun, 21 Jun 2020 09:35:57 -0700 (PDT) Received: from localhost ([::1]:56262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jn2wl-0007UH-43 for importer@patchew.org; Sun, 21 Jun 2020 12:35:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52604) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jn2jl-0006nu-A8 for qemu-devel@nongnu.org; Sun, 21 Jun 2020 12:22:29 -0400 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]:39370) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jn2jj-0007xk-4G for qemu-devel@nongnu.org; Sun, 21 Jun 2020 12:22:29 -0400 Received: by mail-lj1-x244.google.com with SMTP id a9so16628564ljn.6 for ; Sun, 21 Jun 2020 09:22:26 -0700 (PDT) Received: from localhost.localdomain (193-239-39-51.ksi-system.net. [193.239.39.51]) by smtp.gmail.com with ESMTPSA id k7sm2822838lfd.67.2020.06.21.09.22.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jun 2020 09:22:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/OUUBKDsy3J40KxRYAgVxdYTHQyEXQLdkmrBWWB58eM=; b=bxXxVtqdICCNBJooeKtTOAVbxF09EFlkmcc91+j6Vfdm6tyLqpisg8rfmHqJuG5c8Y +uGg95J2/4oVIc3KwsEEMj+EaJo0kVxjSNiBH6KR/2Q7IyX/Z2YPl5WPueXgdTJouxVc SXmR3Jo0JRX8OTzXHS2RlqPXmb3jr8xaolPTOr2VNeiQoA8qw1kKpJExP4kWIP8+EGyZ JTUzE8ZEbHYf7TQrAb93Duty03HuXSoThIBX7FaXbvABzqG3+M9jvga0HRNW50XuCzGT qIOcMeGq630VH85iRcNVmRlwvxPVTa4l50QSakut5zMUmC/LEIpp4YL/wszmIRIp3umc iXTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/OUUBKDsy3J40KxRYAgVxdYTHQyEXQLdkmrBWWB58eM=; b=CF+1mUf/e0zt0k7VLUOprtfrPVO0CfcsZZKwwnxsGPFnzxg0EiZIkhC47oRGJykqii w563IfQOYeW0lm9vnde5W8Ah3HNDTYglWZFivSkQBpYDo41T8yzuh4yJJ8wseDMGk4Qc sNds8P4K7dzAeuX1VelG860ARhP5qGmBtCzor/Cxd9yvi9sxoQml0l6UP+grK56vbaFM gtjPIdjUMfDNbxtNiLfrOrIMRMF4s+WwoHE5tRRwaCeKj+/NYVG/XUQpBzj+fudIrVXN WReJYS3xYJm022qGSjjE4tv3ee2Ws6YyZi97GVsZ+NtcBUQPA6TYgz91DAjoboIePFL9 rpWQ== X-Gm-Message-State: AOAM531LaIOM/pBqpwiuWfwYQ65lda8tRlwjBDUsCxvcBM3yJZYqBzDS ene3pfvfR8XsjF9AAaubmdJ1Qi7n41TUzQ== X-Google-Smtp-Source: ABdhPJzSF6MtMj7BLCiNjiE547hPSpF1EnOLo25k/zV1i7vpcXLAtXts/2GUdkVqSVQ19nf3M1xKfA== X-Received: by 2002:a2e:a58a:: with SMTP id m10mr6435806ljp.346.1592756545385; Sun, 21 Jun 2020 09:22:25 -0700 (PDT) From: Szymon Lukasz To: qemu-devel@nongnu.org Subject: [PATCH 2/6] chardev: add support for retrieving the terminal size Date: Sun, 21 Jun 2020 18:21:28 +0200 Message-Id: <20200621162132.62797-3-noh4hss@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200621162132.62797-1-noh4hss@gmail.com> References: <20200621162132.62797-1-noh4hss@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::244; envelope-from=noh4hss@gmail.com; helo=mail-lj1-x244.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Mailman-Approved-At: Sun, 21 Jun 2020 12:30:17 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, amit@kernel.org, mst@redhat.com, Szymon Lukasz , marcandre.lureau@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Extend the class of chardevs with a new function - chr_get_winsize. A chardev backend should implement if it is able to get the size of the connected terminal and can detect changes in the terminal size, i.e. if the backend cannot detect resizes it must not implement this (e.g. if we have a tty backend connected to some (pseudo)terminal there is no clean way to detect resizes since SIGWINCH is sent only for the controlling terminal). Signed-off-by: Szymon Lukasz --- chardev/char-fe.c | 11 +++++++++++ chardev/char-mux.c | 7 +++++++ include/chardev/char-fe.h | 11 +++++++++++ include/chardev/char.h | 1 + 4 files changed, 30 insertions(+) diff --git a/chardev/char-fe.c b/chardev/char-fe.c index f3530a90e6..802d3096cd 100644 --- a/chardev/char-fe.c +++ b/chardev/char-fe.c @@ -336,6 +336,17 @@ void qemu_chr_fe_set_echo(CharBackend *be, bool echo) } } =20 +int qemu_chr_fe_get_winsize(CharBackend *be, uint16_t *cols, uint16_t *row= s) +{ + Chardev *chr =3D be->chr; + + if (chr && CHARDEV_GET_CLASS(chr)->chr_get_winsize) { + return CHARDEV_GET_CLASS(chr)->chr_get_winsize(chr, cols, rows); + } + + return -1; +} + void qemu_chr_fe_set_open(CharBackend *be, int fe_open) { Chardev *chr =3D be->chr; diff --git a/chardev/char-mux.c b/chardev/char-mux.c index 46c44af67c..368ce2334e 100644 --- a/chardev/char-mux.c +++ b/chardev/char-mux.c @@ -293,6 +293,12 @@ static void mux_chr_update_read_handlers(Chardev *chr) chr->gcontext, true, false); } =20 +static int mux_chr_get_winsize(Chardev *chr, uint16_t *cols, uint16_t *row= s) +{ + MuxChardev *d =3D MUX_CHARDEV(chr); + return qemu_chr_fe_get_winsize(&d->chr, cols, rows); +} + void mux_set_focus(Chardev *chr, int focus) { MuxChardev *d =3D MUX_CHARDEV(chr); @@ -385,6 +391,7 @@ static void char_mux_class_init(ObjectClass *oc, void *= data) cc->chr_be_event =3D mux_chr_be_event; cc->chr_machine_done =3D open_muxes; cc->chr_update_read_handler =3D mux_chr_update_read_handlers; + cc->chr_get_winsize =3D mux_chr_get_winsize; } =20 static const TypeInfo char_mux_type_info =3D { diff --git a/include/chardev/char-fe.h b/include/chardev/char-fe.h index a553843364..b7943df93a 100644 --- a/include/chardev/char-fe.h +++ b/include/chardev/char-fe.h @@ -154,6 +154,17 @@ int qemu_chr_fe_wait_connected(CharBackend *be, Error = **errp); */ void qemu_chr_fe_set_echo(CharBackend *be, bool echo); =20 +/** + * qemu_chr_fe_get_winsize: + * @cols: the address for storing columns + * @rows: the address for storing rows + * + * Get the terminal size of the backend. + * + * Returns: 0 on success and < 0 on error + */ +int qemu_chr_fe_get_winsize(CharBackend *be, uint16_t *cols, uint16_t *row= s); + /** * qemu_chr_fe_set_open: * diff --git a/include/chardev/char.h b/include/chardev/char.h index 00589a6025..fb20707917 100644 --- a/include/chardev/char.h +++ b/include/chardev/char.h @@ -276,6 +276,7 @@ typedef struct ChardevClass { void (*chr_be_event)(Chardev *s, QEMUChrEvent event); /* Return 0 if succeeded, 1 if failed */ int (*chr_machine_done)(Chardev *chr); + int (*chr_get_winsize)(Chardev *chr, uint16_t *cols, uint16_t *rows); } ChardevClass; =20 Chardev *qemu_chardev_new(const char *id, const char *typename, --=20 2.27.0 From nobody Sun Feb 8 23:01:26 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1592757157; cv=none; d=zohomail.com; s=zohoarc; b=fOCv2OxPrI381ZymwsdIBho1eGpjMJUTjwg2JLF25kUwXIiVWh4aDU69o9kSPDTyaZrrizIKXTy8u4NWM6f8srtXqyypoEqNb4rO8cV+f1xbRNV5ahGimwvXmASEUb7WPJi8XkNPbLfxp0e58gECBTlQdhHaoBJfDOg+TNCOJR0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592757157; h=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=okjFI9L7TqZfHlM0DvNcdByQI8MQ8azG7lBbIRoFOgk=; b=FOxjozTXbCUlfrqjXM93Lj4AR3I8zCVR4nQiB4nGr0qazDQ+CJWL+/Cw0xVAgjmCMjYmn6r3NGw63+6+FWoJe+sjhblI7Vh/XTVDqvX61GGykt3JnUTesU1j9Emg3K3hdFRYtn1qXuHXaWoa9ObiZ6AfhMxmf9ylmgaI2mYyvgk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592757157860520.2220419576608; Sun, 21 Jun 2020 09:32:37 -0700 (PDT) Received: from localhost ([::1]:48350 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jn2tY-0003Th-GP for importer@patchew.org; Sun, 21 Jun 2020 12:32:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52618) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jn2jl-0006o2-U1 for qemu-devel@nongnu.org; Sun, 21 Jun 2020 12:22:29 -0400 Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]:35795) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jn2jk-0007xw-6F for qemu-devel@nongnu.org; Sun, 21 Jun 2020 12:22:29 -0400 Received: by mail-lj1-x243.google.com with SMTP id q19so16669149lji.2 for ; Sun, 21 Jun 2020 09:22:27 -0700 (PDT) Received: from localhost.localdomain (193-239-39-51.ksi-system.net. [193.239.39.51]) by smtp.gmail.com with ESMTPSA id k7sm2822838lfd.67.2020.06.21.09.22.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jun 2020 09:22:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=okjFI9L7TqZfHlM0DvNcdByQI8MQ8azG7lBbIRoFOgk=; b=VCjATV4f7DNanJ0h7Gd+kE/yqXYfWsKYXgVMoaL4e/53o5t4yrBeIR+uyRJxpOxzFK wSrLPxP2PQPhnyHvVEExhXfXbpIzfHafb6b5hyLY0T9dleK2yyRjRxsrr1UlEsZid+eK 7g+c/CFNymlv4aYkix/+JjtiiMY0ZrOK+DNIXx82RaCTSUWyFo/+U9wbrefCZ39Vl6+L QAfzDtqUsPvfB0ejtXrjms8p7gWeRJxgoBxzL4Hq0gfl2xYbJLNsMI307LMGMUFK5Wyb Zr14a70dZtE/01TwtiWKuH27tgWU50bVNf66rFbZrN0lBeYF7DK5imxF8BUbJ/Do7I0v lz9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=okjFI9L7TqZfHlM0DvNcdByQI8MQ8azG7lBbIRoFOgk=; b=GaGTGHTeSLCe61RIxEsS0bJMTp2Xf2X7gXGo5nFSAh/qprnMeKUDvAKmKkbBWmZzFR zeDng6swtxlUo5uY4BGKtKacYrxhZRdNE5/ZUbTgDMwzY+/+tzla3XhUTA05MtnNrIKX VCVyFCojlyD0kSsICVxpSRkRIeD6CIK81w3VHVh0xPxURhW00QwLRI9fBcbiLzY4HtLe 49nqxJlOgHM0uSdxJoEjfcKyVHS8VVAOVROVvs2AyLTr8P0T4g01oGPCX2yAjNiXGylL mLdjvykv0LwrteY0caP8nKR5b4TdUB1WU0ABAq7KFTHYzjHL4ByXYqTmHExw0f0wRv2Q Fb7Q== X-Gm-Message-State: AOAM533EHzb4ZfRyWeQcLTIManS4rfu+9IHRBDN4aOGV8nRfKU0UCFSM WB+OYcEuTHhTd4kdvnMsMin+rGo3MRsbng== X-Google-Smtp-Source: ABdhPJw2bFvwv+VOg9Tw0wjHjhRKKA3ADmfw5GGIX6uuS6w2CTjTnt0SA5BnunIhqVy9UHmEa0uG5g== X-Received: by 2002:a2e:8110:: with SMTP id d16mr6772025ljg.12.1592756546250; Sun, 21 Jun 2020 09:22:26 -0700 (PDT) From: Szymon Lukasz To: qemu-devel@nongnu.org Subject: [PATCH 3/6] chardev: add support for notifying about terminal resizes Date: Sun, 21 Jun 2020 18:21:29 +0200 Message-Id: <20200621162132.62797-4-noh4hss@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200621162132.62797-1-noh4hss@gmail.com> References: <20200621162132.62797-1-noh4hss@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::243; envelope-from=noh4hss@gmail.com; helo=mail-lj1-x243.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Mailman-Approved-At: Sun, 21 Jun 2020 12:30:17 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, amit@kernel.org, mst@redhat.com, Szymon Lukasz , marcandre.lureau@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Add a new chardev event, CHR_EVENT_RESIZE, which a backend should trigger if detects the size of the connected terminal changed. Signed-off-by: Szymon Lukasz --- backends/cryptodev-vhost-user.c | 1 + chardev/char.c | 1 + hw/block/vhost-user-blk.c | 1 + hw/char/terminal3270.c | 1 + hw/char/virtio-console.c | 1 + hw/ipmi/ipmi_bmc_extern.c | 1 + hw/usb/ccid-card-passthru.c | 1 + hw/usb/dev-serial.c | 1 + hw/usb/redirect.c | 1 + include/chardev/char.h | 1 + monitor/hmp.c | 1 + monitor/qmp.c | 1 + net/vhost-user.c | 1 + 13 files changed, 13 insertions(+) diff --git a/backends/cryptodev-vhost-user.c b/backends/cryptodev-vhost-use= r.c index 8b8cbc4223..bbf8ad426a 100644 --- a/backends/cryptodev-vhost-user.c +++ b/backends/cryptodev-vhost-user.c @@ -174,6 +174,7 @@ static void cryptodev_vhost_user_event(void *opaque, QE= MUChrEvent event) case CHR_EVENT_BREAK: case CHR_EVENT_MUX_IN: case CHR_EVENT_MUX_OUT: + case CHR_EVENT_RESIZE: /* Ignore */ break; } diff --git a/chardev/char.c b/chardev/char.c index e3051295ac..904f8bf6e3 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -74,6 +74,7 @@ void qemu_chr_be_event(Chardev *s, QEMUChrEvent event) case CHR_EVENT_BREAK: case CHR_EVENT_MUX_IN: case CHR_EVENT_MUX_OUT: + case CHR_EVENT_RESIZE: /* Ignore */ break; } diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index a00b854736..1a656a27c3 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -403,6 +403,7 @@ static void vhost_user_blk_event(void *opaque, QEMUChrE= vent event) case CHR_EVENT_BREAK: case CHR_EVENT_MUX_IN: case CHR_EVENT_MUX_OUT: + case CHR_EVENT_RESIZE: /* Ignore */ break; } diff --git a/hw/char/terminal3270.c b/hw/char/terminal3270.c index 2c47ebf007..eadccbb617 100644 --- a/hw/char/terminal3270.c +++ b/hw/char/terminal3270.c @@ -169,6 +169,7 @@ static void chr_event(void *opaque, QEMUChrEvent event) case CHR_EVENT_BREAK: case CHR_EVENT_MUX_IN: case CHR_EVENT_MUX_OUT: + case CHR_EVENT_RESIZE: /* Ignore */ break; } diff --git a/hw/char/virtio-console.c b/hw/char/virtio-console.c index 4f46753ea3..97b9240ef5 100644 --- a/hw/char/virtio-console.c +++ b/hw/char/virtio-console.c @@ -165,6 +165,7 @@ static void chr_event(void *opaque, QEMUChrEvent event) case CHR_EVENT_BREAK: case CHR_EVENT_MUX_IN: case CHR_EVENT_MUX_OUT: + case CHR_EVENT_RESIZE: /* Ignore */ break; } diff --git a/hw/ipmi/ipmi_bmc_extern.c b/hw/ipmi/ipmi_bmc_extern.c index f9a13e0a44..9562584309 100644 --- a/hw/ipmi/ipmi_bmc_extern.c +++ b/hw/ipmi/ipmi_bmc_extern.c @@ -439,6 +439,7 @@ static void chr_event(void *opaque, QEMUChrEvent event) case CHR_EVENT_BREAK: case CHR_EVENT_MUX_IN: case CHR_EVENT_MUX_OUT: + case CHR_EVENT_RESIZE: /* Ignore */ break; } diff --git a/hw/usb/ccid-card-passthru.c b/hw/usb/ccid-card-passthru.c index bb325dbc4a..3c26b16ed0 100644 --- a/hw/usb/ccid-card-passthru.c +++ b/hw/usb/ccid-card-passthru.c @@ -321,6 +321,7 @@ static void ccid_card_vscard_event(void *opaque, QEMUCh= rEvent event) case CHR_EVENT_MUX_IN: case CHR_EVENT_MUX_OUT: case CHR_EVENT_CLOSED: + case CHR_EVENT_RESIZE: /* Ignore */ break; } diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c index 7e50e3ba47..e8e960d0e6 100644 --- a/hw/usb/dev-serial.c +++ b/hw/usb/dev-serial.c @@ -507,6 +507,7 @@ static void usb_serial_event(void *opaque, QEMUChrEvent= event) break; case CHR_EVENT_MUX_IN: case CHR_EVENT_MUX_OUT: + case CHR_EVENT_RESIZE: /* Ignore */ break; } diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 417a60a2e6..b716c4fdd7 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -1383,6 +1383,7 @@ static void usbredir_chardev_event(void *opaque, QEMU= ChrEvent event) case CHR_EVENT_BREAK: case CHR_EVENT_MUX_IN: case CHR_EVENT_MUX_OUT: + case CHR_EVENT_RESIZE: /* Ignore */ break; } diff --git a/include/chardev/char.h b/include/chardev/char.h index fb20707917..c3d108ce82 100644 --- a/include/chardev/char.h +++ b/include/chardev/char.h @@ -22,6 +22,7 @@ typedef enum { CHR_EVENT_OPENED, /* new connection established */ CHR_EVENT_MUX_IN, /* mux-focus was set to this terminal */ CHR_EVENT_MUX_OUT, /* mux-focus will move on */ + CHR_EVENT_RESIZE, /* the terminal size of the chardev changed */ CHR_EVENT_CLOSED /* connection closed. NOTE: currently this event * is only bound to the read port of the chardev. * Normally the read port and write port of a diff --git a/monitor/hmp.c b/monitor/hmp.c index d598dd02bb..020be03d61 100644 --- a/monitor/hmp.c +++ b/monitor/hmp.c @@ -1373,6 +1373,7 @@ static void monitor_event(void *opaque, QEMUChrEvent = event) break; =20 case CHR_EVENT_BREAK: + case CHR_EVENT_RESIZE: /* Ignored */ break; } diff --git a/monitor/qmp.c b/monitor/qmp.c index d433ceae5b..58aecb475b 100644 --- a/monitor/qmp.c +++ b/monitor/qmp.c @@ -371,6 +371,7 @@ static void monitor_qmp_event(void *opaque, QEMUChrEven= t event) case CHR_EVENT_BREAK: case CHR_EVENT_MUX_IN: case CHR_EVENT_MUX_OUT: + case CHR_EVENT_RESIZE: /* Ignore */ break; } diff --git a/net/vhost-user.c b/net/vhost-user.c index 17532daaf3..e30cbe74bd 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -297,6 +297,7 @@ static void net_vhost_user_event(void *opaque, QEMUChrE= vent event) case CHR_EVENT_BREAK: case CHR_EVENT_MUX_IN: case CHR_EVENT_MUX_OUT: + case CHR_EVENT_RESIZE: /* Ignore */ break; } --=20 2.27.0 From nobody Sun Feb 8 23:01:26 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1592757362; cv=none; d=zohomail.com; s=zohoarc; b=graWPO7kO+tx7ho+uDpXAW5rpNChNmjhbtuuqq4qFEWlmsf7RpKDFb9YOHPjCizmS0hMV5syQLrXXCo12xFlg6RNFIJMFUlvdzBux1kPEMLzlG1VCZy56gCGb3MAL0ElNi9m3izPeY/8aX/P8rIoJCmmC66WnietCnBaKnPL+bg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592757362; h=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=IEq/0MOxjv3VFOKWXkmTsGCVmogmJmtEdGRs+jHMXjw=; b=TC2vnqq9d9OvrULOmgzWSg9CKyJiZ3wcOnQ1QgDIjpfFfxbsnnEGvXhIq+OsY4zudG6BCNJeEUSWTomjWIEs9Gk6JXT6cogD0dEjq6HZDTIy6glCeaXNlM5C/LGh/mOhv32K+94Cazsbe9J0YxUdhj/BvBCdb8shdjEw6fyCdxs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592757362587667.0102354440322; Sun, 21 Jun 2020 09:36:02 -0700 (PDT) Received: from localhost ([::1]:56354 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jn2wr-0007YC-Dy for importer@patchew.org; Sun, 21 Jun 2020 12:36:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52624) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jn2jm-0006oM-HQ for qemu-devel@nongnu.org; Sun, 21 Jun 2020 12:22:30 -0400 Received: from mail-lf1-x141.google.com ([2a00:1450:4864:20::141]:39411) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jn2jk-0007y5-RX for qemu-devel@nongnu.org; Sun, 21 Jun 2020 12:22:30 -0400 Received: by mail-lf1-x141.google.com with SMTP id d21so6150543lfb.6 for ; Sun, 21 Jun 2020 09:22:28 -0700 (PDT) Received: from localhost.localdomain (193-239-39-51.ksi-system.net. [193.239.39.51]) by smtp.gmail.com with ESMTPSA id k7sm2822838lfd.67.2020.06.21.09.22.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jun 2020 09:22:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IEq/0MOxjv3VFOKWXkmTsGCVmogmJmtEdGRs+jHMXjw=; b=JHa0a7RtIvGTH04Mx/wdFaOFP6HP8n5TGTfaM/T1khOVEKGx0OutBcrW5wEs6NLNOR Oz+1CgOTtFtsoWz03AcoYlzefkVBmuo8WjPmSs+Ekl57gjGAZx6OqDyAT682CkEEiBgT TEnDhkVKh9jgcBI/Ur7/n+m9togLJ8JNTAh0oT2dF0uq+c4pzFDtp9/sfgexvxCH1YD/ UHNmVNsOzjPY+ygCaXQgkRZT4Vo9HOrmJZ4C7dyinZsq0laYPy63Dej4bn7RdZi/jKAx Oj5x+4K9nvn7PVgB04gGwGY4XgpmjH+C43bwRHkgz9IOyWTfHH6Juzqjvp6VfNXh3Yt4 Fhag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IEq/0MOxjv3VFOKWXkmTsGCVmogmJmtEdGRs+jHMXjw=; b=hMLvwv1Wi2IrkmuGmAOs6fhcBsRYC55ZNy2v2pil43TQTRt4tMKOPUdN20y6k9ukzN MqgjpfXMNfnRK1mgQcaxVH5QwDRF0+kite6pdbGLdM8JXFsMatKMjldyV58qcuJddrfz dRiZrItUaUNZct01KZvYTRMdTXYDlz77bajRx00eEZX8/aQOEVZr/9zVxGfeKgHGiIMV QmQxiyljpPUQyZ3TaK+e0r/regvX+tXfwKLwAFIfzUFD2j4huWzNvuH244BrkxJvcbCT z1tTt//M1d+56y1EjGzgrcQybze1vxz7ka9EE3qoCxoPv0feesDFBCwOtsakRhcG/h4q cghQ== X-Gm-Message-State: AOAM533pOw/Rld4RMoYHEmse8CPpZLGYF8Op4QHH8kn7JfEQFu9J2mPv iFSx62sVTJjlmvSuqubw/lq+QZzowqghLw== X-Google-Smtp-Source: ABdhPJzX5BqFUfR4aULh0LWn1LwNtQo6oMqzC9MFspMJpEYEDSb54NLlNv+cQMPlbpwG+CCc2EWMVg== X-Received: by 2002:a19:7014:: with SMTP id h20mr7293458lfc.49.1592756547093; Sun, 21 Jun 2020 09:22:27 -0700 (PDT) From: Szymon Lukasz To: qemu-devel@nongnu.org Subject: [PATCH 4/6] char-stdio: add support for the terminal size Date: Sun, 21 Jun 2020 18:21:30 +0200 Message-Id: <20200621162132.62797-5-noh4hss@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200621162132.62797-1-noh4hss@gmail.com> References: <20200621162132.62797-1-noh4hss@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::141; envelope-from=noh4hss@gmail.com; helo=mail-lf1-x141.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Mailman-Approved-At: Sun, 21 Jun 2020 12:30:17 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, amit@kernel.org, mst@redhat.com, Szymon Lukasz , marcandre.lureau@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Implement chr_get_winsize for the stdio backend and trigger CHR_EVENT_RESIZE upon SIGWINCH delivery. Signed-off-by: Szymon Lukasz --- chardev/char-stdio.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/chardev/char-stdio.c b/chardev/char-stdio.c index 82eaebc1db..ab14edffc1 100644 --- a/chardev/char-stdio.c +++ b/chardev/char-stdio.c @@ -34,7 +34,9 @@ #include "chardev/char-win-stdio.h" #else #include +#include #include "chardev/char-fd.h" +#include "qemu/main-loop.h" #endif =20 #ifndef _WIN32 @@ -45,6 +47,13 @@ static bool stdio_in_use; static bool stdio_allow_signal; static bool stdio_echo_state; =20 +typedef struct { + FDChardev parent; + Notifier resize_notifier; +} StdioChardev; + +#define STDIO_CHARDEV(obj) OBJECT_CHECK(StdioChardev, (obj), TYPE_CHARDEV_= STDIO) + static void term_exit(void) { if (stdio_in_use) { @@ -82,11 +91,31 @@ static void term_stdio_handler(int sig) qemu_chr_set_echo_stdio(NULL, stdio_echo_state); } =20 +static int qemu_chr_get_winsize_stdio(Chardev *chr, uint16_t *cols, uint16= _t *rows) +{ + struct winsize ws; + + if (ioctl(1, TIOCGWINSZ, &ws) < 0) { + return -1; + } + + *cols =3D ws.ws_col; + *rows =3D ws.ws_row; + return 0; +} + +static void term_resize_notify(Notifier *n, void *data) +{ + StdioChardev *s =3D container_of(n, StdioChardev, resize_notifier); + qemu_chr_be_event(CHARDEV(s), CHR_EVENT_RESIZE); +} + static void qemu_chr_open_stdio(Chardev *chr, ChardevBackend *backend, bool *be_opened, Error **errp) { + StdioChardev *s =3D STDIO_CHARDEV(chr); ChardevStdio *opts =3D backend->u.stdio.data; struct sigaction act; =20 @@ -116,6 +145,9 @@ static void qemu_chr_open_stdio(Chardev *chr, stdio_allow_signal =3D opts->signal; } qemu_chr_set_echo_stdio(chr, false); + + s->resize_notifier.notify =3D term_resize_notify; + sigwinch_add_notifier(&s->resize_notifier); } #endif =20 @@ -139,6 +171,7 @@ static void char_stdio_class_init(ObjectClass *oc, void= *data) #ifndef _WIN32 cc->open =3D qemu_chr_open_stdio; cc->chr_set_echo =3D qemu_chr_set_echo_stdio; + cc->chr_get_winsize =3D qemu_chr_get_winsize_stdio; #endif } =20 @@ -155,6 +188,7 @@ static const TypeInfo char_stdio_type_info =3D { .parent =3D TYPE_CHARDEV_WIN_STDIO, #else .parent =3D TYPE_CHARDEV_FD, + .instance_size =3D sizeof(StdioChardev), #endif .instance_finalize =3D char_stdio_finalize, .class_init =3D char_stdio_class_init, --=20 2.27.0 From nobody Sun Feb 8 23:01:26 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1592757156; cv=none; d=zohomail.com; s=zohoarc; b=jvn1s3f8Wady2/g4sjzbOpjn3dodAv4JlGP7qlXGR+mHw/Fe9ldUEByxXW13nPJ9X80tCCFomXyyXifSu1rJgOXQI9rwwZOkQvUQGSw1uyWRAqko/cho2/G9bZt5UTliQnzvBN7ImnpqSmGlRX5pzcHTvBhjAz7rEgEdkooKTkI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592757156; h=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=Rhi9d3gdnSNNQEzJpih2aVZzubxIfPivq5heve4K+qc=; b=O0truoRKmuL2QOER7ULaYLGVxExIgnQHUA9PS94gxnwEahxylj9gspCNfBG9+TVFIVCGtLEDQT096SSzp0s31ysujyFBIVKFaXa3C2pNBpPXOqLvxsU+sCKjGoTWsRb36Guo6W7Wb1M3K4mZftM1LOlbmwkIEztxfF7JIjJcB/U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592757156328585.9274499330905; Sun, 21 Jun 2020 09:32:36 -0700 (PDT) Received: from localhost ([::1]:48262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jn2tW-0003Qt-Rc for importer@patchew.org; Sun, 21 Jun 2020 12:32:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52638) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jn2jn-0006of-G9 for qemu-devel@nongnu.org; Sun, 21 Jun 2020 12:22:31 -0400 Received: from mail-lj1-x241.google.com ([2a00:1450:4864:20::241]:44172) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jn2jl-0007yK-Q0 for qemu-devel@nongnu.org; Sun, 21 Jun 2020 12:22:31 -0400 Received: by mail-lj1-x241.google.com with SMTP id c17so16603308lji.11 for ; Sun, 21 Jun 2020 09:22:29 -0700 (PDT) Received: from localhost.localdomain (193-239-39-51.ksi-system.net. [193.239.39.51]) by smtp.gmail.com with ESMTPSA id k7sm2822838lfd.67.2020.06.21.09.22.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jun 2020 09:22:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Rhi9d3gdnSNNQEzJpih2aVZzubxIfPivq5heve4K+qc=; b=dqPAoFb3wpY0i7LWtq/TJypevTVup726EfStumvHkxhyyY0NqrUc1bg37+qKWjBUhi Vx4R8PrxAJi76j8dO5gIgf/uufvcXIb66yt7b/ZqebZXcAJ0oDgpFLC8u5BZO/S7loxr eFt1arpK4GURmfyhamj7NPaIxCyoPGc5IH8SmurqwgENna0fb4nqjkop7HMdlzNiHw+V zPI270AvcrDOKNMTRaCqBvPZ3rMJxnKBiM27zacvHso7Gbb0AoZu9aZhsKIWzUvCXRBy QtWZOhJCB2ps9fStqhIIPD1miPMzUvdyeeC0LBhaF7MbL8ugr3kzxDZgVvsoqRAfS0Vv fxBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Rhi9d3gdnSNNQEzJpih2aVZzubxIfPivq5heve4K+qc=; b=llaHPruqzymvAb0xvOaqPjqKdApiW8N+xD/3yMlaZcSlW9uYZ5oSsvqzZyh2oH2tsC znBcLGkqygNl4HSzv8ZCx2+JkY3T3eG+aiaC/B6vMRzYxU3J5T9pYUaMfb79atFtMLeR kaN5uFv8hvZxhqdRpa7dlXlgy5OeUJrw3x67tesnxSC352eQDfTW8BM96+uqQ8ITYk5I lDDZBDpcVtHXiXNB0BQDq7VcySbbpE8OfKRqeJCpwBJ5beyayPZLpaAq+GGrRSTnpAx3 2qmMCY0Ji2GwXjT72047PeSGZWGKdX03g1YOdA47DdCF9JXTbdwDZv/n3se1+MasSx0J c0EQ== X-Gm-Message-State: AOAM533n5uVdMvHZRdpwCxgrWVYof6tNP2XC192QCOZ1KTLh62kKPene tyJMrCSb0Q6402t3DIWeagUvqHCowDoK6w== X-Google-Smtp-Source: ABdhPJzpvOIAB9Dfu9gHwepdf2+AhVxXnyPIivRFTRLsz9ZC9IDQ+ra/sIxeGSKnrC8+aKUBYsHU0w== X-Received: by 2002:a2e:96da:: with SMTP id d26mr6622615ljj.25.1592756547948; Sun, 21 Jun 2020 09:22:27 -0700 (PDT) From: Szymon Lukasz To: qemu-devel@nongnu.org Subject: [PATCH 5/6] virtio-serial-bus: add terminal resize messages Date: Sun, 21 Jun 2020 18:21:31 +0200 Message-Id: <20200621162132.62797-6-noh4hss@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200621162132.62797-1-noh4hss@gmail.com> References: <20200621162132.62797-1-noh4hss@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::241; envelope-from=noh4hss@gmail.com; helo=mail-lj1-x241.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Mailman-Approved-At: Sun, 21 Jun 2020 12:30:17 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, amit@kernel.org, mst@redhat.com, Szymon Lukasz , marcandre.lureau@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Implement the part of the virtio spec that allows to notify the virtio driver about terminal resizes. The virtio spec contains two methods to achieve that: For legacy drivers, we have only one port and we put the terminal size in the config space and inject the config changed interrupt. For multiport devices, we use the control virtqueue to send a packet containing the terminal size. Note that the Linux kernel expects the fields indicating the number of rows and columns in a packet to be in a different order than the one specified in the current version of the virtio spec. We follow the Linux implementation, so hopefully there is no implementation of this functionality conforming to the spec. Signed-off-by: Szymon Lukasz --- hw/char/trace-events | 1 + hw/char/virtio-serial-bus.c | 41 +++++++++++++++++++++++++++++-- include/hw/virtio/virtio-serial.h | 5 ++++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/hw/char/trace-events b/hw/char/trace-events index d20eafd56f..be40df47ea 100644 --- a/hw/char/trace-events +++ b/hw/char/trace-events @@ -10,6 +10,7 @@ serial_ioport_write(uint16_t addr, uint8_t value) "write = addr 0x%02x val 0x%02x" =20 # virtio-serial-bus.c virtio_serial_send_control_event(unsigned int port, uint16_t event, uint16= _t value) "port %u, event %u, value %u" +virtio_serial_send_console_resize(unsigned int port, uint16_t cols, uint16= _t rows) "port %u, cols %u, rows %u" virtio_serial_throttle_port(unsigned int port, bool throttle) "port %u, th= rottle %d" virtio_serial_handle_control_message(uint16_t event, uint16_t value) "even= t %u, value %u" virtio_serial_handle_control_message_port(unsigned int port) "port %u" diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index 262089c0c9..9d99161e13 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -261,6 +261,42 @@ static size_t send_control_event(VirtIOSerial *vser, u= int32_t port_id, return send_control_msg(vser, &cpkt, sizeof(cpkt)); } =20 +/* + * This struct should be added to the Linux kernel uapi headers + * and later imported to standard-headers/linux/virtio_console.h + */ +struct virtio_console_resize { + __virtio16 rows; + __virtio16 cols; +}; + +void virtio_serial_send_console_resize(VirtIOSerialPort *port, + uint16_t cols, uint16_t rows) +{ + VirtIOSerial *vser =3D port->vser; + VirtIODevice *vdev =3D VIRTIO_DEVICE(vser); + + if (virtio_vdev_has_feature(vdev, VIRTIO_CONSOLE_F_MULTIPORT)) { + struct { + struct virtio_console_control control; + struct virtio_console_resize resize; + } buffer; + + virtio_stl_p(vdev, &buffer.control.id, port->id); + virtio_stw_p(vdev, &buffer.control.event, VIRTIO_CONSOLE_RESIZE); + virtio_stw_p(vdev, &buffer.resize.cols, cols); + virtio_stw_p(vdev, &buffer.resize.rows, rows); + + trace_virtio_serial_send_console_resize(port->id, cols, rows); + send_control_msg(vser, &buffer, sizeof(buffer)); + + } else if (virtio_vdev_has_feature(vdev, VIRTIO_CONSOLE_F_SIZE)) { + vser->port0_cols =3D cols; + vser->port0_rows =3D rows; + virtio_notify_config(vdev); + } +} + /* Functions for use inside qemu to open and read from/write to ports */ int virtio_serial_open(VirtIOSerialPort *port) { @@ -559,6 +595,7 @@ static uint64_t get_features(VirtIODevice *vdev, uint64= _t features, vser =3D VIRTIO_SERIAL(vdev); =20 features |=3D vser->host_features; + virtio_add_feature(&features, VIRTIO_CONSOLE_F_SIZE); if (vser->bus.max_nr_ports > 1) { virtio_add_feature(&features, VIRTIO_CONSOLE_F_MULTIPORT); } @@ -572,8 +609,8 @@ static void get_config(VirtIODevice *vdev, uint8_t *con= fig_data) struct virtio_console_config *config =3D (struct virtio_console_config *)config_data; =20 - config->cols =3D 0; - config->rows =3D 0; + config->cols =3D virtio_tswap16(vdev, vser->port0_cols); + config->rows =3D virtio_tswap16(vdev, vser->port0_rows); config->max_nr_ports =3D virtio_tswap32(vdev, vser->serial.max_virtserial_port= s); } diff --git a/include/hw/virtio/virtio-serial.h b/include/hw/virtio/virtio-s= erial.h index ed3e916b68..1d6436c0b1 100644 --- a/include/hw/virtio/virtio-serial.h +++ b/include/hw/virtio/virtio-serial.h @@ -188,6 +188,8 @@ struct VirtIOSerial { virtio_serial_conf serial; =20 uint64_t host_features; + + uint16_t port0_cols, port0_rows; }; =20 /* Interface to the virtio-serial bus */ @@ -222,6 +224,9 @@ size_t virtio_serial_guest_ready(VirtIOSerialPort *port= ); */ void virtio_serial_throttle_port(VirtIOSerialPort *port, bool throttle); =20 +void virtio_serial_send_console_resize(VirtIOSerialPort *port, + uint16_t cols, uint16_t rows); + #define TYPE_VIRTIO_SERIAL "virtio-serial-device" #define VIRTIO_SERIAL(obj) \ OBJECT_CHECK(VirtIOSerial, (obj), TYPE_VIRTIO_SERIAL) --=20 2.27.0 From nobody Sun Feb 8 23:01:26 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1592757363; cv=none; d=zohomail.com; s=zohoarc; b=ZaW+btjkOpGHVnMviz3JQnVksKG7aKvu+1LzzMSD4f+ATZtwtfvLgs2YZrkgEjSuPoFNvw2QTTHZvjwOeJqT2piTfshM6ri09ziEflNtqQd6pE4ZH9AJCbRUigt7lbOI4R9RBQPS9LNrWDP/1wIOumPgvCOK11suV924Lio8fZs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592757363; h=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=Q2aSrf1EjsOvJpOxHsvMeL3ETTLqp6nu/7mQtqEiP9s=; b=OIqeiCGwBjkh+CuDx2IrivNFN2ALVTDIoYXnzMlwTNwMF05rOikqSAo+/F5ETTJUS/TNwmnXYpYZP027ePp5ptNgnDPeDhw8PZfhZ7o7I2m4MD9mU4Ra4t6IM5DEvuL8QCgw9K3zGLwCraoPCgzmMH5weNOyNwm1JDs6b0uue90= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592757363273326.10084033653015; Sun, 21 Jun 2020 09:36:03 -0700 (PDT) Received: from localhost ([::1]:56440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jn2wr-0007af-Rs for importer@patchew.org; Sun, 21 Jun 2020 12:36:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52646) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jn2jo-0006ov-BW for qemu-devel@nongnu.org; Sun, 21 Jun 2020 12:22:32 -0400 Received: from mail-lf1-x142.google.com ([2a00:1450:4864:20::142]:43589) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jn2jm-0007yX-Nx for qemu-devel@nongnu.org; Sun, 21 Jun 2020 12:22:32 -0400 Received: by mail-lf1-x142.google.com with SMTP id g139so7439638lfd.10 for ; Sun, 21 Jun 2020 09:22:30 -0700 (PDT) Received: from localhost.localdomain (193-239-39-51.ksi-system.net. [193.239.39.51]) by smtp.gmail.com with ESMTPSA id k7sm2822838lfd.67.2020.06.21.09.22.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jun 2020 09:22:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Q2aSrf1EjsOvJpOxHsvMeL3ETTLqp6nu/7mQtqEiP9s=; b=H03A6ihttpKK3VflZUmPrTBPZbEJxZKofg5laNIMhTqWGQpwoXrRtbMNGhP/u+4JVy bds3YKL8pSfX9v8TF/vAWpwrKc9/c//3hywq2y1S1DVbmYsT5m48eCFbgGpyr+WlFsuJ Zb+jXeZIbnd/61y0IE1VS3Wjf22UcRRj1C/Lib4gmOEHcV2d7300aHUBk8xqBSAyMznf lDjEXNJIP66Rvs714CnQ115koMWDzBUVUY/DDDQSZqBGdnGyfTCcblH3AYWgUU5qCfmN 3QP5zF3HPxq762vxbY20iJmj682jCGqnkQoD1PEEvk1Yjpstn4wYGWsLqR2UPddAuFcd N/hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Q2aSrf1EjsOvJpOxHsvMeL3ETTLqp6nu/7mQtqEiP9s=; b=WnbQJKYBn4cLmleGAyC/8O18DMfpDw4qoDQy3AfINdqjxIZXx2++pG+5MJRrww9Zq0 c49eaG9FzNU/lFB9vKGYeFHoPionTcIIqzD9fx8Sfuuoevg2Z0jAhRzGKuZJC5pBLqC4 Lkw94SjComdYb1YhVaFnjz6mkW1ElKIDdGlUaS3K49P4JJ60JdiEN0cb5xEruroFeCMI myHuzwIVzioKdwMeoImgU2UUZw8tMt25gzUEmoKd/khEq7qpzkObqhC3Ay0OxeD3IjII sHHGTTucfPi4nGMLagbEpv9TAIhstTSC3su5qv0eKYWNC940OdjEDyojbabBmdjigE8G ct8Q== X-Gm-Message-State: AOAM532g8rzqMyyncyYZT+k1fF0K/FqFrHY7XMh0ivy5qSBj1a2rUrm6 PGDzNs9FrOTGR80jNuSEpUM2NOyFho5vpA== X-Google-Smtp-Source: ABdhPJx3pOxtSxnLFDrQOKItyvSoJmuOKWnZ51s+DP4Rf3ck+0Cp4aIl7KsD+14fp1yTqVNFM/u0+g== X-Received: by 2002:a05:6512:303:: with SMTP id t3mr7487637lfp.159.1592756548935; Sun, 21 Jun 2020 09:22:28 -0700 (PDT) From: Szymon Lukasz To: qemu-devel@nongnu.org Subject: [PATCH 6/6] virtio-console: notify the guest about terminal resizes Date: Sun, 21 Jun 2020 18:21:32 +0200 Message-Id: <20200621162132.62797-7-noh4hss@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200621162132.62797-1-noh4hss@gmail.com> References: <20200621162132.62797-1-noh4hss@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::142; envelope-from=noh4hss@gmail.com; helo=mail-lf1-x142.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Mailman-Approved-At: Sun, 21 Jun 2020 12:30:17 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, amit@kernel.org, mst@redhat.com, Szymon Lukasz , marcandre.lureau@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" If a virtio serial port is a console port forward terminal resize messages from the chardev backend to the guest. Signed-off-by: Szymon Lukasz --- hw/char/virtio-console.c | 64 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 4 deletions(-) diff --git a/hw/char/virtio-console.c b/hw/char/virtio-console.c index 97b9240ef5..1ea06aad08 100644 --- a/hw/char/virtio-console.c +++ b/hw/char/virtio-console.c @@ -29,6 +29,7 @@ typedef struct VirtConsole { =20 CharBackend chr; guint watch; + uint16_t cols, rows; } VirtConsole; =20 /* @@ -104,6 +105,36 @@ static ssize_t flush_buf(VirtIOSerialPort *port, return ret; } =20 +static void virtconsole_send_resize(VirtIOSerialPort *port) +{ + uint16_t cols, rows; + VirtConsole *vcon =3D VIRTIO_CONSOLE(port); + + /* + * We probably shouldn't send these messages before + * we told the guest it is a console port (which we do + * by sending VIRTIO_CONSOLE_CONSOLE_PORT message). + * Instead of adding a new field to the device state + * lets just use the guest_connected field for that purpose + * since the guest should not care about the terminal size + * before opening the port. + */ + if (!port->guest_connected) { + return; + } + + if (qemu_chr_fe_get_winsize(&vcon->chr, &cols, &rows) < 0) { + cols =3D 0; + rows =3D 0; + } + + if (cols !=3D vcon->cols || rows !=3D vcon->rows) { + vcon->cols =3D cols; + vcon->rows =3D rows; + virtio_serial_send_console_resize(port, cols, rows); + } +} + /* Callback function that's called when the guest opens/closes the port */ static void set_guest_connected(VirtIOSerialPort *port, int guest_connecte= d) { @@ -111,7 +142,9 @@ static void set_guest_connected(VirtIOSerialPort *port,= int guest_connected) DeviceState *dev =3D DEVICE(port); VirtIOSerialPortClass *k =3D VIRTIO_SERIAL_PORT_GET_CLASS(port); =20 - if (!k->is_console) { + if (k->is_console) { + virtconsole_send_resize(port); + } else { qemu_chr_fe_set_open(&vcon->chr, guest_connected); } =20 @@ -171,6 +204,22 @@ static void chr_event(void *opaque, QEMUChrEvent event) } } =20 +static void chr_event_console(void *opaque, QEMUChrEvent event) +{ + VirtConsole *vcon =3D opaque; + VirtIOSerialPort *port =3D VIRTIO_SERIAL_PORT(vcon); + + switch (event) { + case CHR_EVENT_OPENED: + case CHR_EVENT_RESIZE: + trace_virtio_console_chr_event(port->id, event); + virtconsole_send_resize(port); + break; + default: + break; + } +} + static int chr_be_change(void *opaque) { VirtConsole *vcon =3D opaque; @@ -179,7 +228,9 @@ static int chr_be_change(void *opaque) =20 if (k->is_console) { qemu_chr_fe_set_handlers(&vcon->chr, chr_can_read, chr_read, - NULL, chr_be_change, vcon, NULL, true); + chr_event_console, chr_be_change, + vcon, NULL, true); + virtconsole_send_resize(port); } else { qemu_chr_fe_set_handlers(&vcon->chr, chr_can_read, chr_read, chr_event, chr_be_change, vcon, NULL, fal= se); @@ -207,7 +258,7 @@ static void virtconsole_enable_backend(VirtIOSerialPort= *port, bool enable) VirtIOSerialPortClass *k =3D VIRTIO_SERIAL_PORT_GET_CLASS(port); =20 qemu_chr_fe_set_handlers(&vcon->chr, chr_can_read, chr_read, - k->is_console ? NULL : chr_event, + k->is_console ? chr_event_console : chr_e= vent, chr_be_change, vcon, NULL, false); } else { qemu_chr_fe_set_handlers(&vcon->chr, NULL, NULL, NULL, @@ -227,6 +278,11 @@ static void virtconsole_realize(DeviceState *dev, Erro= r **errp) return; } =20 + if (k->is_console) { + vcon->cols =3D (uint16_t) -1; + vcon->rows =3D (uint16_t) -1; + } + if (qemu_chr_fe_backend_connected(&vcon->chr)) { /* * For consoles we don't block guest data transfer just @@ -239,7 +295,7 @@ static void virtconsole_realize(DeviceState *dev, Error= **errp) */ if (k->is_console) { qemu_chr_fe_set_handlers(&vcon->chr, chr_can_read, chr_read, - NULL, chr_be_change, + chr_event_console, chr_be_change, vcon, NULL, true); virtio_serial_open(port); } else { --=20 2.27.0