From nobody Sat Feb 7 08:27:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1594068021; cv=none; d=zohomail.com; s=zohoarc; b=KvuVYIxvPeOirhEvlq9oJGieTGxnSa/uR53H3oP/1FyWP0M13TMT7Q57dSPfaeIKL7fENw55+NvU0HyAd66+EjpvfeXkKtZXCO7jCZII88cz8YWRG9Gi0MOb8BWc7Tf/r0ouqeR1Gt15f9wko80rN+WP47gYfNIavfumwPV3bsA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594068021; 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=lJvFO5Pb/vWMhSFo8+5u9ofTXO9NYGyp5FgW59rhl2k=; b=SbDpZsC/zcZ3XdIWx2IAj4p++1BGm+wGKfSA5pzMHwyBRVrnGSAB7lnYolU8nifQS7cO41TAHVVKmnyiNcwMBsDnSqaqUrH7oPsetTbhncqQ+dPtrYTUimtTXTgYkZBDOGn/o0K+SW5Akslag6DnKpj2y+5poP9GTNROSOWZEKk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1594068021301703.0680651400966; Mon, 6 Jul 2020 13:40:21 -0700 (PDT) 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-220-MOX5OrsPOpqrHyHcJhyNaQ-1; Mon, 06 Jul 2020 16:40:16 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B370B2D0; Mon, 6 Jul 2020 20:40:11 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7E7647B419; Mon, 6 Jul 2020 20:40:11 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 0A91E1809557; Mon, 6 Jul 2020 20:40:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 066Ke8Y0005143 for ; Mon, 6 Jul 2020 16:40:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5FA7D7B420; Mon, 6 Jul 2020 20:40:08 +0000 (UTC) Received: from blue.redhat.com (ovpn-113-97.phx2.redhat.com [10.3.113.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 15B617B400; Mon, 6 Jul 2020 20:40:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594068020; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=lJvFO5Pb/vWMhSFo8+5u9ofTXO9NYGyp5FgW59rhl2k=; b=Q4pjSBxeFbV64ZNqMLwLLnoaaMuw2zdTDWum1VcUYlWz8MgA7WtR5kPh0KgYxPBtw0NHNa N+gH0Mis6NMsQI84cVjuXMEUPDz62em0w1KvHFj5NK+Sx420952YudatZVfy1bROdLCT9O PtDgsbilIECMVrvRiwyYIyoqUaRqJf8= X-MC-Unique: MOX5OrsPOpqrHyHcJhyNaQ-1 From: Eric Blake To: qemu-devel@nongnu.org Subject: [PATCH v6 01/10] qemu-img: Flush stdout before before potential stderr messages Date: Mon, 6 Jul 2020 15:39:45 -0500 Message-Id: <20200706203954.341758-2-eblake@redhat.com> In-Reply-To: <20200706203954.341758-1-eblake@redhat.com> References: <20200706203954.341758-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: kwolf@redhat.com, pkrempa@redhat.com, qemu-block@nongnu.org, libvir-list@redhat.com, mreitz@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" 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 --- 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 6dbcb7e083ea..a568196ba250 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); } ret =3D bdrv_create(drv, filename, opts, &local_err); diff --git a/tests/qemu-iotests/049.out b/tests/qemu-iotests/049.out index c54ae21b868a..22f395246b37 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 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' 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' =3D=3D Check preallocation option =3D=3D @@ -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 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' =3D=3D Check encryption option =3D=3D @@ -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 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) *** done diff --git a/tests/qemu-iotests/054.out b/tests/qemu-iotests/054.out index e6ec430edd47..71f18bb98760 100644 --- a/tests/qemu-iotests/054.out +++ b/tests/qemu-iotests/054.out @@ -1,8 +1,8 @@ QA output created by 054 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) 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 aab922fb369b..f65a9ca84fea 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 +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 *** done diff --git a/tests/qemu-iotests/112.out b/tests/qemu-iotests/112.out index ae0318cabea6..5e77e38a7a13 100644 --- a/tests/qemu-iotests/112.out +++ b/tests/qemu-iotests/112.out @@ -2,7 +2,6 @@ QA output created by 112 =3D=3D=3D refcount_bits limits =3D=3D=3D -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 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) =3D=3D=3D Snapshot limit on refcount_bits=3D1 =3D=3D=3D diff --git a/tests/qemu-iotests/259.out b/tests/qemu-iotests/259.out index ffed19c2a0af..e27b9ff38d75 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 --- 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.27.0