From nobody Tue Feb 10 16:58:00 2026 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=1677859732; cv=none; d=zohomail.com; s=zohoarc; b=GWjON+/Pbur7V7Pgh1skYFUnUZB30QtYI8vibimnfa5gZfGRG5L8cHWfM0JkhFwlT/KENBLYZs6W6qaDJ+0eEPVw07+x4lYVMGxxrF/b2edSYpcizNBcImxVGLCO8cXzLIDRfa/1nXDCujaoK/jtF7GWR7VGrWzC1GjqInTZT2Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677859732; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=p++4zIgGZrX/Z/sDx3hiWSacNj22/J8kQgnF2nrA63w=; b=T/WrGTtj1zU8QDhYE0KPO0eypyAXfn+z603vl2FpCM228EAsHmNbMUzeKDgelwEtNlQvdR6RYvC9c0N4Np/pJ9sDxLMbAHBs15kbOwUE2X5AITpfvHHH5GoZWh24hQ4AM7N6C0ArfQVls9fnMDScdboSd/b2F5jRd6I5hy5K5ms= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677859732334418.59538807853755; Fri, 3 Mar 2023 08:08:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pY7wg-0007ha-Km; Fri, 03 Mar 2023 11:07:46 -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 ) id 1pY7wc-0007eq-Uv for qemu-devel@nongnu.org; Fri, 03 Mar 2023 11:07:44 -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 ) id 1pY7wa-0005kP-U0 for qemu-devel@nongnu.org; Fri, 03 Mar 2023 11:07:42 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-278-VaGGxrC8PHKLho1OZdmSwg-1; Fri, 03 Mar 2023 11:07:39 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AFC26101A52E; Fri, 3 Mar 2023 16:07:38 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 37D4E492C14; Fri, 3 Mar 2023 16:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677859660; 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=p++4zIgGZrX/Z/sDx3hiWSacNj22/J8kQgnF2nrA63w=; b=JMQB2qGTlOSazfDC+3aJFyqDLe6h6Jrw7YksbwMMsz4w/itOzT5a/Q3tIEJYEvfk8sHUbQ rT0VIBEMKMNVxbScPDgj2u73pK+4F13xnfwvLVdXCXps4I4PxdMtNP/qtybjMsmK8Bawnn jIGhKY0XAlI/XEtmMN/33uwY56I7xKg= X-MC-Unique: VaGGxrC8PHKLho1OZdmSwg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Kevin Wolf , qemu-block@nongnu.org, Thomas Huth , Hanna Reitz , =?UTF-8?q?Alex=20Benn=C3=A9e?= , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v2 5/8] iotests: connect stdin to /dev/null when running tests Date: Fri, 3 Mar 2023 16:07:24 +0000 Message-Id: <20230303160727.3977246-6-berrange@redhat.com> In-Reply-To: <20230303160727.3977246-1-berrange@redhat.com> References: <20230303160727.3977246-1-berrange@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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=berrange@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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1677859733930100002 Currently the tests have their stdin inherited from the test harness, meaning they are connected to a TTY. The QEMU processes spawned by certain tests, however, modify TTY settings and if the test exits abnormally the settings might not be restored. The python test harness thus has some logic which will capture the initial TTY settings and restore them once all tests are finished. This does not, however, take into account the possibility of many copies of the 'check' program running in parallel. With parallel execution, a later invokation may save the TTY state that QEMU has already modified, and thus restore bad state leaving the TTY non-functional. None of the I/O tests shnould actually be interactive requiring user input and so they should not require a TTY at all. To avoid this while TTY save/restore complexity we can connect the test stdin to /dev/null instead. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Thomas Huth --- tests/qemu-iotests/testrunner.py | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/tests/qemu-iotests/testrunner.py b/tests/qemu-iotests/testrunn= er.py index e734800b3d..81519ed6e2 100644 --- a/tests/qemu-iotests/testrunner.py +++ b/tests/qemu-iotests/testrunner.py @@ -24,12 +24,10 @@ import subprocess import contextlib import json -import termios import shutil import sys from multiprocessing import Pool -from contextlib import contextmanager -from typing import List, Optional, Iterator, Any, Sequence, Dict, \ +from typing import List, Optional, Any, Sequence, Dict, \ ContextManager =20 from testenv import TestEnv @@ -56,22 +54,6 @@ def file_diff(file1: str, file2: str) -> List[str]: return res =20 =20 -# We want to save current tty settings during test run, -# since an aborting qemu call may leave things screwed up. -@contextmanager -def savetty() -> Iterator[None]: - isterm =3D sys.stdin.isatty() - if isterm: - fd =3D sys.stdin.fileno() - attr =3D termios.tcgetattr(fd) - - try: - yield - finally: - if isterm: - termios.tcsetattr(fd, termios.TCSADRAIN, attr) - - class LastElapsedTime(ContextManager['LastElapsedTime']): """ Cache for elapsed time for tests, to show it during new test run =20 @@ -169,7 +151,6 @@ def __enter__(self) -> 'TestRunner': self._stack =3D contextlib.ExitStack() self._stack.enter_context(self.env) self._stack.enter_context(self.last_elapsed) - self._stack.enter_context(savetty()) return self =20 def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> N= one: @@ -294,6 +275,7 @@ def do_run_test(self, test: str, mp: bool) -> TestResul= t: t0 =3D time.time() with f_bad.open('w', encoding=3D"utf-8") as f: with subprocess.Popen(args, cwd=3Dstr(f_test.parent), env=3Den= v, + stdin=3Dsubprocess.DEVNULL, stdout=3Df, stderr=3Dsubprocess.STDOUT) = as proc: try: proc.wait() --=20 2.39.2