From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MRBlC-0005lA-9r for qemu-devel@nongnu.org; Wed, 15 Jul 2009 17:11:30 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MRBl7-0005hm-Jh for qemu-devel@nongnu.org; Wed, 15 Jul 2009 17:11:29 -0400 Received: from [199.232.76.173] (port=37503 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MRBl7-0005ha-BI for qemu-devel@nongnu.org; Wed, 15 Jul 2009 17:11:25 -0400 Received: from verein.lst.de ([213.95.11.210]:43490) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA1:24) (Exim 4.60) (envelope-from ) id 1MRBl6-0005q8-S9 for qemu-devel@nongnu.org; Wed, 15 Jul 2009 17:11:25 -0400 Received: from verein.lst.de (localhost [127.0.0.1]) by verein.lst.de (8.12.3/8.12.3/Debian-7.1) with ESMTP id n6FLBLgh018859 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Wed, 15 Jul 2009 23:11:21 +0200 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-7.2) id n6FLBLNU018857 for qemu-devel@nongnu.org; Wed, 15 Jul 2009 23:11:21 +0200 Date: Wed, 15 Jul 2009 23:11:21 +0200 From: Christoph Hellwig Message-ID: <20090715211121.GA18828@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] [PATCH] qemu-io: use BDRV_O_FILE to implement the growable open option List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Instead of doing our own check for protocols which fails because raw isn't formally a protocol but special cased in find_protocol specify the BDRV_O_FILE option to use the same code as bdrv_file_open does. While we're at it also add the missing documentation for -g to the main qemu-io help string. Signed-off-by: Christoph Hellwig Index: qemu/qemu-io.c =================================================================== --- qemu.orig/qemu-io.c 2009-07-15 20:20:29.288013364 +0200 +++ qemu/qemu-io.c 2009-07-15 20:27:28.653015235 +0200 @@ -1199,23 +1199,19 @@ static int openfile(char *name, int flag if (!bs) return 1; + if (growable) { + flags |= BDRV_O_FILE; + } + if (bdrv_open(bs, name, flags) == -1) { fprintf(stderr, "%s: can't open device %s\n", progname, name); bs = NULL; return 1; } - if (growable) { - if (!bs->drv || !bs->drv->protocol_name) { - fprintf(stderr, - "%s: only protocols can be opened growable\n", - progname); - return 1; - } bs->growable = 1; } - return 0; } @@ -1327,6 +1323,7 @@ static void usage(const char *name) " -r, --read-only export read-only\n" " -s, --snapshot use snapshot file\n" " -n, --nocache disable host cache\n" +" -g, --growable allow file to grow (only applies to protocols)\n" " -m, --misalign misalign allocations for O_DIRECT\n" " -h, --help display this help and exit\n" " -V, --version output version information and exit\n"