From nobody Tue Apr 15 03:09:22 2025 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=1594140664; cv=none; d=zohomail.com; s=zohoarc; b=jWhIdZqwWexCkuCByqBK2+n4Ry+Ris/j47loKeRhEiv062+R4rNrJ8gZTY1Cse1hIfalvqJq5MkgeMIqnxpIgXRa+jiupdZLLOoMxFwABsAtueG8JWH+3fE3ugE1WKejYUaomLqLHblSnvfe2R6uU9+ITMEEk3M+SSfllJuRXS0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594140664; 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=DdaB25yWPzDpqrSx4Dkn+Ay1YVyVUTLKcicTCCvTG14=; b=f+c5g/pGu9PHgZK3sqQUi7/veNcZpERzf5HYcCQyv4/nFid3qDcogE6+8ZXRt+YE63ZhEvIz8VKzu65ASjIl6aS0XpSYLEL72JWM88++OM/wmNpWs1ULY3Z9RWZjiGA23zYkjOcGAFGsPLLD2eOwscZ9/Ca1j3zagjG/p/VaQ6k= 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) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159414066417541.16055240053481; Tue, 7 Jul 2020 09:51:04 -0700 (PDT) Received: from localhost ([::1]:54920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jsqoA-0002tL-RR for importer@patchew.org; Tue, 07 Jul 2020 12:51:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39996) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jsqZn-0008E1-Cq for qemu-devel@nongnu.org; Tue, 07 Jul 2020 12:36:11 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:53582 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jsqZj-0004Fc-56 for qemu-devel@nongnu.org; Tue, 07 Jul 2020 12:36:11 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-57-xphObT5pOSKjbxXxTh58nA-1; Tue, 07 Jul 2020 12:35:46 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9941D84E21A; Tue, 7 Jul 2020 16:35:44 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-114-113.ams2.redhat.com [10.36.114.113]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2908F71674; Tue, 7 Jul 2020 16:35:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594139766; 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=DdaB25yWPzDpqrSx4Dkn+Ay1YVyVUTLKcicTCCvTG14=; b=LvB3oZYGmSHhDXyN1pLnx1pDBIPCfmelCMb1hvavm1P1ixqtoX92rjCeTbDwKiClX+UHDP 49iTgAo5LESgu0wfRL1mAV4xp7FUmbrE8/W3cSxBER3sth2FjwYNFbgRz7jtan/XwvjWDt ZzlfmhRUtcNuaBIKAvFjfaPmcsfZ1Yk= X-MC-Unique: xphObT5pOSKjbxXxTh58nA-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 03/12] qemu-img: Flush stdout before before potential stderr messages Date: Tue, 7 Jul 2020 18:34:55 +0200 Message-Id: <20200707163504.194740-4-kwolf@redhat.com> In-Reply-To: <20200707163504.194740-1-kwolf@redhat.com> References: <20200707163504.194740-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=207.211.31.81; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/07 00:20:54 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Eric Blake During 'qemu-img create ... 2>&1', if --quiet is not in force, we can end up with buffered I/O in stdout that was produced before failure, but which appears in output after failure. This is confusing; the fix is to flush stdout prior to attempting anything that might produce an error message. Several iotests demonstrate the resulting ordering change now that the merged outputs now reflect chronology. (An even better fix would be to avoid printf from within block.c altogether, but that's much more invasive...) Signed-off-by: Eric Blake Message-Id: <20200706203954.341758-2-eblake@redhat.com> Signed-off-by: Kevin Wolf --- block.c | 1 + tests/qemu-iotests/049.out | 8 ++++---- tests/qemu-iotests/054.out | 2 +- tests/qemu-iotests/079.out | 2 +- tests/qemu-iotests/112.out | 4 ++-- tests/qemu-iotests/259.out | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/block.c b/block.c index 6dbcb7e083..a568196ba2 100644 --- a/block.c +++ b/block.c @@ -6186,6 +6186,7 @@ void bdrv_img_create(const char *filename, const char= *fmt, printf("Formatting '%s', fmt=3D%s ", filename, fmt); qemu_opts_print(opts, " "); puts(""); + fflush(stdout); } =20 ret =3D bdrv_create(drv, filename, opts, &local_err); diff --git a/tests/qemu-iotests/049.out b/tests/qemu-iotests/049.out index c54ae21b86..22f395246b 100644 --- a/tests/qemu-iotests/049.out +++ b/tests/qemu-iotests/049.out @@ -167,12 +167,12 @@ qemu-img create -f qcow2 -o compat=3D1.1 TEST_DIR/t.q= cow2 64M Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3D1.1 cl= uster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_type= =3Dzlib =20 qemu-img create -f qcow2 -o compat=3D0.42 TEST_DIR/t.qcow2 64M -qemu-img: TEST_DIR/t.qcow2: Invalid parameter '0.42' Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3D0.42 c= luster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_typ= e=3Dzlib +qemu-img: TEST_DIR/t.qcow2: Invalid parameter '0.42' =20 qemu-img create -f qcow2 -o compat=3Dfoobar TEST_DIR/t.qcow2 64M -qemu-img: TEST_DIR/t.qcow2: Invalid parameter 'foobar' Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3Dfoobar= cluster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_t= ype=3Dzlib +qemu-img: TEST_DIR/t.qcow2: Invalid parameter 'foobar' =20 =3D=3D Check preallocation option =3D=3D =20 @@ -183,8 +183,8 @@ qemu-img create -f qcow2 -o preallocation=3Dmetadata TE= ST_DIR/t.qcow2 64M Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 65536 preallocation=3Dmetadata lazy_refcounts=3Doff refcount_bits=3D16 comp= ression_type=3Dzlib =20 qemu-img create -f qcow2 -o preallocation=3D1234 TEST_DIR/t.qcow2 64M -qemu-img: TEST_DIR/t.qcow2: Invalid parameter '1234' Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 cluster_size=3D= 65536 preallocation=3D1234 lazy_refcounts=3Doff refcount_bits=3D16 compress= ion_type=3Dzlib +qemu-img: TEST_DIR/t.qcow2: Invalid parameter '1234' =20 =3D=3D Check encryption option =3D=3D =20 @@ -206,7 +206,7 @@ qemu-img create -f qcow2 -o compat=3D0.10,lazy_refcount= s=3Doff TEST_DIR/t.qcow2 64M Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3D0.10 c= luster_size=3D65536 lazy_refcounts=3Doff refcount_bits=3D16 compression_typ= e=3Dzlib =20 qemu-img create -f qcow2 -o compat=3D0.10,lazy_refcounts=3Don TEST_DIR/t.q= cow2 64M -qemu-img: TEST_DIR/t.qcow2: Lazy refcounts only supported with compatibili= ty level 1.1 and above (use version=3Dv3 or greater) Formatting 'TEST_DIR/t.qcow2', fmt=3Dqcow2 size=3D67108864 compat=3D0.10 c= luster_size=3D65536 lazy_refcounts=3Don refcount_bits=3D16 compression_type= =3Dzlib +qemu-img: TEST_DIR/t.qcow2: Lazy refcounts only supported with compatibili= ty level 1.1 and above (use version=3Dv3 or greater) =20 *** done diff --git a/tests/qemu-iotests/054.out b/tests/qemu-iotests/054.out index e6ec430edd..71f18bb987 100644 --- a/tests/qemu-iotests/054.out +++ b/tests/qemu-iotests/054.out @@ -1,8 +1,8 @@ QA output created by 054 =20 creating too large image (1 EB) -qemu-img: TEST_DIR/t.IMGFMT: The image size is too large for file format '= IMGFMT' (try using a larger cluster size) Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1152921504606846976 +qemu-img: TEST_DIR/t.IMGFMT: The image size is too large for file format '= IMGFMT' (try using a larger cluster size) =20 creating too large image (1 EB) using qcow2.py Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D4294967296 diff --git a/tests/qemu-iotests/079.out b/tests/qemu-iotests/079.out index aab922fb36..f65a9ca84f 100644 --- a/tests/qemu-iotests/079.out +++ b/tests/qemu-iotests/079.out @@ -9,6 +9,6 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D4294967= 296 preallocation=3Dmetadat Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D4294967296 preallocati= on=3Dmetadata Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D4294967296 preallocati= on=3Dmetadata Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D4294967296 preallocati= on=3Dmetadata -qemu-img: TEST_DIR/t.IMGFMT: Cluster size must be a power of two between 5= 12 and 2048k Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D4294967296 preallocati= on=3Dmetadata +qemu-img: TEST_DIR/t.IMGFMT: Cluster size must be a power of two between 5= 12 and 2048k *** done diff --git a/tests/qemu-iotests/112.out b/tests/qemu-iotests/112.out index ae0318cabe..5e77e38a7a 100644 --- a/tests/qemu-iotests/112.out +++ b/tests/qemu-iotests/112.out @@ -2,7 +2,6 @@ QA output created by 112 =20 =3D=3D=3D refcount_bits limits =3D=3D=3D =20 -qemu-img: TEST_DIR/t.IMGFMT: Refcount width must be a power of two and may= not exceed 64 bits Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 qemu-img: TEST_DIR/t.IMGFMT: Refcount width must be a power of two and may= not exceed 64 bits Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 refcount_bits= =3D-1 @@ -10,6 +9,7 @@ qemu-img: TEST_DIR/t.IMGFMT: Refcount width must be a powe= r of two and may not e Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 qemu-img: TEST_DIR/t.IMGFMT: Refcount width must be a power of two and may= not exceed 64 bits Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 +qemu-img: TEST_DIR/t.IMGFMT: Refcount width must be a power of two and may= not exceed 64 bits Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 refcount bits: 1 Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 @@ -21,10 +21,10 @@ refcount bits: 16 =20 Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 refcount bits: 16 -qemu-img: TEST_DIR/t.IMGFMT: Different refcount widths than 16 bits requir= e compatibility level 1.1 or above (use version=3Dv3 or greater) Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 qemu-img: TEST_DIR/t.IMGFMT: Different refcount widths than 16 bits requir= e compatibility level 1.1 or above (use version=3Dv3 or greater) Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 +qemu-img: TEST_DIR/t.IMGFMT: Different refcount widths than 16 bits requir= e compatibility level 1.1 or above (use version=3Dv3 or greater) =20 =3D=3D=3D Snapshot limit on refcount_bits=3D1 =3D=3D=3D =20 diff --git a/tests/qemu-iotests/259.out b/tests/qemu-iotests/259.out index ffed19c2a0..e27b9ff38d 100644 --- a/tests/qemu-iotests/259.out +++ b/tests/qemu-iotests/259.out @@ -9,6 +9,6 @@ virtual size: 64 MiB (67108864 bytes) disk size: unavailable =20 --- Testing creation for which the node would need to grow --- -qemu-img: TEST_DIR/t.IMGFMT: Could not resize image: Image format driver d= oes not support resize Formatting 'TEST_DIR/t.IMGFMT', fmt=3Dqcow2 size=3D67108864 preallocation= =3Dmetadata +qemu-img: TEST_DIR/t.IMGFMT: Could not resize image: Image format driver d= oes not support resize *** done --=20 2.25.4