From nobody Mon Feb 9 20:34:55 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1582284429; cv=none; d=zohomail.com; s=zohoarc; b=k00w/J5/3QY0WFZ28K5TuYFk8m/uChJ38xMAdDFS3F7QbVQvwiNbHfy1jx/Q1ZZ9fKaJ8xXq1V2KirFnuJtE1/xr/nPOxeHAl+nXY2sB/CcPXTB5Dfko1sJN3pKVHLUuPNGGjB92664V7hzxNU1wgJmBs+Pw0ToZiGtE1zn2q6U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582284429; 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=7JxLX3G2fQYdmYBZqXd/PlErIkcNdVDptn8OF0OsJVU=; b=GVuo39fIvbzQlIRfojKysaxxBFVn8qabR2MfTKZqJmlfajpkgJeVg73EBeW3VKyqCIuh9dFFrRJE9juv1GjyvQzDCBFpkR7OtlkqJW5rkJZNybTUUr8z+nfeB3/NGQz/z19EKq/zCb1Y+DENo3Gva277JUKWCVDVmWF8+wQCv4A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 1582284429144872.3938767450195; Fri, 21 Feb 2020 03:27:09 -0800 (PST) Received: from localhost ([::1]:55554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j56SZ-0000Ct-VZ for importer@patchew.org; Fri, 21 Feb 2020 06:27:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35773) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j56RJ-0006Ol-SO for qemu-devel@nongnu.org; Fri, 21 Feb 2020 06:25:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j56RI-0001vC-DR for qemu-devel@nongnu.org; Fri, 21 Feb 2020 06:25:49 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:43816 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j56RI-0001v1-9P for qemu-devel@nongnu.org; Fri, 21 Feb 2020 06:25:48 -0500 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-384-TUt43Nq1O9uD7bHCO09fbQ-1; Fri, 21 Feb 2020 06:25:42 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 153E6800D5B; Fri, 21 Feb 2020 11:25:41 +0000 (UTC) Received: from localhost (ovpn-117-223.ams2.redhat.com [10.36.117.223]) by smtp.corp.redhat.com (Postfix) with ESMTP id F0AFF1001DC2; Fri, 21 Feb 2020 11:25:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582284347; 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=7JxLX3G2fQYdmYBZqXd/PlErIkcNdVDptn8OF0OsJVU=; b=TTPeUDnA0rD9xN8xJvLxfoHWq/P0XAqUUZ/9C26Mm9H6MHuOYIzGfZr4b2y0nc9w6PwIGz 8S6Ju26BbYrHnWuSKawmc7c7u11VLJbLqQQV5gohTa9Yd9YjOY1dS5OmhlQTfpuqjyQwNR lQfokV9RX4V8WXLm+vQLFInJ/aHZbxs= X-MC-Unique: TUt43Nq1O9uD7bHCO09fbQ-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Subject: [PATCH v4 3/4] qemu-img: allow qemu-img measure --object without a filename Date: Fri, 21 Feb 2020 11:25:21 +0000 Message-Id: <20200221112522.1497712-4-stefanha@redhat.com> In-Reply-To: <20200221112522.1497712-1-stefanha@redhat.com> References: <20200221112522.1497712-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 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: Kevin Wolf , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stefan Hajnoczi , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" In most qemu-img sub-commands the --object option only makes sense when there is a filename. qemu-img measure is an exception because objects may be referenced from the image creation options instead of an existing image file. Allow --object without a filename. Signed-off-by: Stefan Hajnoczi Reviewed-by: Max Reitz --- qemu-img.c | 6 ++---- tests/qemu-iotests/178 | 2 +- tests/qemu-iotests/178.out.qcow2 | 8 ++++---- tests/qemu-iotests/178.out.raw | 8 ++++---- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 2b4562b9d9..0cee7bed8b 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -4912,10 +4912,8 @@ static int img_measure(int argc, char **argv) filename =3D argv[optind]; } =20 - if (!filename && - (object_opts || image_opts || fmt || snapshot_name || sn_opts)) { - error_report("--object, --image-opts, -f, and -l " - "require a filename argument."); + if (!filename && (image_opts || fmt || snapshot_name || sn_opts)) { + error_report("--image-opts, -f, and -l require a filename argument= ."); goto out; } if (filename && img_size !=3D UINT64_MAX) { diff --git a/tests/qemu-iotests/178 b/tests/qemu-iotests/178 index 51a70fe669..7cf0e27154 100755 --- a/tests/qemu-iotests/178 +++ b/tests/qemu-iotests/178 @@ -50,7 +50,7 @@ _make_test_img 1G $QEMU_IMG measure # missing arguments $QEMU_IMG measure --size 2G "$TEST_IMG" # only one allowed $QEMU_IMG measure "$TEST_IMG" a # only one filename allowed -$QEMU_IMG measure --object secret,id=3Dsec0,data=3DMTIzNDU2,format=3Dbase6= 4 # missing filename +$QEMU_IMG measure --object secret,id=3Dsec0,data=3DMTIzNDU2,format=3Dbase6= 4 # size or filename needed $QEMU_IMG measure --image-opts # missing filename $QEMU_IMG measure -f qcow2 # missing filename $QEMU_IMG measure -l snap1 # missing filename diff --git a/tests/qemu-iotests/178.out.qcow2 b/tests/qemu-iotests/178.out.= qcow2 index 9e7d8c44df..f59bf4b2fb 100644 --- a/tests/qemu-iotests/178.out.qcow2 +++ b/tests/qemu-iotests/178.out.qcow2 @@ -5,10 +5,10 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D10737= 41824 qemu-img: Either --size N or one filename must be specified. qemu-img: --size N cannot be used together with a filename. qemu-img: At most one filename argument is allowed. -qemu-img: --object, --image-opts, -f, and -l require a filename argument. -qemu-img: --object, --image-opts, -f, and -l require a filename argument. -qemu-img: --object, --image-opts, -f, and -l require a filename argument. -qemu-img: --object, --image-opts, -f, and -l require a filename argument. +qemu-img: Either --size N or one filename must be specified. +qemu-img: --image-opts, -f, and -l require a filename argument. +qemu-img: --image-opts, -f, and -l require a filename argument. +qemu-img: --image-opts, -f, and -l require a filename argument. qemu-img: Invalid option list: , qemu-img: Invalid parameter 'snapshot.foo' qemu-img: Failed in parsing snapshot param 'snapshot.foo' diff --git a/tests/qemu-iotests/178.out.raw b/tests/qemu-iotests/178.out.raw index 6478365905..404ca908d8 100644 --- a/tests/qemu-iotests/178.out.raw +++ b/tests/qemu-iotests/178.out.raw @@ -5,10 +5,10 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D10737= 41824 qemu-img: Either --size N or one filename must be specified. qemu-img: --size N cannot be used together with a filename. qemu-img: At most one filename argument is allowed. -qemu-img: --object, --image-opts, -f, and -l require a filename argument. -qemu-img: --object, --image-opts, -f, and -l require a filename argument. -qemu-img: --object, --image-opts, -f, and -l require a filename argument. -qemu-img: --object, --image-opts, -f, and -l require a filename argument. +qemu-img: Either --size N or one filename must be specified. +qemu-img: --image-opts, -f, and -l require a filename argument. +qemu-img: --image-opts, -f, and -l require a filename argument. +qemu-img: --image-opts, -f, and -l require a filename argument. qemu-img: Invalid option list: , qemu-img: Invalid parameter 'snapshot.foo' qemu-img: Failed in parsing snapshot param 'snapshot.foo' --=20 2.24.1