Skip to content

Commit

Permalink
block: Use bdrv_nb_sectors() in img_convert()
Browse files Browse the repository at this point in the history
Instead of bdrv_getlength().  Replace variable output_length by
output_sectors.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Benoit Canet <benoit@irqsave.net>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
Markus Armbruster authored and kevmw committed Aug 15, 2014
1 parent 30a7f2f commit 43716fa
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions qemu-img.c
Expand Up @@ -1469,13 +1469,13 @@ static int img_convert(int argc, char **argv)
buf = qemu_blockalign(out_bs, bufsectors * BDRV_SECTOR_SIZE);

if (skip_create) {
int64_t output_length = bdrv_getlength(out_bs);
if (output_length < 0) {
int64_t output_sectors = bdrv_nb_sectors(out_bs);
if (output_sectors < 0) {
error_report("unable to get output image length: %s\n",
strerror(-output_length));
strerror(-output_sectors));
ret = -1;
goto out;
} else if (output_length < total_sectors << BDRV_SECTOR_BITS) {
} else if (output_sectors < total_sectors) {
error_report("output file is smaller than input file");
ret = -1;
goto out;
Expand Down

0 comments on commit 43716fa

Please sign in to comment.