From patchwork Thu Apr 26 16:19:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kagan X-Patchwork-Id: 10366303 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7C36260542 for ; Thu, 26 Apr 2018 16:24:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E30F2862A for ; Thu, 26 Apr 2018 16:24:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6225628A14; Thu, 26 Apr 2018 16:24:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ECF9128BE0 for ; Thu, 26 Apr 2018 16:22:55 +0000 (UTC) Received: from localhost ([::1]:43325 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBjfb-0005NR-0c for patchwork-qemu-devel@patchwork.kernel.org; Thu, 26 Apr 2018 12:22:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42989) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBjd5-0003AT-EZ for qemu-devel@nongnu.org; Thu, 26 Apr 2018 12:20:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fBjd3-0000dB-GZ for qemu-devel@nongnu.org; Thu, 26 Apr 2018 12:20:19 -0400 Received: from mail-he1eur01on0132.outbound.protection.outlook.com ([104.47.0.132]:43469 helo=EUR01-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fBjcw-0000VC-TS; Thu, 26 Apr 2018 12:20:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=mQZEIDRMYY4Faxz3wk2ph5b5mtV21b8nfKmIME5H254=; b=dSmJxWUd8UIbA5Jz0n8R4Ks2Vjsx4/QcTJo5QjTbzYKa9mbt7tZl0pwwq1K+3w2SeKtSUlOgFqNc86bjWTL8l4TVnZVjmObAqfKChaqoxMd8vMiARxhE7ktIFkvdqGCfRyaFI4wMy7UnObfHd+YmzEkRbgM5RbK6YH+rh6/9Oco= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=rkagan@virtuozzo.com; Received: from rkaganb.sw.ru (195.214.232.6) by HE1PR0801MB1980.eurprd08.prod.outlook.com (2603:10a6:3:4f::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.15; Thu, 26 Apr 2018 16:20:07 +0000 From: Roman Kagan To: Kevin Wolf , Max Reitz , Markus Armbruster , qemu-block@nongnu.org, qemu-devel@nongnu.org Date: Thu, 26 Apr 2018 19:19:43 +0300 Message-Id: <20180426161958.2872-3-rkagan@virtuozzo.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180426161958.2872-1-rkagan@virtuozzo.com> References: <20180426161958.2872-1-rkagan@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: HE1PR0902CA0049.eurprd09.prod.outlook.com (2603:10a6:7:15::38) To HE1PR0801MB1980.eurprd08.prod.outlook.com (2603:10a6:3:4f::22) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:HE1PR0801MB1980; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0801MB1980; 3:fW9WFDHe/7pPWMIUqk30ssVdmbsp3vDQc39ZQ72KgAlqXEXpTbne1hXpbsIU/jtVBnCW2Zj6Kk7Vz+aUPioqLimao6xIXfZHnma3vst5B+Wqqavq8yFhY48BzEt0luCakaiQdgNQ9q5IdaDQW/S00oNHJUPcXtjigI4fW8Sodr5+MxpIjsez1Zt8Fn+aTYT9qW4xo+RYmGZqApwfjsosrAji5P5q3qerhlCMqxIDkiXep0R2D4itLtsx3HXCBHE6; 25:jfZYhi3K2Rw9Wil6EZl5Or79kdaKVssM60UdRL1aIt4vz/LCgi1nwTgJ40qXpmpWQ2kyndcbMN4X26sj7A4CvAGf6YJhwCML1wZ/H6x34mTSEEBQuFOAYsPQCaQ13zYKVZjedjXjr88kxPetudPhMsxNN53CCIX1TkFk4nOXg/GmrVkvaQsY9adEXN4LHAjWWo5N/HrJlCZLeJlaZ4hq2/ZiXCfGJQH+HFM7MeX3qUvEasS4wCVVu4xwGqV0kZBPjZ3jFLFrU9PUY9KT3e29zbXzZ0VNI6zkNSuHMaxdzMe4pgSmPMuhDFQdMYLwISX46EGuu4z4JGaVSJCDR0Sp3A==; 31:eQirEyA0hxMfKdytKBFzaZOHEYQyRwfJJYsgfUhTpOoTbBU+zIJ/P4GVKknA8xeDLu5as9zGnsNS7tIZc/v4OmsVD7SCB2SlkiXJK8NcsoJneHoUdPjAooBPAx/A/GE/pWBKchVSzc8t4VmUyeGUxi4vitx6OVwZB9N0pbGhAfzQZCpRc9RFLgmLBDnroADW/NfQ3SNyYeUrTzjjH2psUVelI4atpvbf5d8fa7NepSQ= X-MS-TrafficTypeDiagnostic: HE1PR0801MB1980: X-Microsoft-Exchange-Diagnostics: 1; HE1PR0801MB1980; 20:Sk9vr1Xu8FpBWXP1plQqS4TkXgDwZ0XGskC6X5tRlf58Cnn69Kv1shwDEN3o9zOzaK911g2RtYGs84S7ZShHfo/M4qmSSVewN9al7RyomLTulWsWDSaTKCFnQHF8TU3plA9yNR5nSHJocnQmT1HF12qpROl/y6MxKAOaYtUqAnnJEJ7qfQtmfQY5duoRQFE0ADAoQUTl76zOsM27i9KIgqfW5sxl3onjQB6mMwItbf9xs6JjmG5fjCaJ2TpS26WCv+xAJdN0fqS9MXp4DAfuylUDTlGZkp8QZktampbT6e+YCjJTYJKOgZLU2xfVLaDZ0BefcaAk/ZMBcahOmhctizN+Q5rJ5QDZuCrugE/iADJJ+MloF5zwISAefgCnLPsCEBolSC64uYkfYJ6eX4StKLFvesqro/hrL6fZ2E7P2IGxF18pekUuRv2o1H3CuyWzfdGmGifEEe08m3pWp5KUIDkWgCAW1ytVVdS9M6d06m9hRX7SvNPfd81J+Q9exi/R; 4:tZmQF+RfoPU0A/idPmB0N/3ZkoycfIyN0FP3yVduTzsd42BHSR4vWuE37+SGc9bQptnssUpVBs24fKZ/2WI+zSlncCT5Yk752hqPWBkcYNvyEFtv6jjEgBp3rsPPzX4g9mD1mjoN1IKBP+H4UD2m+oECOOF7Ua69RKJL2eKb0mHPQqgbI3dBbSrAmjTo9uupXYPf88P/TFj3hvlmc9Y+Ryg89r7BPAIHZmY2iy7KNqt800VkM7573rbHhuzapH0nhtHlnU06WkVInYzitaR5/A== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3002001)(3231232)(944501410)(52105095)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123562045)(20161123558120)(6072148)(201708071742011); SRVR:HE1PR0801MB1980; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0801MB1980; X-Forefront-PRVS: 0654257CF5 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(366004)(396003)(39850400004)(39380400002)(346002)(376002)(189003)(199004)(1076002)(106356001)(956004)(55236004)(53936002)(6506007)(2616005)(2906002)(110136005)(81156014)(36756003)(6116002)(97736004)(8936002)(3846002)(575784001)(86362001)(47776003)(105586002)(11346002)(50226002)(81166006)(53416004)(7736002)(305945005)(476003)(486006)(446003)(316002)(6666003)(16526019)(76176011)(5660300001)(8676002)(386003)(6512007)(186003)(50466002)(48376002)(16586007)(66066001)(51416003)(6486002)(26005)(52116002)(69596002)(25786009)(68736007)(478600001); DIR:OUT; SFP:1102; SCL:1; SRVR:HE1PR0801MB1980; H:rkaganb.sw.ru; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0801MB1980; 23:dhBx5YmjycXyINSkjreqQb1I358afygCliOXDZU?= =?us-ascii?Q?fdO1c9Qeg/4D16ui4KQU0NOIPDddTIiQIHlNSuZkkEbNKPmX7X7r3paSNpeD?= =?us-ascii?Q?cmKZOfA1OGJ4H/3JY3xDbrmxbdZGwEZfWvjyRoZoBqdJ2p7ohEHD5785opWy?= =?us-ascii?Q?3Egy8oVkbkCrox2ju1MLucWe9TyOoJxj8LplmfQbfNCUkUZ7QO/rysi4yFTZ?= =?us-ascii?Q?7zhGZCuv8+p6tfFE6hj8PcLf5wd9lG+ig1nYko6xPf7CjMNBH5BxSATOb6JZ?= =?us-ascii?Q?vBiXqX0xKBNUZq8zgRRW0apij2MszyosZeOEBn1oSmER4YC4u1eTmRe6c3Jb?= =?us-ascii?Q?OnvsmdcV78pw1fV46dvt54Gwo1uzABd+i2f/vjmJkcdttOL9wiRqCfc9GujW?= =?us-ascii?Q?jnj9pae7pol1YtoNu1DxqKz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-Message-Info: Bxa7/c0xkSSuExrDeio0hmaycJDAzVx1YUIu1XF8vVNBCz2S45JC9M60ewQ88RFwgZ70bVBhyT1+5CNkF8JSfXUm0m1ALFb7t790LpFukbqDaCLkpWJNZXdyeFGtNV49UfmhicLhelWdqqHGiJkqfiHEGAvPRq1xbUuQaOhR2aJkAh6Cv5kRWhqcthC2OdMM X-Microsoft-Exchange-Diagnostics: 1; HE1PR0801MB1980; 6:8Q86gRr9+0p91LZ3rKTAbkelXePJrAsOXozPSLsuuoIspNlI8y4KnzhySMHORg8w8m9MPA5WVSv+fgWdIBwa5FvMKwOYv/NKUpD1tVB82yPJ214u6aLzfdZNbRX9W6GUDToYeWSiVarHtu7c5SY5UUWYZXWKMv1GaNHFDUQqfxuWbwZgtGgg+oyYGm6hIJHxtC0ZyEduh1QzqMAlj8iS4AZCd9qZC4z43Uuz2NEFH0UKP60Ihhtjww5yYla8gt8GK9AHYEcyHbQSE40I63fwSnEVQtQBnJuuU8P6qluSNrNngo5JBnWOwNMWiVduzQvnvF+N+7ZyVfbU2sRbQ4O/E6/SDgPCXDEgYaQRcNbLAmejXH8wnOuLynWCEcX6K9LlGpFPAf08vQIkce5FCWR0PixEgOEiaDZuUPlh4MjJmosSJN+D0KYT2JOY550/AzlQdPfXfn7OgyMxKfEd0TASxA==; 5:eHpIY86FCuOKBV97ibp+IfOpOcZM8fJqkaMoii5VldGtrZMHs/BZ1niG9q2FA9Hn1xugvwA667gjoPvjBRr2PVCYEDcu52VHCkGfKngpAw/nIm7um78aWhvkm1yC0mUuVyYao9AhHILEfzBXicRtzN359912r6Y2Lq3+noDJUZU=; 24:93e7VrRJ4wleEfWYKXIls6VBLzLOhFCsjgXpTEbdtWu4hrK4EIZKxtXNpIIUKfMl4re+RrUpOp7qcNIOWxSmdBhn7tGwhZubQ3NLNghdnpM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR0801MB1980; 7:p1H3h4IDmGPCwJOzhOROFY9d7RaF/ftP6T3NPU15Jmsctw38/egWhzXHAH0mHKghyRg+icuakJeFFFO0uA0RBRzwdvtQa2mMdWcsT+Ly7IOg/PngV9zMAF6Div9QrAkJhLZOKLpgV1tZTgNLz7M0ASqK/GP09NWQ4B85Lg09BtQQdfg/GM66TY3nMACw9Yt+GnHqTELgB0zGefvbelrxmdqH9FlgCWfgkWSklLMUjS2THAdnG+pIORwgfMIKzFxV; 20:qt81p08jn0Zm+c85luQn0jyKlob87O2hPJwmYlERl85yrAcrrCb+OP2bamKy+ZLydZ8K/2izxDImHtUP2a6MkY25olAjXv4JNaqv9WhF7xc3aAXpOX1dC5ZeHE55zKABzJEE7bVcryfPFV1XOSBPufI7k3mvyO4bvMIYxqmPfu4= X-MS-Office365-Filtering-Correlation-Id: f3eea484-3070-4cad-be58-08d5ab91934b X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2018 16:20:07.0740 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f3eea484-3070-4cad-be58-08d5ab91934b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1980 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.0.132 Subject: [Qemu-devel] [PATCH 02/17] iotests: iotests.py: prevent deadlock in subprocess 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP A subprocess whose std{out,err} is subprocess.PIPE may block writing its output, so .wait() should not be called on it until the pipes are read completely on the caller's side. Subprocess.communicate takes care of this. Signed-off-by: Roman Kagan Reviewed-by: Max Reitz --- tests/qemu-iotests/iotests.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index b25d48a91b..e2abf0cb53 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -104,20 +104,20 @@ def qemu_img_pipe(*args): subp = subprocess.Popen(qemu_img_args + list(args), stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - exitcode = subp.wait() - if exitcode < 0: - sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' '.join(qemu_img_args + list(args)))) - return subp.communicate()[0] + output = subp.communicate()[0] + if subp.returncode < 0: + sys.stderr.write('qemu-img received signal %i: %s\n' % (-subp.returncode, ' '.join(qemu_img_args + list(args)))) + return output def qemu_io(*args): '''Run qemu-io and return the stdout data''' args = qemu_io_args + list(args) subp = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - exitcode = subp.wait() - if exitcode < 0: - sys.stderr.write('qemu-io received signal %i: %s\n' % (-exitcode, ' '.join(args))) - return subp.communicate()[0] + output = subp.communicate()[0] + if subp.returncode < 0: + sys.stderr.write('qemu-io received signal %i: %s\n' % (-subp.returncode, ' '.join(args))) + return output class QemuIoInteractive: