From nobody Tue Nov 4 15:26:28 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530216635698542.5974184557381; Thu, 28 Jun 2018 13:10:35 -0700 (PDT) Received: from localhost ([::1]:38302 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdFS-0002tr-TY for importer@patchew.org; Thu, 28 Jun 2018 16:10:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37782) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYdAN-00072v-8i for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYdAL-0008Qk-VB for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:19 -0400 Received: from mail-wr0-x229.google.com ([2a00:1450:400c:c0c::229]:41886) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYdAL-0008Ou-NS for qemu-devel@nongnu.org; Thu, 28 Jun 2018 16:05:17 -0400 Received: by mail-wr0-x229.google.com with SMTP id h10-v6so6671295wrq.8 for ; Thu, 28 Jun 2018 13:05:17 -0700 (PDT) Received: from 640k.lan ([82.84.124.111]) by smtp.gmail.com with ESMTPSA id 127-v6sm6211110wmd.18.2018.06.28.13.05.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jun 2018 13:05:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=peiX5D+2uTI2Rlhwxu4ElB3MlS7Zl1y5IQCbsU37Vbc=; b=ufuTywwoRPDTCRqZykFB1yyP5IaaDlUpplpf6oXhw63guNDjflE+88byPVunp5in4G dtLPLU14BKya7AnCxFeqnB5LB3XMnulZJQHM9VxxerYa6LFJsTsG60Ohf+I3NFvKGHJb 1n52WIO5YTowydJLiUB47JEv3EoWgEyFGdQrYm0gYOBw7T3OSQEOUuGcpj9nP8c0+MhF jsg89yLZsUR8C/yP8p5ZYqlysEnNkXMcibGyzQ8FWSLMid5GHghmQRQjw6uVPxqvrkv6 Ar6hiphRKyA6hniR+mP4eMudXAa3kPBVfUM3e3S3eY4uMlUhnlThSmShUDktyVasBLEN hx+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=peiX5D+2uTI2Rlhwxu4ElB3MlS7Zl1y5IQCbsU37Vbc=; b=JAGDzrECCTnnv/tFQI0ibSvuBJPqEIpqQqA0i5bvhVuwrB/CgLf1BSkI1dlyfjMzMb FTLDAR4S5F8Qi+xTL6zqcv11WlpOhSWapURgbxwu5OfMWpJkhplHTNhc/olcCTgfjaV+ M3bfUsL2QhdqVSGAYGXNcPz4TDAO4ztrK2F8Et35vhaT6Ax5mW9o4Y0UvAl1XzkFGeh/ znG3PVruEASTlblQ8cocc4tOBm03UtDkTcGgLGCzwzhACEkS63L7AoO+vz4MZCYdRSfY KVdwVao2T5N9H0UhYrvlEInotyny1vxCTt7Mf22+LK28XUIWgepGNEH+YynYOXYEf2bl BmQQ== X-Gm-Message-State: APt69E20HkV8HwD6dAtpK1cqIzqIZlXD7LXNiOYcYS5hQJYqxrfEuZUa zxVOudpd8IDHyPW5If8XWbOBuAGr X-Google-Smtp-Source: AAOMgpc8Nl4F6gnAzb9SF47KS7BalRfsfi2MIIKap4BFsfLyivqdmb294y04Foz5zYlpaDM9SkZByQ== X-Received: by 2002:adf:fe46:: with SMTP id m6-v6mr9566922wrs.171.1530216316422; Thu, 28 Jun 2018 13:05:16 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 22:04:13 +0200 Message-Id: <1530216310-52873-4-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> References: <1530216310-52873-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::229 Subject: [Qemu-devel] [PULL 03/60] chardev: don't splatter terminal settings on exit if not previously set X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: Daniel P. Berrang=C3=A9 The stdio chardev finalize method calls term_exit() to restore the original terminal settings that were saved in the "oldtty" global. If the qemu_chr_open_stdio() method exited with an error, we might not have any original terminal settings saved in "oldtty" yet. eg $ qemu-system-x86_64 -monitor stdio -daemonize qemu-system-x86_64: -monitor stdio: cannot use stdio with -daemonize will cause QEMU to splatter the terminal settings with an all-zeros "struct termios", with predictably unpleasant results. Fortunately the existing "stdio_in_use" flag is suitable witness for whether "oldtty" contains settings that need restoring. Signed-off-by: Daniel P. Berrang=C3=A9 Message-Id: <20180604123043.13985-1-berrange@redhat.com> Reviewed-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Paolo Bonzini --- chardev/char-stdio.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/chardev/char-stdio.c b/chardev/char-stdio.c index 96375f2..9624220 100644 --- a/chardev/char-stdio.c +++ b/chardev/char-stdio.c @@ -46,8 +46,10 @@ static bool stdio_echo_state; =20 static void term_exit(void) { - tcsetattr(0, TCSANOW, &oldtty); - fcntl(0, F_SETFL, old_fd0_flags); + if (stdio_in_use) { + tcsetattr(0, TCSANOW, &oldtty); + fcntl(0, F_SETFL, old_fd0_flags); + } } =20 static void qemu_chr_set_echo_stdio(Chardev *chr, bool echo) --=20 1.8.3.1