mirror of https://gitlab.com/qemu-project/qemu
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
This commit is contained in:
parent
72fcd388b6
commit
2450148920
|
@ -220,6 +220,7 @@ static int img_create(int argc, char **argv)
|
||||||
const char *filename;
|
const char *filename;
|
||||||
const char *base_filename = NULL;
|
const char *base_filename = NULL;
|
||||||
uint64_t size;
|
uint64_t size;
|
||||||
|
double sizef;
|
||||||
const char *p;
|
const char *p;
|
||||||
BlockDriver *drv;
|
BlockDriver *drv;
|
||||||
|
|
||||||
|
@ -260,13 +261,13 @@ static int img_create(int argc, char **argv)
|
||||||
if (optind >= argc)
|
if (optind >= argc)
|
||||||
help();
|
help();
|
||||||
p = argv[optind];
|
p = argv[optind];
|
||||||
size = strtoul(p, (char **)&p, 0);
|
sizef = strtod(p, (char **)&p);
|
||||||
if (*p == 'M') {
|
if (*p == 'M') {
|
||||||
size *= 1024 * 1024;
|
size = (uint64_t)(sizef * 1024 * 1024);
|
||||||
} else if (*p == 'G') {
|
} else if (*p == 'G') {
|
||||||
size *= 1024 * 1024 * 1024;
|
size = (uint64_t)(sizef * 1024 * 1024 * 1024);
|
||||||
} else if (*p == 'k' || *p == 'K' || *p == '\0') {
|
} else if (*p == 'k' || *p == 'K' || *p == '\0') {
|
||||||
size *= 1024;
|
size = (uint64_t)(sizef * 1024);
|
||||||
} else {
|
} else {
|
||||||
help();
|
help();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue