summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162>2009-03-08 19:49:44 +0000
committeraurel32 <aurel32@c046a42c-6fe2-441c-8c8c-71466251a162>2009-03-08 19:49:44 +0000
commit245014892041640d634ee4cf458e7961a78dfd53 (patch)
treea3af406783c680b1dbfc91f4e96b9f21bac0cbd2
parent72fcd388b6a8f6b5c4874418a0152300a14b2d5b (diff)
downloadqemu-245014892041640d634ee4cf458e7961a78dfd53.tar.gz
qemu-245014892041640d634ee4cf458e7961a78dfd53.tar.bz2
qemu-245014892041640d634ee4cf458e7961a78dfd53.zip
qemu-img: accept sizes with decimal values
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6786 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r--qemu-img.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/qemu-img.c b/qemu-img.c
index 2af695fbe6..ad25cb3e64 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -220,6 +220,7 @@ static int img_create(int argc, char **argv)
const char *filename;
const char *base_filename = NULL;
uint64_t size;
+ double sizef;
const char *p;
BlockDriver *drv;
@@ -260,13 +261,13 @@ static int img_create(int argc, char **argv)
if (optind >= argc)
help();
p = argv[optind];
- size = strtoul(p, (char **)&p, 0);
+ sizef = strtod(p, (char **)&p);
if (*p == 'M') {
- size *= 1024 * 1024;
+ size = (uint64_t)(sizef * 1024 * 1024);
} else if (*p == 'G') {
- size *= 1024 * 1024 * 1024;
+ size = (uint64_t)(sizef * 1024 * 1024 * 1024);
} else if (*p == 'k' || *p == 'K' || *p == '\0') {
- size *= 1024;
+ size = (uint64_t)(sizef * 1024);
} else {
help();
}