From patchwork Fri Dec 20 18:28:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 304227 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5B7212C009C for ; Sat, 21 Dec 2013 05:39:01 +1100 (EST) Received: from localhost ([::1]:51171 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vu4yQ-0000E7-Hq for incoming@patchwork.ozlabs.org; Fri, 20 Dec 2013 13:38:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36591) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vu4ol-0004XO-R0 for qemu-devel@nongnu.org; Fri, 20 Dec 2013 13:29:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vu4of-0001bk-Rw for qemu-devel@nongnu.org; Fri, 20 Dec 2013 13:28:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38084) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vu4of-0001bX-K9 for qemu-devel@nongnu.org; Fri, 20 Dec 2013 13:28:53 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rBKISrBh014810 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 20 Dec 2013 13:28:53 -0500 Received: from localhost (ovpn-116-19.ams2.redhat.com [10.36.116.19]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rBKISoHP029316 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Fri, 20 Dec 2013 13:28:52 -0500 From: Max Reitz To: qemu-devel@nongnu.org Date: Fri, 20 Dec 2013 19:28:20 +0100 Message-Id: <1387564104-15315-21-git-send-email-mreitz@redhat.com> In-Reply-To: <1387564104-15315-1-git-send-email-mreitz@redhat.com> References: <1387564104-15315-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Fam Zheng , Stefan Hajnoczi , Max Reitz Subject: [Qemu-devel] [PATCH v7 20/24] qemu-io: Make filename optional X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Giving a filename is actually not essential, since it can be specified through the options as well - on the contrary: Sometimes a filename must not be given. Signed-off-by: Max Reitz Reviewed-by: Kevin Wolf --- qemu-io.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/qemu-io.c b/qemu-io.c index f180813..a0e0e22 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -160,11 +160,13 @@ static int open_f(BlockDriverState *bs, int argc, char **argv) flags |= BDRV_O_RDWR; } - if (optind != argc - 1) { + if (optind == argc - 1) { + return openfile(argv[optind], flags, growable, opts); + } else if (optind == argc) { + return openfile(NULL, flags, growable, opts); + } else { return qemuio_command_usage(&open_cmd); } - - return openfile(argv[optind], flags, growable, opts); } static int quit_f(BlockDriverState *bs, int argc, char **argv)