* [Qemu-devel] [PATCH] qemu-img: Allow creating zero sized images
@ 2009-10-28 10:36 Kevin Wolf
0 siblings, 0 replies; only message in thread
From: Kevin Wolf @ 2009-10-28 10:36 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf
A size of 0 should be valid and cannot be treated as "missing value". Use -1
for this purpose instead.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
qemu-img.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index 204f618..00fcade 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -297,13 +297,16 @@ static int img_create(int argc, char **argv)
return 0;
}
+ /* Create parameter list with default values */
+ param = parse_option_parameters("", drv->create_options, param);
+ set_option_parameter_int(param, BLOCK_OPT_SIZE, -1);
+
+ /* Parse -o options */
if (options) {
param = parse_option_parameters(options, drv->create_options, param);
if (param == NULL) {
error("Invalid options for file format '%s'.", fmt);
}
- } else {
- param = parse_option_parameters("", drv->create_options, param);
}
/* Get the filename */
@@ -321,7 +324,7 @@ static int img_create(int argc, char **argv)
// The size for the image must always be specified, with one exception:
// If we are using a backing file, we can obtain the size from there
- if (get_option_parameter(param, BLOCK_OPT_SIZE)->value.n == 0) {
+ if (get_option_parameter(param, BLOCK_OPT_SIZE)->value.n == -1) {
QEMUOptionParameter *backing_file =
get_option_parameter(param, BLOCK_OPT_BACKING_FILE);
--
1.6.2.5
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2009-10-28 10:37 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-28 10:36 [Qemu-devel] [PATCH] qemu-img: Allow creating zero sized images Kevin Wolf
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).