From 6db956039db8a6333265d458be561dc1bc2b4481 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 5 Apr 2010 16:53:57 +0200 Subject: block: get rid of the BDRV_O_FILE flag BDRV_O_FILE is only used to communicate between bdrv_file_open and bdrv_open. It affects two things: first bdrv_open only searches for protocols using find_protocol instead of all image formats and host drivers. We can easily move that to the caller and pass the found driver to bdrv_open. Second it is used to not force a read-write open of a snapshot file. But we never use bdrv_file_open to open snapshots and this behaviour doesn't make sense to start with. qemu-io abused the BDRV_O_FILE for it's growable option, switch it to using bdrv_file_open to make sure we only open files as growable were we can actually support that. This patch requires Kevin's "[PATCH] Replace calls of old bdrv_open" to be applied first. Signed-off-by: Christoph Hellwig Signed-off-by: Kevin Wolf --- qemu-io.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'qemu-io.c') diff --git a/qemu-io.c b/qemu-io.c index ffb5817..8517b90 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -1276,23 +1276,23 @@ static int openfile(char *name, int flags, int growable) return 1; } - bs = bdrv_new("hda"); - if (!bs) - return 1; - if (growable) { - flags |= BDRV_O_FILE; - } - - if (bdrv_open(bs, name, flags, NULL) < 0) { - fprintf(stderr, "%s: can't open device %s\n", progname, name); - bs = NULL; - return 1; + if (bdrv_file_open(&bs, name, flags)) { + fprintf(stderr, "%s: can't open device %s\n", progname, name); + return 1; + } + } else { + bs = bdrv_new("hda"); + if (!bs) + return 1; + + if (bdrv_open(bs, name, flags, NULL) < 0) { + fprintf(stderr, "%s: can't open device %s\n", progname, name); + bs = NULL; + return 1; + } } - if (growable) { - bs->growable = 1; - } return 0; } -- cgit v1.1