qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qemu-io: use BDRV_O_FILE to implement the growable open option
@ 2009-07-15 21:11 Christoph Hellwig
  0 siblings, 0 replies; only message in thread
From: Christoph Hellwig @ 2009-07-15 21:11 UTC (permalink / raw)
  To: qemu-devel

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 <hch@lst.de>

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"

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-07-15 21:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-15 21:11 [Qemu-devel] [PATCH] qemu-io: use BDRV_O_FILE to implement the growable open option Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).