Commit 1db6947dafa7f33a309130ccbf461748adac6da0
Committed by
Anthony Liguori
1 parent
08738984
qemu-io: use BDRV_O_FILE to implement the growable open option
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> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing
1 changed file
with
5 additions
and
8 deletions
qemu-io.c
| @@ -1237,23 +1237,19 @@ static int openfile(char *name, int flags, int growable) | @@ -1237,23 +1237,19 @@ static int openfile(char *name, int flags, int growable) | ||
| 1237 | if (!bs) | 1237 | if (!bs) |
| 1238 | return 1; | 1238 | return 1; |
| 1239 | 1239 | ||
| 1240 | + if (growable) { | ||
| 1241 | + flags |= BDRV_O_FILE; | ||
| 1242 | + } | ||
| 1243 | + | ||
| 1240 | if (bdrv_open(bs, name, flags) == -1) { | 1244 | if (bdrv_open(bs, name, flags) == -1) { |
| 1241 | fprintf(stderr, "%s: can't open device %s\n", progname, name); | 1245 | fprintf(stderr, "%s: can't open device %s\n", progname, name); |
| 1242 | bs = NULL; | 1246 | bs = NULL; |
| 1243 | return 1; | 1247 | return 1; |
| 1244 | } | 1248 | } |
| 1245 | 1249 | ||
| 1246 | - | ||
| 1247 | if (growable) { | 1250 | if (growable) { |
| 1248 | - if (!bs->drv || !bs->drv->protocol_name) { | ||
| 1249 | - fprintf(stderr, | ||
| 1250 | - "%s: only protocols can be opened growable\n", | ||
| 1251 | - progname); | ||
| 1252 | - return 1; | ||
| 1253 | - } | ||
| 1254 | bs->growable = 1; | 1251 | bs->growable = 1; |
| 1255 | } | 1252 | } |
| 1256 | - | ||
| 1257 | return 0; | 1253 | return 0; |
| 1258 | } | 1254 | } |
| 1259 | 1255 | ||
| @@ -1365,6 +1361,7 @@ static void usage(const char *name) | @@ -1365,6 +1361,7 @@ static void usage(const char *name) | ||
| 1365 | " -r, --read-only export read-only\n" | 1361 | " -r, --read-only export read-only\n" |
| 1366 | " -s, --snapshot use snapshot file\n" | 1362 | " -s, --snapshot use snapshot file\n" |
| 1367 | " -n, --nocache disable host cache\n" | 1363 | " -n, --nocache disable host cache\n" |
| 1364 | +" -g, --growable allow file to grow (only applies to protocols)\n" | ||
| 1368 | " -m, --misalign misalign allocations for O_DIRECT\n" | 1365 | " -m, --misalign misalign allocations for O_DIRECT\n" |
| 1369 | " -h, --help display this help and exit\n" | 1366 | " -h, --help display this help and exit\n" |
| 1370 | " -V, --version output version information and exit\n" | 1367 | " -V, --version output version information and exit\n" |