Lines Matching +full:next +full:- +full:level +full:- +full:cache
4 * Copyright (c) 2003-2008 Fabrice Bellard
28 #include "qemu/help-texts.h"
29 #include "qemu/qemu-progress.h"
30 #include "qemu-version.h"
32 #include "qapi/qapi-commands-block-core.h"
33 #include "qapi/qapi-visit-block-core.h"
34 #include "qapi/qobject-output-visitor.h"
38 #include "qemu/config-file.h"
40 #include "qemu/error-report.h"
42 #include "qemu/main-loop.h"
48 #include "system/block-backend.h"
51 #include "block/dirty-bitmap.h"
56 #include "block/throttle-groups.h"
58 #define QEMU_IMG_VERSION "qemu-img version " QEMU_FULL_VERSION \
96 /* Default to cache=writeback as data integrity is not important for qemu-img */
113 error_printf("Try 'qemu-img --help' for more information\n"); in error_exit()
129 /* Please keep in synch with docs/tools/qemu-img.rst */
135 "usage: qemu-img [standard options] command [command options]\n" in help()
138 " '-h', '--help' display this help and exit\n" in help()
139 " '-V', '--version' output version information and exit\n" in help()
140 " '-T', '--trace' [[enable=]<pattern>][,events=<file>][,file=<file>]\n" in help()
146 #include "qemu-img-cmds.h" in help()
156 " 'cache' is the cache mode used to write the output disk image, the valid\n" in help()
159 " 'src_cache' is the cache mode used to read input disk images, the valid\n" in help()
160 " options are the same as for the 'cache' option\n" in help()
168 " name=value format. Use -o help for an overview of the options supported by\n" in help()
173 " '-c' indicates that target image must be compressed (qcow format only)\n" in help()
174 " '-u' allows unsafe backing chains. For rebasing, it is assumed that old and\n" in help()
179 " '-h' with or without a command shows this help and lists the supported formats\n" in help()
180 " '-p' show progress of command (only certain commands)\n" in help()
181 " '-q' use Quiet mode - do not print any output (except errors)\n" in help()
182 " '-S' indicates the consecutive number of bytes (defaults to 4k) that must\n" in help()
183 " contain only zeros for qemu-img to create a sparse image during\n" in help()
187 " '--output' takes the format in which the output must be done (human or json)\n" in help()
188 " '-n' skips the target volume creation (useful if the volume is created\n" in help()
189 " prior to running qemu-img)\n" in help()
193 " actions from '--add', '--remove', '--clear', '--enable', '--disable',\n" in help()
194 " or '--merge source'\n" in help()
195 " '-g granularity' sets the granularity for '--add' actions\n" in help()
196 " '-b source' and '-F src_fmt' tell '--merge' actions to find the source\n" in help()
200 " '-r' tries to repair any inconsistencies that are found during the check.\n" in help()
201 " '-r leaks' repairs only cluster leaks, whereas '-r all' fixes all\n" in help()
206 " '--bitmaps' copies all top-level persistent bitmaps to destination\n" in help()
207 " '-m' specifies how many coroutines work in parallel during the convert\n" in help()
209 " '-W' allow to write to the target out of order rather than sequential\n" in help()
213 " '-a' applies a snapshot (revert disk to saved state)\n" in help()
214 " '-c' creates a snapshot\n" in help()
215 " '-d' deletes a snapshot\n" in help()
216 " '-l' lists all snapshots in the given image\n" in help()
219 " '-f' first image format\n" in help()
220 " '-F' second image format\n" in help()
221 " '-s' run in Strict mode - fail on different image size or sector allocation\n" in help()
229 " 'skip=N' skip N bs-sized blocks at the start of input\n"; in help()
256 for (i = len; i > 0 && list[i - 1] == ','; i--) { in is_valid_option_list()
258 if ((len - i) % 2) { in is_valid_option_list()
271 return -1; in accumulate_options()
319 if (!drv->create_opts) { in print_block_option_help()
324 create_opts = qemu_opts_append(create_opts, drv->create_opts); in print_block_option_help()
332 if (!proto_drv->create_opts) { in print_block_option_help()
334 proto_drv->format_name); in print_block_option_help()
338 create_opts = qemu_opts_append(create_opts, proto_drv->create_opts); in print_block_option_help()
351 "The protocol level may support further options.\n" in print_block_option_help()
370 error_report("--force-share/-U conflicts with image options"); in img_open_opts()
422 if (g_str_has_suffix(name, "key-secret")) { in img_add_key_secrets()
439 error_report("--image-opts and --format are mutually exclusive"); in img_open()
471 return -1; in add_old_style_options()
478 return -1; in add_old_style_options()
491 if (err < 0 && err != -ERANGE) { in cvtnum_full()
498 if (err == -ERANGE || res > max || res < min) { in cvtnum_full()
501 return -ERANGE; in cvtnum_full()
514 uint64_t img_size = -1; in img_create()
532 if (c == -1) { in img_create()
537 missing_argument(argv[optind - 1]); in img_create()
540 unrecognized_option(argv[optind - 1]); in img_create()
622 qprintf(quiet, "%s\n", str->str); in dump_json_image_check()
630 if (!(check->corruptions || check->leaks || check->check_errors)) { in dump_human_image_check()
633 if (check->corruptions) { in dump_human_image_check()
637 check->corruptions); in dump_human_image_check()
640 if (check->leaks) { in dump_human_image_check()
644 check->leaks); in dump_human_image_check()
647 if (check->check_errors) { in dump_human_image_check()
651 check->check_errors); in dump_human_image_check()
655 if (check->total_clusters != 0 && check->allocated_clusters != 0) { in dump_human_image_check()
658 check->allocated_clusters, check->total_clusters, in dump_human_image_check()
659 check->allocated_clusters * 100.0 / check->total_clusters, in dump_human_image_check()
660 check->fragmented_clusters * 100.0 / check->allocated_clusters, in dump_human_image_check()
661 check->compressed_clusters * 100.0 / in dump_human_image_check()
662 check->allocated_clusters); in dump_human_image_check()
665 if (check->image_end_offset) { in dump_human_image_check()
667 "Image end offset: %" PRId64 "\n", check->image_end_offset); in dump_human_image_check()
685 check->filename = g_strdup(filename); in collect_image_check()
686 check->format = g_strdup(bdrv_get_format_name(bs)); in collect_image_check()
687 check->check_errors = result.check_errors; in collect_image_check()
688 check->corruptions = result.corruptions; in collect_image_check()
689 check->has_corruptions = result.corruptions != 0; in collect_image_check()
690 check->leaks = result.leaks; in collect_image_check()
691 check->has_leaks = result.leaks != 0; in collect_image_check()
692 check->corruptions_fixed = result.corruptions_fixed; in collect_image_check()
693 check->has_corruptions_fixed = result.corruptions_fixed != 0; in collect_image_check()
694 check->leaks_fixed = result.leaks_fixed; in collect_image_check()
695 check->has_leaks_fixed = result.leaks_fixed != 0; in collect_image_check()
696 check->image_end_offset = result.image_end_offset; in collect_image_check()
697 check->has_image_end_offset = result.image_end_offset != 0; in collect_image_check()
698 check->total_clusters = result.bfi.total_clusters; in collect_image_check()
699 check->has_total_clusters = result.bfi.total_clusters != 0; in collect_image_check()
700 check->allocated_clusters = result.bfi.allocated_clusters; in collect_image_check()
701 check->has_allocated_clusters = result.bfi.allocated_clusters != 0; in collect_image_check()
702 check->fragmented_clusters = result.bfi.fragmented_clusters; in collect_image_check()
703 check->has_fragmented_clusters = result.bfi.fragmented_clusters != 0; in collect_image_check()
704 check->compressed_clusters = result.bfi.compressed_clusters; in collect_image_check()
705 check->has_compressed_clusters = result.bfi.compressed_clusters != 0; in collect_image_check()
713 * 0 - Check completed, image is good
714 * 1 - Check not completed because of internal errors
715 * 2 - Check completed, image is corrupted
716 * 3 - Check completed, image has leaked clusters, but is good otherwise
717 * 63 - Checks are not supported by the image format
723 const char *filename, *fmt, *output, *cache; in img_check() local
736 cache = BDRV_DEFAULT_CACHE; in img_check()
746 {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, in img_check()
747 {"force-share", no_argument, 0, 'U'}, in img_check()
752 if (c == -1) { in img_check()
757 missing_argument(argv[optind - 1]); in img_check()
760 unrecognized_option(argv[optind - 1]); in img_check()
776 error_exit("Unknown option value for -r " in img_check()
784 cache = optarg; in img_check()
800 if (optind != argc - 1) { in img_check()
810 error_report("--output must be used with human or json as argument."); in img_check()
814 ret = bdrv_parse_cache_mode(cache, &flags, &writethrough); in img_check()
816 error_report("Invalid source cache option: %s", cache); in img_check()
830 if (ret == -ENOTSUP) { in img_check()
836 if (check->corruptions_fixed || check->leaks_fixed) { in img_check()
840 leaks_fixed = check->leaks_fixed; in img_check()
841 has_leaks_fixed = check->has_leaks_fixed; in img_check()
842 corruptions_fixed = check->corruptions_fixed; in img_check()
843 has_corruptions_fixed = check->has_corruptions_fixed; in img_check()
851 check->leaks_fixed, in img_check()
852 check->corruptions_fixed); in img_check()
859 check->leaks_fixed = leaks_fixed; in img_check()
860 check->has_leaks_fixed = has_leaks_fixed; in img_check()
861 check->corruptions_fixed = corruptions_fixed; in img_check()
862 check->has_corruptions_fixed = has_corruptions_fixed; in img_check()
876 if (ret || check->check_errors) { in img_check()
878 error_report("Check failed: %s", strerror(-ret)); in img_check()
886 if (check->corruptions) { in img_check()
888 } else if (check->leaks) { in img_check()
910 error_setg_errno(cbi->errp, -ret, "Block job failed"); in common_block_job_cb()
921 job_ref_locked(&job->job); in run_block_job()
927 progress_get_snapshot(&job->job.progress, &progress_current, in run_block_job()
934 } while (!job_is_ready_locked(&job->job) && in run_block_job()
935 !job_is_completed_locked(&job->job)); in run_block_job()
937 if (!job_is_completed_locked(&job->job)) { in run_block_job()
938 ret = job_complete_sync_locked(&job->job, errp); in run_block_job()
940 ret = job->job.ret; in run_block_job()
942 job_unref_locked(&job->job); in run_block_job()
954 const char *filename, *fmt, *cache, *base; in img_commit() local
966 cache = BDRV_DEFAULT_CACHE; in img_commit()
972 {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, in img_commit()
977 if (c == -1) { in img_commit()
982 missing_argument(argv[optind - 1]); in img_commit()
985 unrecognized_option(argv[optind - 1]); in img_commit()
994 cache = optarg; in img_commit()
998 /* -b implies -d */ in img_commit()
1030 if (optind != argc - 1) { in img_commit()
1036 ret = bdrv_parse_cache_mode(cache, &flags, &writethrough); in img_commit()
1038 error_report("Invalid cache option: %s", cache); in img_commit()
1065 * behavior of qemu-img commit is using the immediate backing file. */ in img_commit()
1112 if (ret == -ENOTSUP) { in img_commit()
1134 error_setg_errno(&local_err, -ret, "Error while closing the image"); in img_commit()
1148 * Returns -1 if 'buf' contains only zeroes, otherwise the byte index
1150 * non-zero byte. This function is robust to a buffer that is not
1151 * sector-aligned.
1163 if (i < n && !buffer_is_zero(buf + i, n - end)) { in find_nonzero()
1166 return -1; in find_nonzero()
1171 * a non-NUL byte.
1206 tail = (sector_num + i) & (alignment - 1); in is_allocated_sectors()
1210 * For sure next sector after i is data, and it will rewrite this in is_allocated_sectors()
1217 i += alignment - tail; in is_allocated_sectors()
1221 * For sure next sector after i is data, and it will rewrite this in is_allocated_sectors()
1225 i -= tail; in is_allocated_sectors()
1254 n -= *pnum; in is_allocated_sectors_min()
1262 n -= *pnum; in is_allocated_sectors_min()
1279 * Returns 0 if the first chunk of each buffer matches, non-zero otherwise.
1299 int64_t len = MIN(bytes - i, chsize); in compare_buffers()
1316 * Intended for use by 'qemu-img compare': Returns 0 in case sectors are
1317 * filled with 0, 1 if sectors contain non-zero data (this is a comparison
1338 offset, filename, strerror(-ret)); in check_empty_sectors()
1354 * 0 - Images are identical or the requested help was printed
1355 * 1 - Images differ
1356 * >1 - Error occurred
1360 const char *fmt1 = NULL, *fmt2 = NULL, *cache, *filename1, *filename2; in img_compare() local
1367 int ret = 0; /* return value - 0 Ident, 1 Different, >1 Error */ in img_compare()
1379 cache = BDRV_DEFAULT_CACHE; in img_compare()
1384 {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, in img_compare()
1385 {"force-share", no_argument, 0, 'U'}, in img_compare()
1390 if (c == -1) { in img_compare()
1395 missing_argument(argv[optind - 1]); in img_compare()
1398 unrecognized_option(argv[optind - 1]); in img_compare()
1410 cache = optarg; in img_compare()
1451 if (optind != argc - 2) { in img_compare()
1461 ret = bdrv_parse_cache_mode(cache, &flags, &writethrough); in img_compare()
1463 error_report("Invalid source cache option: %s", cache); in img_compare()
1489 filename1, strerror(-total_size1)); in img_compare()
1496 filename2, strerror(-total_size2)); in img_compare()
1515 total_size1 - offset, &pnum1, NULL, in img_compare()
1525 total_size2 - offset, &pnum2, NULL, in img_compare()
1556 offset, filename1, strerror(-ret)); in img_compare()
1564 offset, filename2, strerror(-ret)); in img_compare()
1608 progress_base - offset, &chunk, in img_compare()
1653 merge_src->type = QTYPE_QDICT; in do_dirty_bitmap_merge()
1654 merge_src->u.external.node = g_strdup(src_node); in do_dirty_bitmap_merge()
1655 merge_src->u.external.name = g_strdup(src_name); in do_dirty_bitmap_merge()
1709 while (sector_num - *src_cur_offset >= s->src_sectors[*src_cur]) { in convert_select_part()
1710 *src_cur_offset += s->src_sectors[*src_cur]; in convert_select_part()
1712 assert(*src_cur < s->src_num); in convert_select_part()
1725 assert(s->total_sectors > sector_num); in convert_iteration_sectors()
1726 n = MIN(s->total_sectors - sector_num, BDRV_REQUEST_MAX_SECTORS); in convert_iteration_sectors()
1728 if (s->target_backing_sectors >= 0) { in convert_iteration_sectors()
1729 if (sector_num >= s->target_backing_sectors) { in convert_iteration_sectors()
1731 } else if (sector_num + n > s->target_backing_sectors) { in convert_iteration_sectors()
1734 n = s->target_backing_sectors - sector_num; in convert_iteration_sectors()
1738 if (s->sector_next_status <= sector_num) { in convert_iteration_sectors()
1739 uint64_t offset = (sector_num - src_cur_offset) * BDRV_SECTOR_SIZE; in convert_iteration_sectors()
1742 BlockDriverState *src_bs = blk_bs(s->src[src_cur]); in convert_iteration_sectors()
1745 if (s->target_has_backing) { in convert_iteration_sectors()
1758 if (s->salvage) { in convert_iteration_sectors()
1760 if (!s->quiet) { in convert_iteration_sectors()
1763 strerror(-ret)); in convert_iteration_sectors()
1774 "%" PRIu64 ": %s", offset, strerror(-ret)); in convert_iteration_sectors()
1783 * Avoid that s->sector_next_status becomes unaligned to the source in convert_iteration_sectors()
1787 tail = (sector_num - src_cur_offset + n) % s->src_alignment[src_cur]; in convert_iteration_sectors()
1789 n -= tail; in convert_iteration_sectors()
1793 s->status = post_backing_zero ? BLK_BACKING_FILE : BLK_ZERO; in convert_iteration_sectors()
1795 s->status = BLK_DATA; in convert_iteration_sectors()
1797 s->status = s->target_has_backing ? BLK_BACKING_FILE : BLK_DATA; in convert_iteration_sectors()
1800 s->sector_next_status = sector_num + n; in convert_iteration_sectors()
1803 n = MIN(n, s->sector_next_status - sector_num); in convert_iteration_sectors()
1804 if (s->status == BLK_DATA) { in convert_iteration_sectors()
1805 n = MIN(n, s->buf_sectors); in convert_iteration_sectors()
1811 if (s->compressed) { in convert_iteration_sectors()
1812 if (n < s->cluster_sectors) { in convert_iteration_sectors()
1813 n = MIN(s->cluster_sectors, s->total_sectors - sector_num); in convert_iteration_sectors()
1814 s->status = BLK_DATA; in convert_iteration_sectors()
1816 n = QEMU_ALIGN_DOWN(n, s->cluster_sectors); in convert_iteration_sectors()
1829 assert(nb_sectors <= s->buf_sectors); in convert_co_read()
1837 * nb_sectors that spreads into the next part. So we must be able to in convert_co_read()
1840 blk = s->src[src_cur]; in convert_co_read()
1841 bs_sectors = s->src_sectors[src_cur]; in convert_co_read()
1843 offset = (sector_num - src_cur_offset) << BDRV_SECTOR_BITS; in convert_co_read()
1845 n = MIN(nb_sectors, bs_sectors - (sector_num - src_cur_offset)); in convert_co_read()
1852 if (s->salvage) { in convert_co_read()
1857 if (!s->quiet) { in convert_co_read()
1859 ": %s", offset, strerror(-ret)); in convert_co_read()
1869 nb_sectors -= n; in convert_co_read()
1885 BdrvRequestFlags flags = s->compressed ? BDRV_REQ_WRITE_COMPRESSED : 0; in convert_co_write()
1892 assert(s->target_has_backing); in convert_co_write()
1896 /* If we're told to keep the target fully allocated (-S 0) or there in convert_co_write()
1897 * is real non-zero data, we must write it. Otherwise we can treat in convert_co_write()
1902 if (!s->min_sparse || in convert_co_write()
1903 (!s->compressed && in convert_co_write()
1904 is_allocated_sectors_min(buf, n, &n, s->min_sparse, in convert_co_write()
1905 sector_num, s->alignment)) || in convert_co_write()
1906 (s->compressed && in convert_co_write()
1909 ret = blk_co_pwrite(s->target, sector_num << BDRV_SECTOR_BITS, in convert_co_write()
1916 /* fall-through */ in convert_co_write()
1919 if (s->has_zero_init) { in convert_co_write()
1920 assert(!s->target_has_backing); in convert_co_write()
1923 ret = blk_co_pwrite_zeroes(s->target, in convert_co_write()
1934 nb_sectors -= n; in convert_co_write()
1953 offset = (sector_num - src_cur_offset) << BDRV_SECTOR_BITS; in convert_co_copy_range()
1954 blk = s->src[src_cur]; in convert_co_copy_range()
1955 bs_sectors = s->src_sectors[src_cur]; in convert_co_copy_range()
1957 n = MIN(nb_sectors, bs_sectors - (sector_num - src_cur_offset)); in convert_co_copy_range()
1959 ret = blk_co_copy_range(blk, offset, s->target, in convert_co_copy_range()
1967 nb_sectors -= n; in convert_co_copy_range()
1977 int index = -1; in convert_co_do_copy()
1979 for (i = 0; i < s->num_coroutines; i++) { in convert_co_do_copy()
1980 if (s->co[i] == qemu_coroutine_self()) { in convert_co_do_copy()
1987 s->running_coroutines++; in convert_co_do_copy()
1988 buf = blk_blockalign(s->target, s->buf_sectors * BDRV_SECTOR_SIZE); in convert_co_do_copy()
1996 qemu_co_mutex_lock(&s->lock); in convert_co_do_copy()
1997 if (s->ret != -EINPROGRESS || s->sector_num >= s->total_sectors) { in convert_co_do_copy()
1998 qemu_co_mutex_unlock(&s->lock); in convert_co_do_copy()
2002 n = convert_iteration_sectors(s, s->sector_num); in convert_co_do_copy()
2005 qemu_co_mutex_unlock(&s->lock); in convert_co_do_copy()
2006 s->ret = n; in convert_co_do_copy()
2010 sector_num = s->sector_num; in convert_co_do_copy()
2011 status = s->status; in convert_co_do_copy()
2012 if (!s->min_sparse && s->status == BLK_ZERO) { in convert_co_do_copy()
2013 n = MIN(n, s->buf_sectors); in convert_co_do_copy()
2017 s->sector_num += n; in convert_co_do_copy()
2018 qemu_co_mutex_unlock(&s->lock); in convert_co_do_copy()
2020 if (status == BLK_DATA || (!s->min_sparse && status == BLK_ZERO)) { in convert_co_do_copy()
2021 s->allocated_done += n; in convert_co_do_copy()
2022 qemu_progress_print(100.0 * s->allocated_done / in convert_co_do_copy()
2023 s->allocated_sectors, 0); in convert_co_do_copy()
2027 copy_range = s->copy_range && s->status == BLK_DATA; in convert_co_do_copy()
2032 sector_num * BDRV_SECTOR_SIZE, strerror(-ret)); in convert_co_do_copy()
2033 s->ret = ret; in convert_co_do_copy()
2035 } else if (!s->min_sparse && status == BLK_ZERO) { in convert_co_do_copy()
2040 if (s->wr_in_order) { in convert_co_do_copy()
2042 while (s->wr_offs != sector_num && s->ret == -EINPROGRESS) { in convert_co_do_copy()
2043 s->wait_sector_num[index] = sector_num; in convert_co_do_copy()
2046 s->wait_sector_num[index] = -1; in convert_co_do_copy()
2049 if (s->ret == -EINPROGRESS) { in convert_co_do_copy()
2055 s->copy_range = false; in convert_co_do_copy()
2063 sector_num * BDRV_SECTOR_SIZE, strerror(-ret)); in convert_co_do_copy()
2064 s->ret = ret; in convert_co_do_copy()
2068 if (s->wr_in_order) { in convert_co_do_copy()
2071 s->wr_offs = sector_num + n; in convert_co_do_copy()
2072 for (i = 0; i < s->num_coroutines; i++) { in convert_co_do_copy()
2073 if (s->co[i] && s->wait_sector_num[i] == s->wr_offs) { in convert_co_do_copy()
2075 * A -> B -> A cannot occur because A has in convert_co_do_copy()
2076 * s->wait_sector_num[i] == -1 during A -> B. Therefore in convert_co_do_copy()
2079 qemu_coroutine_enter(s->co[i]); in convert_co_do_copy()
2087 s->co[index] = NULL; in convert_co_do_copy()
2088 s->running_coroutines--; in convert_co_do_copy()
2089 if (!s->running_coroutines && s->ret == -EINPROGRESS) { in convert_co_do_copy()
2091 s->ret = 0; in convert_co_do_copy()
2101 if (!s->has_zero_init && s->target_is_new && s->min_sparse && in convert_do_copy()
2102 !s->target_has_backing) { in convert_do_copy()
2104 s->has_zero_init = bdrv_has_zero_init(blk_bs(s->target)); in convert_do_copy()
2110 if (s->compressed) { in convert_do_copy()
2111 if (s->cluster_sectors <= 0 || s->cluster_sectors > s->buf_sectors) { in convert_do_copy()
2113 return -EINVAL; in convert_do_copy()
2115 s->buf_sectors = s->cluster_sectors; in convert_do_copy()
2118 while (sector_num < s->total_sectors) { in convert_do_copy()
2125 if (s->status == BLK_DATA || (!s->min_sparse && s->status == BLK_ZERO)) in convert_do_copy()
2127 s->allocated_sectors += n; in convert_do_copy()
2133 s->sector_next_status = 0; in convert_do_copy()
2134 s->ret = -EINPROGRESS; in convert_do_copy()
2136 qemu_co_mutex_init(&s->lock); in convert_do_copy()
2137 for (i = 0; i < s->num_coroutines; i++) { in convert_do_copy()
2138 s->co[i] = qemu_coroutine_create(convert_co_do_copy, s); in convert_do_copy()
2139 s->wait_sector_num[i] = -1; in convert_do_copy()
2140 qemu_coroutine_enter(s->co[i]); in convert_do_copy()
2143 while (s->running_coroutines) { in convert_do_copy()
2147 if (s->compressed && !s->ret) { in convert_do_copy()
2149 ret = blk_pwrite_compressed(s->target, 0, 0, NULL); in convert_do_copy()
2155 return s->ret; in convert_do_copy()
2165 return -1; in convert_check_bitmaps()
2174 error_printf("Try --skip-broken-bitmaps, or " in convert_check_bitmaps()
2175 "use 'qemu-img bitmap --remove' to delete it\n"); in convert_check_bitmaps()
2176 return -1; in convert_check_bitmaps()
2199 qmp_block_dirty_bitmap_add(dst->node_name, name, in convert_copy_bitmaps()
2206 return -1; in convert_copy_bitmaps()
2209 do_dirty_bitmap_merge(dst->node_name, name, src->node_name, name, in convert_copy_bitmaps()
2213 qmp_block_dirty_bitmap_remove(dst->node_name, name, NULL); in convert_copy_bitmaps()
2214 return -1; in convert_copy_bitmaps()
2237 const char *fmt = NULL, *out_fmt = NULL, *cache = "unsafe", in img_convert() local
2251 int64_t ret = -EINVAL; in img_convert()
2271 {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, in img_convert()
2272 {"force-share", no_argument, 0, 'U'}, in img_convert()
2273 {"target-image-opts", no_argument, 0, OPTION_TARGET_IMAGE_OPTS}, in img_convert()
2275 {"target-is-zero", no_argument, 0, OPTION_TARGET_IS_ZERO}, in img_convert()
2277 {"skip-broken-bitmaps", no_argument, 0, OPTION_SKIP_BROKEN}, in img_convert()
2282 if (c == -1) { in img_convert()
2287 missing_argument(argv[optind - 1]); in img_convert()
2290 unrecognized_option(argv[optind - 1]); in img_convert()
2355 cache = optarg; in img_convert()
2420 error_report("Use of --skip-broken-bitmaps requires --bitmaps"); in img_convert()
2425 error_report("Cannot enable copy offloading when -c is used"); in img_convert()
2430 error_report("Cannot enable copy offloading when -S is used"); in img_convert()
2440 error_report("--target-image-opts requires use of -n flag"); in img_convert()
2445 error_report("-o has no effect when skipping image creation"); in img_convert()
2450 error_report("--target-is-zero requires use of -n flag"); in img_convert()
2454 s.src_num = argc - optind - 1; in img_convert()
2455 out_filename = s.src_num >= 1 ? argv[argc - 1] : NULL; in img_convert()
2472 /* ret is still -EINVAL until here */ in img_convert()
2475 error_report("Invalid source cache option: %s", src_cache); in img_convert()
2496 ret = -1; in img_convert()
2502 argv[optind + bs_i], strerror(-s.src_sectors[bs_i])); in img_convert()
2503 ret = -1; in img_convert()
2507 s.src_alignment[bs_i] = DIV_ROUND_UP(src_bs->bl.request_alignment, in img_convert()
2524 ret = -1; in img_convert()
2533 ret = -1; in img_convert()
2542 ret = -1; in img_convert()
2549 ret = -1; in img_convert()
2553 if (!drv->create_opts) { in img_convert()
2555 drv->format_name); in img_convert()
2556 ret = -1; in img_convert()
2560 if (!proto_drv->create_opts) { in img_convert()
2562 proto_drv->format_name); in img_convert()
2563 ret = -1; in img_convert()
2567 create_opts = qemu_opts_append(create_opts, drv->create_opts); in img_convert()
2568 create_opts = qemu_opts_append(create_opts, proto_drv->create_opts); in img_convert()
2574 ret = -1; in img_convert()
2587 /* Get backing file name if -o backing_file was used */ in img_convert()
2595 error_report("Cannot use --target-is-zero when the destination " in img_convert()
2603 ret = -1; in img_convert()
2611 ret = -1; in img_convert()
2627 ret = -1; in img_convert()
2634 ret = -1; in img_convert()
2643 ret = -1; in img_convert()
2652 ret = -1; in img_convert()
2682 ret = bdrv_parse_cache_mode(cache, &flags, &writethrough); in img_convert()
2684 error_report("Invalid cache option: %s", cache); in img_convert()
2700 /* TODO ultimately we should allow --target-image-opts in img_convert()
2701 * to be used even when -n is not given. in img_convert()
2710 ret = -1; in img_convert()
2717 out_bs->drv->format_name); in img_convert()
2718 ret = -1; in img_convert()
2722 if (s.compressed && !block_driver_can_compress(out_bs->drv)) { in img_convert()
2724 ret = -1; in img_convert()
2733 MAX(out_bs->bl.opt_transfer >> BDRV_SECTOR_BITS, in img_convert()
2734 out_bs->bl.pdiscard_alignment >> in img_convert()
2740 DIV_ROUND_UP(out_bs->bl.request_alignment, in img_convert()
2748 strerror(-output_sectors)); in img_convert()
2749 ret = -1; in img_convert()
2753 ret = -1; in img_convert()
2768 s.target_backing_sectors = -1; in img_convert()
2847 printf("%s\n", str->str); in dump_json_block_graph_info_list()
2863 printf("%s\n", str->str); in dump_json_block_graph_info()
2875 info->children == NULL); in dump_human_image_info()
2877 for (children_list = info->children; children_list; in dump_human_image_info()
2878 children_list = children_list->next) in dump_human_image_info()
2880 BlockChildInfo *child = children_list->value; in dump_human_image_info()
2884 indentation * 4, "", path, child->name); in dump_human_image_info()
2885 child_path = g_strdup_printf("%s%s/", path, child->name); in dump_human_image_info()
2886 dump_human_image_info(child->info, indentation + 1, child_path); in dump_human_image_info()
2895 for (elem = list; elem; elem = elem->next) { in dump_human_image_info_list()
2901 dump_human_image_info(elem->value, 0, "/"); in dump_human_image_info_list()
2915 * @chain: true - enumerate entire backing file chain
2916 * false - only topmost image file
2980 if (info->full_backing_filename) { in collect_image_info_list()
2981 filename = info->full_backing_filename; in collect_image_info_list()
2982 } else if (info->backing_filename) { in collect_image_info_list()
2985 info->backing_filename); in collect_image_info_list()
2988 if (info->backing_filename_format) { in collect_image_info_list()
2989 fmt = info->backing_filename_format; in collect_image_info_list()
3020 {"backing-chain", no_argument, 0, OPTION_BACKING_CHAIN}, in img_info()
3022 {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, in img_info()
3023 {"force-share", no_argument, 0, 'U'}, in img_info()
3028 if (c == -1) { in img_info()
3033 missing_argument(argv[optind - 1]); in img_info()
3036 unrecognized_option(argv[optind - 1]); in img_info()
3061 if (optind != argc - 1) { in img_info()
3071 error_report("--output must be used with human or json as argument."); in img_info()
3089 dump_json_block_graph_info(list->value); in img_info()
3099 MapEntry *next) in dump_map_entry() argument
3103 if (e->data && !e->has_offset) { in dump_map_entry()
3105 return -1; in dump_map_entry()
3107 if (e->data && !e->zero) { in dump_map_entry()
3108 printf("%#-16"PRIx64"%#-16"PRIx64"%#-16"PRIx64"%s\n", in dump_map_entry()
3109 e->start, e->length, in dump_map_entry()
3110 e->has_offset ? e->offset : 0, in dump_map_entry()
3111 e->filename ?: ""); in dump_map_entry()
3116 if (next && (!next->data || next->zero)) { in dump_map_entry()
3117 next->data = false; in dump_map_entry()
3118 next->zero = true; in dump_map_entry()
3125 e->start, e->length, e->depth, in dump_map_entry()
3126 e->present ? "true" : "false", in dump_map_entry()
3127 e->zero ? "true" : "false", in dump_map_entry()
3128 e->data ? "true" : "false", in dump_map_entry()
3129 e->compressed ? "true" : "false"); in dump_map_entry()
3130 if (e->has_offset) { in dump_map_entry()
3131 printf(", \"offset\": %"PRId64"", e->offset); in dump_map_entry()
3135 if (next) { in dump_map_entry()
3156 /* As an optimization, we could cache the current range of unallocated in get_block_status()
3185 filename = file->filename; in get_block_status()
3204 static inline bool entry_mergeable(const MapEntry *curr, const MapEntry *next) in entry_mergeable() argument
3206 if (curr->length == 0) { in entry_mergeable()
3209 if (curr->zero != next->zero || in entry_mergeable()
3210 curr->data != next->data || in entry_mergeable()
3211 curr->compressed != next->compressed || in entry_mergeable()
3212 curr->depth != next->depth || in entry_mergeable()
3213 curr->present != next->present || in entry_mergeable()
3214 !curr->filename != !next->filename || in entry_mergeable()
3215 curr->has_offset != next->has_offset) { in entry_mergeable()
3218 if (curr->filename && strcmp(curr->filename, next->filename)) { in entry_mergeable()
3221 if (curr->has_offset && curr->offset + curr->length != next->offset) { in entry_mergeable()
3235 MapEntry curr = { .length = 0 }, next; in img_map() local
3240 int64_t max_length = -1; in img_map()
3251 {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, in img_map()
3252 {"force-share", no_argument, 0, 'U'}, in img_map()
3253 {"start-offset", required_argument, 0, 's'}, in img_map()
3254 {"max-length", required_argument, 0, 'l'}, in img_map()
3259 if (c == -1) { in img_map()
3264 missing_argument(argv[optind - 1]); in img_map()
3267 unrecognized_option(argv[optind - 1]); in img_map()
3301 if (optind != argc - 1) { in img_map()
3311 error_report("--output must be used with human or json as argument."); in img_map()
3322 printf("%-16s%-16s%-16s%s\n", "Offset", "Length", "Mapped to", "File"); in img_map()
3332 if (max_length != -1) { in img_map()
3339 int64_t n = length - offset; in img_map()
3341 ret = get_block_status(bs, offset, n, &next); in img_map()
3343 error_report("Could not read file metadata: %s", strerror(-ret)); in img_map()
3347 if (entry_mergeable(&curr, &next)) { in img_map()
3348 curr.length += next.length; in img_map()
3353 ret = dump_map_entry(output_format, &curr, &next); in img_map()
3358 curr = next; in img_map()
3396 {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, in img_snapshot()
3397 {"force-share", no_argument, 0, 'U'}, in img_snapshot()
3402 if (c == -1) { in img_snapshot()
3407 missing_argument(argv[optind - 1]); in img_snapshot()
3410 unrecognized_option(argv[optind - 1]); in img_snapshot()
3417 error_exit("Cannot mix '-l', '-a', '-c', '-d'"); in img_snapshot()
3425 error_exit("Cannot mix '-l', '-a', '-c', '-d'"); in img_snapshot()
3433 error_exit("Cannot mix '-l', '-a', '-c', '-d'"); in img_snapshot()
3441 error_exit("Cannot mix '-l', '-a', '-c', '-d'"); in img_snapshot()
3462 if (optind != argc - 1) { in img_snapshot()
3495 snapshot_name, strerror(-ret)); in img_snapshot()
3545 const char *fmt, *cache, *src_cache, *out_basefmt, *out_baseimg; in img_rebase() local
3560 cache = BDRV_DEFAULT_CACHE; in img_rebase()
3568 {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, in img_rebase()
3569 {"force-share", no_argument, 0, 'U'}, in img_rebase()
3575 if (c == -1) { in img_rebase()
3580 missing_argument(argv[optind - 1]); in img_rebase()
3583 unrecognized_option(argv[optind - 1]); in img_rebase()
3604 cache = optarg; in img_rebase()
3631 if (optind != argc - 1) { in img_rebase()
3635 error_exit("Must specify backing file (-b) or use unsafe mode (-u)"); in img_rebase()
3643 ret = bdrv_parse_cache_mode(cache, &flags, &writethrough); in img_rebase()
3645 error_report("Invalid cache option: %s", cache); in img_rebase()
3652 error_report("Invalid source cache option: %s", src_cache); in img_rebase()
3656 /* The source files are opened read-only, don't care about WCE */ in img_rebase()
3669 ret = -1; in img_rebase()
3679 if (compress && !block_driver_can_compress(unfiltered_bs->drv)) { in img_rebase()
3681 ret = -1; in img_rebase()
3690 ret = -1; in img_rebase()
3727 base_bs->filename); in img_rebase()
3749 overlay_filename = bs->exact_filename[0] ? bs->exact_filename in img_rebase()
3750 : bs->filename; in img_rebase()
3759 ret = -1; in img_rebase()
3791 ret = -1; in img_rebase()
3804 * If qemu-img crashes during this step, no harm is done. The content of in img_rebase()
3826 filename, strerror(-size)); in img_rebase()
3827 ret = -1; in img_rebase()
3838 backing_name, strerror(-old_backing_size)); in img_rebase()
3839 ret = -1; in img_rebase()
3847 out_baseimg, strerror(-new_backing_size)); in img_rebase()
3848 ret = -1; in img_rebase()
3861 /* How many bytes can we handle with the next read? */ in img_rebase()
3862 n = MIN(IO_BUF_SIZE, size - offset); in img_rebase()
3868 strerror(-ret)); in img_rebase()
3887 strerror(-ret)); in img_rebase()
3912 n += offset - QEMU_ALIGN_DOWN(offset, write_align); in img_rebase()
3914 n += QEMU_ALIGN_UP(offset + n, write_align) - (offset + n); in img_rebase()
3915 n = MIN(n, size - offset); in img_rebase()
3923 n_old = MIN(n, MAX(0, old_backing_size - (int64_t) offset)); in img_rebase()
3924 n_new = MIN(n, MAX(0, new_backing_size - (int64_t) offset)); in img_rebase()
3930 memset(buf_old + n_old, 0, n - n_old); in img_rebase()
3941 memset(buf_new + n_new, 0, n - n_new); in img_rebase()
3957 n - written, write_align, &pnum)) in img_rebase()
3968 strerror(-ret)); in img_rebase()
3994 if (ret == -ENOSPC) { in img_rebase()
3997 } else if (ret == -EINVAL && out_baseimg && !out_basefmt) { in img_rebase()
4002 out_baseimg, strerror(-ret)); in img_rebase()
4063 size = argv[--argc]; in img_resize()
4071 {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, in img_resize()
4078 if (c == -1) { in img_resize()
4083 missing_argument(argv[optind - 1]); in img_resize()
4086 unrecognized_option(argv[optind - 1]); in img_resize()
4116 if (optind != argc - 1) { in img_resize()
4127 case '-': in img_resize()
4128 relative = -1; in img_resize()
4140 ret = -1; in img_resize()
4151 ret = -1; in img_resize()
4158 strerror(-current_size)); in img_resize()
4159 ret = -1; in img_resize()
4170 ret = -1; in img_resize()
4176 ret = -1; in img_resize()
4181 error_report("Use the --shrink option to perform a shrink operation."); in img_resize()
4185 ret = -1; in img_resize()
4228 if (!drv->bdrv_amend_options) { in print_amend_option_help()
4235 assert(drv->amend_opts); in print_amend_option_help()
4238 qemu_opts_print_help(drv->amend_opts, false); in print_amend_option_help()
4249 const char *fmt = NULL, *filename, *cache; in img_amend() local
4258 cache = BDRV_DEFAULT_CACHE; in img_amend()
4263 {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, in img_amend()
4269 if (c == -1) { in img_amend()
4275 missing_argument(argv[optind - 1]); in img_amend()
4278 unrecognized_option(argv[optind - 1]); in img_amend()
4285 ret = -1; in img_amend()
4293 cache = optarg; in img_amend()
4314 error_exit("Must specify options (-o)"); in img_amend()
4322 filename = (optind == argc - 1) ? argv[argc - 1] : NULL; in img_amend()
4330 if (optind != argc - 1) { in img_amend()
4332 ret = -1; in img_amend()
4337 ret = bdrv_parse_cache_mode(cache, &flags, &writethrough); in img_amend()
4339 error_report("Invalid cache option: %s", cache); in img_amend()
4346 ret = -1; in img_amend()
4351 fmt = bs->drv->format_name; in img_amend()
4354 /* If the format was auto-detected, print option help here */ in img_amend()
4360 if (!bs->drv->bdrv_amend_options) { in img_amend()
4364 ret = -1; in img_amend()
4369 assert(bs->drv->amend_opts); in img_amend()
4371 amend_opts = qemu_opts_append(amend_opts, bs->drv->amend_opts); in img_amend()
4375 amend_opts = qemu_opts_append(amend_opts, bs->drv->create_opts); in img_amend()
4385 ret = -1; in img_amend()
4436 error_report("Failed flush request: %s", strerror(-ret)); in bench_undrained_flush_cb()
4447 error_report("Failed request: %s", strerror(-ret)); in bench_cb()
4451 if (b->in_flush) { in bench_cb()
4452 /* Just finished a flush with drained queue: Start next requests */ in bench_cb()
4453 assert(b->in_flight == 0); in bench_cb()
4454 b->in_flush = false; in bench_cb()
4455 } else if (b->in_flight > 0) { in bench_cb()
4456 int remaining = b->n - b->in_flight; in bench_cb()
4458 b->n--; in bench_cb()
4459 b->in_flight--; in bench_cb()
4462 if (b->flush_interval && remaining % b->flush_interval == 0) { in bench_cb()
4463 if (!b->in_flight || !b->drain_on_flush) { in bench_cb()
4466 if (b->drain_on_flush) { in bench_cb()
4467 b->in_flush = true; in bench_cb()
4473 acb = blk_aio_flush(b->blk, cb, b); in bench_cb()
4479 if (b->drain_on_flush) { in bench_cb()
4485 while (b->n > b->in_flight && b->in_flight < b->nrreq) { in bench_cb()
4486 int64_t offset = b->offset; in bench_cb()
4489 * and b->offset is ready for the next submission. in bench_cb()
4491 b->in_flight++; in bench_cb()
4492 b->offset += b->step; in bench_cb()
4493 if (b->image_size <= b->bufsize) { in bench_cb()
4494 b->offset = 0; in bench_cb()
4496 b->offset %= b->image_size - b->bufsize; in bench_cb()
4498 if (b->write) { in bench_cb()
4499 acb = blk_aio_pwritev(b->blk, offset, b->qiov, 0, bench_cb, b); in bench_cb()
4501 acb = blk_aio_preadv(b->blk, offset, b->qiov, 0, bench_cb, b); in bench_cb()
4538 {"flush-interval", required_argument, 0, OPTION_FLUSH_INTERVAL}, in img_bench()
4539 {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, in img_bench()
4541 {"no-drain", no_argument, 0, OPTION_NO_DRAIN}, in img_bench()
4542 {"force-share", no_argument, 0, 'U'}, in img_bench()
4547 if (c == -1) { in img_bench()
4553 missing_argument(argv[optind - 1]); in img_bench()
4556 unrecognized_option(argv[optind - 1]); in img_bench()
4593 ret = -1; in img_bench()
4636 error_report("Invalid cache mode"); in img_bench()
4637 ret = -1; in img_bench()
4679 if (optind != argc - 1) { in img_bench()
4682 filename = argv[argc - 1]; in img_bench()
4685 error_report("--flush-interval is only available in write tests"); in img_bench()
4686 ret = -1; in img_bench()
4691 ret = -1; in img_bench()
4698 ret = -1; in img_bench()
4750 (t2.tv_sec - t1.tv_sec) in img_bench()
4751 + ((double)(t2.tv_usec - t1.tv_usec) / 1000000)); in img_bench()
4777 QSIMPLEQ_ENTRY(ImgBitmapAction) next;
4803 {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, in img_bitmap()
4811 {"source-file", required_argument, 0, 'b'}, in img_bitmap()
4812 {"source-format", required_argument, 0, 'F'}, in img_bitmap()
4816 if (c == -1) { in img_bitmap()
4822 missing_argument(argv[optind - 1]); in img_bitmap()
4825 unrecognized_option(argv[optind - 1]); in img_bitmap()
4847 act->act = BITMAP_ADD; in img_bitmap()
4848 QSIMPLEQ_INSERT_TAIL(&actions, act, next); in img_bitmap()
4853 act->act = BITMAP_REMOVE; in img_bitmap()
4854 QSIMPLEQ_INSERT_TAIL(&actions, act, next); in img_bitmap()
4858 act->act = BITMAP_CLEAR; in img_bitmap()
4859 QSIMPLEQ_INSERT_TAIL(&actions, act, next); in img_bitmap()
4863 act->act = BITMAP_ENABLE; in img_bitmap()
4864 QSIMPLEQ_INSERT_TAIL(&actions, act, next); in img_bitmap()
4868 act->act = BITMAP_DISABLE; in img_bitmap()
4869 QSIMPLEQ_INSERT_TAIL(&actions, act, next); in img_bitmap()
4873 act->act = BITMAP_MERGE; in img_bitmap()
4874 act->src = optarg; in img_bitmap()
4875 QSIMPLEQ_INSERT_TAIL(&actions, act, next); in img_bitmap()
4888 error_report("Need at least one of --add, --remove, --clear, " in img_bitmap()
4889 "--enable, --disable, or --merge"); in img_bitmap()
4894 error_report("granularity only supported with --add"); in img_bitmap()
4898 error_report("-F only supported with -b"); in img_bitmap()
4903 "--merge"); in img_bitmap()
4907 if (optind != argc - 2) { in img_bitmap()
4936 QSIMPLEQ_FOREACH_SAFE(act, &actions, next, act_next) { in img_bitmap()
4937 switch (act->act) { in img_bitmap()
4939 qmp_block_dirty_bitmap_add(bs->node_name, bitmap, in img_bitmap()
4945 qmp_block_dirty_bitmap_remove(bs->node_name, bitmap, &err); in img_bitmap()
4949 qmp_block_dirty_bitmap_clear(bs->node_name, bitmap, &err); in img_bitmap()
4953 qmp_block_dirty_bitmap_enable(bs->node_name, bitmap, &err); in img_bitmap()
4957 qmp_block_dirty_bitmap_disable(bs->node_name, bitmap, &err); in img_bitmap()
4961 do_dirty_bitmap_merge(bs->node_name, bitmap, src_bs->node_name, in img_bitmap()
4962 act->src, &err); in img_bitmap()
4986 error_report("Error while closing the image: %s", strerror(-inactivate_ret)); in img_bitmap()
5031 in->bsz = out->bsz = res; in img_dd_bs()
5040 dd->count = cvtnum("count", arg); in img_dd_count()
5042 if (dd->count < 0) { in img_dd_count()
5053 in->filename = g_strdup(arg); in img_dd_if()
5062 out->filename = g_strdup(arg); in img_dd_of()
5071 in->offset = cvtnum("skip", arg); in img_dd_skip()
5073 if (in->offset < 0) { in img_dd_skip()
5125 { "image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, in img_dd()
5126 { "force-share", no_argument, 0, 'U'}, in img_dd()
5142 missing_argument(argv[optind - 1]); in img_dd()
5145 unrecognized_option(argv[optind - 1]); in img_dd()
5169 ret = -1; in img_dd()
5182 ret = -1; in img_dd()
5187 ret = -1; in img_dd()
5197 ret = -1; in img_dd()
5205 ret = -1; in img_dd()
5212 ret = -1; in img_dd()
5219 ret = -1; in img_dd()
5222 if (!drv->create_opts) { in img_dd()
5224 drv->format_name); in img_dd()
5225 ret = -1; in img_dd()
5228 if (!proto_drv->create_opts) { in img_dd()
5230 proto_drv->format_name); in img_dd()
5231 ret = -1; in img_dd()
5234 create_opts = qemu_opts_append(create_opts, drv->create_opts); in img_dd()
5235 create_opts = qemu_opts_append(create_opts, proto_drv->create_opts); in img_dd()
5242 ret = -1; in img_dd()
5257 size - in.bsz * in.offset, &error_abort); in img_dd()
5265 ret = -1; in img_dd()
5269 /* TODO, we can't honour --image-opts for the target, in img_dd()
5272 * support image-opts style. in img_dd()
5278 ret = -1; in img_dd()
5296 int bytes = (in_pos + in.bsz > size) ? size - in_pos : in.bsz; in img_dd()
5301 strerror(-ret)); in img_dd()
5309 strerror(-ret)); in img_dd()
5342 printf("%s\n", str->str); in dump_json_block_measure_info()
5352 {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, in img_measure()
5356 {"force-share", no_argument, 0, 'U'}, in img_measure()
5380 long_options, NULL)) != -1) { in img_measure()
5425 error_report("--output must be used with human or json " in img_measure()
5444 if (argc - optind > 1) { in img_measure()
5447 } else if (argc - optind == 1) { in img_measure()
5452 error_report("--image-opts, -f, and -l require a filename argument."); in img_measure()
5456 error_report("--size N cannot be used together with a filename."); in img_measure()
5460 error_report("Either --size N or one filename must be specified."); in img_measure()
5491 if (!drv->create_opts) { in img_measure()
5493 drv->format_name); in img_measure()
5497 create_opts = qemu_opts_append(create_opts, drv->create_opts); in img_measure()
5518 printf("required size: %" PRIu64 "\n", info->required); in img_measure()
5519 printf("fully allocated size: %" PRIu64 "\n", info->fully_allocated); in img_measure()
5520 if (info->has_bitmaps) { in img_measure()
5521 printf("bitmaps size: %" PRIu64 "\n", info->bitmaps); in img_measure()
5543 #include "qemu-img-cmds.h"
5582 while ((c = getopt_long(argc, argv, "+:hVT:", long_options, NULL)) != -1) { in main()
5585 missing_argument(argv[optind - 1]); in main()
5588 unrecognized_option(argv[optind - 1]); in main()
5605 argc -= optind; in main()
5619 for (cmd = img_cmds; cmd->name != NULL; cmd++) { in main()
5620 if (!strcmp(cmdname, cmd->name)) { in main()
5621 return cmd->handler(argc, argv); in main()