Commit 245014892041640d634ee4cf458e7961a78dfd53

Authored by aurel32
1 parent 72fcd388

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
Showing 1 changed file with 5 additions and 4 deletions
qemu-img.c
... ... @@ -220,6 +220,7 @@ static int img_create(int argc, char **argv)
220 220 const char *filename;
221 221 const char *base_filename = NULL;
222 222 uint64_t size;
  223 + double sizef;
223 224 const char *p;
224 225 BlockDriver *drv;
225 226  
... ... @@ -260,13 +261,13 @@ static int img_create(int argc, char **argv)
260 261 if (optind >= argc)
261 262 help();
262 263 p = argv[optind];
263   - size = strtoul(p, (char **)&p, 0);
  264 + sizef = strtod(p, (char **)&p);
264 265 if (*p == 'M') {
265   - size *= 1024 * 1024;
  266 + size = (uint64_t)(sizef * 1024 * 1024);
266 267 } else if (*p == 'G') {
267   - size *= 1024 * 1024 * 1024;
  268 + size = (uint64_t)(sizef * 1024 * 1024 * 1024);
268 269 } else if (*p == 'k' || *p == 'K' || *p == '\0') {
269   - size *= 1024;
  270 + size = (uint64_t)(sizef * 1024);
270 271 } else {
271 272 help();
272 273 }
... ...