From nobody Wed May 8 19:48:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1548938419056886.7566074193724; Thu, 31 Jan 2019 04:40:19 -0800 (PST) Received: from localhost ([127.0.0.1]:53820 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpBde-0008P7-1A for importer@patchew.org; Thu, 31 Jan 2019 07:40:14 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpBcf-0007w3-KI for qemu-devel@nongnu.org; Thu, 31 Jan 2019 07:39:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gpBcR-0005N5-Az for qemu-devel@nongnu.org; Thu, 31 Jan 2019 07:39:05 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:38938) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gpBcM-0005Ac-Ul; Thu, 31 Jan 2019 07:38:56 -0500 Received: from 62-165-147-230.co.dnainternet.fi ([62.165.147.230] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1gpBc0-0006GV-Qy; Thu, 31 Jan 2019 13:38:32 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1gpBbm-0002go-UB; Thu, 31 Jan 2019 14:38:18 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Message-Id:Date:Subject:Cc:To:From; bh=nfJoV3pV4Nc4LHPkP5qrMDrlxDhswKEKC3C+2BymtqA=; b=HP6tqs9GwJdYbOtAOOP8qo4KPBMdvfJ4gXAhwbvvYgwGk+LqFUR4w8YwOqiCv/3Zl0uDWNQVOiAEIV5nBO3OeD6+DIcDCEzXZIt7pAmqG1qwcIfpWGaOIwUe7bvWyLqq9+YUZ9kmQ0uxLR5Epjq4hmxRJXS8y/+A6cMZ0yb3Wa+RCfvs84itcb1uMLg49IIsdVHkrvnGpYV9OkenXat6LjOkJXtkbkzhyvnL2eEyFWvfHAz+x1fwaBreN+yjL7of6iMBtqI5EOjzqAAbnnLK2dD9nsUwGHcVA5bt78xCAc8Ok5PVLfBp2EDgV4SouOrhKfAjwmI64u+nnUBGa9I20Q==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 31 Jan 2019 14:38:10 +0200 Message-Id: <20190131123810.10233-1-berto@igalia.com> X-Mailer: git-send-email 2.11.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH] qtest.py: Wait for the result of qtest commands 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: , Cc: Alberto Garcia , Eduardo Habkost , qemu-block@nongnu.org, Markus Armbruster , Peter Xu , Max Reitz , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The cmd() method of the QEMUQtestProtocol class sends a qtest command to QEMU but doesn't wait for the return message ("OK", "FAIL", "ERR"). Because of this, it can return control to the caller before the command has actually finished. In cases like clock_step or clock_set this means that cmd() can return before all the timers triggered by the clock change have been fired. This can be fixed by making cmd() wait for the output of the qtest command. This fixes iotests 093 and 136, which are flaky since commit 8258292e18c39480b64eba9f3551 when the machine is under heavy workload. Signed-off-by: Alberto Garcia Reviewed-by: Stefan Hajnoczi --- scripts/qtest.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/qtest.py b/scripts/qtest.py index adf1fe3f26..afac3fe900 100644 --- a/scripts/qtest.py +++ b/scripts/qtest.py @@ -31,6 +31,7 @@ class QEMUQtestProtocol(object): """ self._address =3D address self._sock =3D self._get_sock() + self._sockfile =3D None if server: self._sock.bind(self._address) self._sock.listen(1) @@ -49,6 +50,7 @@ class QEMUQtestProtocol(object): @raise socket.error on socket connection errors """ self._sock.connect(self._address) + self._sockfile =3D self._sock.makefile() =20 def accept(self): """ @@ -57,6 +59,7 @@ class QEMUQtestProtocol(object): @raise socket.error on socket connection errors """ self._sock, _ =3D self._sock.accept() + self._sockfile =3D self._sock.makefile() =20 def cmd(self, qtest_cmd): """ @@ -65,9 +68,12 @@ class QEMUQtestProtocol(object): @param qtest_cmd: qtest command text to be sent """ self._sock.sendall((qtest_cmd + "\n").encode('utf-8')) + resp =3D self._sockfile.readline() + return resp =20 def close(self): self._sock.close() + self._sockfile.close() =20 def settimeout(self, timeout): self._sock.settimeout(timeout) --=20 2.11.0