" 'skip=N' skip N bs-sized blocks at the start of input\n";
printf("%s\nSupported formats:", help_msg);
- bdrv_iterate_format(format_print, NULL);
+ bdrv_iterate_format(format_print, NULL, false);
printf("\n\n" QEMU_HELP_BOTTOM "\n");
exit(EXIT_SUCCESS);
}
count, &count, NULL, NULL);
}
if (ret < 0) {
+ error_report("error while reading block status of sector %" PRId64
+ ": %s", sector_num, strerror(-ret));
return ret;
}
n = DIV_ROUND_UP(count, BDRV_SECTOR_SIZE);
}
ret = blk_co_pwrite_zeroes(s->target,
sector_num << BDRV_SECTOR_BITS,
- n << BDRV_SECTOR_BITS, 0);
+ n << BDRV_SECTOR_BITS,
+ BDRV_REQ_MAY_UNMAP);
if (ret < 0) {
return ret;
}
if (!s->has_zero_init && !s->target_has_backing &&
bdrv_can_write_zeroes_with_unmap(blk_bs(s->target)))
{
- ret = blk_make_zero(s->target, BDRV_REQ_MAY_UNMAP);
+ ret = blk_make_zero(s->target, BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK);
if (ret == 0) {
s->has_zero_init = true;
}
return 0;
}
-static void dump_map_entry(OutputFormat output_format, MapEntry *e,
- MapEntry *next)
+static int dump_map_entry(OutputFormat output_format, MapEntry *e,
+ MapEntry *next)
{
switch (output_format) {
case OFORMAT_HUMAN:
if (e->data && !e->has_offset) {
error_report("File contains external, encrypted or compressed clusters.");
- exit(1);
+ return -1;
}
if (e->data && !e->zero) {
printf("%#-16"PRIx64"%#-16"PRIx64"%#-16"PRIx64"%s\n",
}
break;
}
+ return 0;
}
static int get_block_status(BlockDriverState *bs, int64_t offset,
}
if (curr.length > 0) {
- dump_map_entry(output_format, &curr, &next);
+ ret = dump_map_entry(output_format, &curr, &next);
+ if (ret < 0) {
+ goto out;
+ }
}
curr = next;
}
- dump_map_entry(output_format, &curr, NULL);
+ ret = dump_map_entry(output_format, &curr, NULL);
out:
blk_unref(blk);