Skip to content

Commit

Permalink
qemu-img: report size overflow error message
Browse files Browse the repository at this point in the history
qemu-img will complain when qcow or qcow2
size overflow for 64 bits, report the right
message in this condition.

$./qemu-img create -f qcow2 /tmp/foo 0x10000000000000000
before change:
qemu-img: Invalid image size specified! You may use k, M, G or T suffixes for
qemu-img: kilobytes, megabytes, gigabytes and terabytes.

after change:
qemu-img: Image size must be less than 8 EiB!

[Resolved conflict with a930091 goto removal -- Stefan]

Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
liguang authored and stefanhaRH committed Jan 2, 2013
1 parent 37edbf7 commit 7944339
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions qemu-img.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -348,9 +348,13 @@ static int img_create(int argc, char **argv)
char *end; char *end;
sval = strtosz_suffix(argv[optind++], &end, STRTOSZ_DEFSUFFIX_B); sval = strtosz_suffix(argv[optind++], &end, STRTOSZ_DEFSUFFIX_B);
if (sval < 0 || *end) { if (sval < 0 || *end) {
error_report("Invalid image size specified! You may use k, M, G or " if (sval == -ERANGE) {
"T suffixes for "); error_report("Image size must be less than 8 EiB!");
error_report("kilobytes, megabytes, gigabytes and terabytes."); } else {
error_report("Invalid image size specified! You may use k, M, "
"G or T suffixes for ");
error_report("kilobytes, megabytes, gigabytes and terabytes.");
}
return 1; return 1;
} }
img_size = (uint64_t)sval; img_size = (uint64_t)sval;
Expand Down

0 comments on commit 7944339

Please sign in to comment.