qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-2020-01-06' into staging

Block patches:
- Minor fixes and tests from the freeze period (too minor to be included
in 4.2)
- Allow many bash iotests to test qcow2's external data file feature
- Add compress filter driver
- Fix Python iotests after 6f6e1698a6
- Fix for the backup job

# gpg: Signature made Mon 06 Jan 2020 14:33:06 GMT
# gpg: using RSA key 91BEB60A30DB3E8857D11829F407DB0061D5CF40
# gpg: issuer "mreitz@redhat.com"
# gpg: Good signature from "Max Reitz <mreitz@redhat.com>" [full]
# Primary key fingerprint: 91BE B60A 30DB 3E88 57D1 1829 F407 DB00 61D5 CF40

* remotes/maxreitz/tags/pull-block-2020-01-06: (34 commits)
backup-top: Begin drain earlier
tests/qemu-iotests: Update tests to recent desugarized -accel option
tests/qemu-iotests: add case to write compressed data of multiple clusters
qcow2: Allow writing compressed data of multiple clusters
block: introduce compress filter driver
iotests: Allow check -o data_file
iotests: Disable data_file where it cannot be used
iotests: Make 198 work with data_file
iotests: Make 137 work with data_file
iotests: Make 110 work with data_file
iotests: Make 091 work with data_file
iotests: Avoid cp/mv of test images
iotests: Use _rm_test_img for deleting test images
iotests: Avoid qemu-img create
iotests: Drop IMGOPTS use in 267
iotests: Replace IMGOPTS='' by --no-opts
iotests: Replace IMGOPTS= by -o
iotests: Inject space into -ocompat=0.10 in 051
iotests: Add -o and --no-opts to _make_test_img
iotests: Let _make_test_img parse its parameters
...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

+1139 -552
+26 -21
block.c
··· 2227 2227 *nshared = shared; 2228 2228 } 2229 2229 2230 + uint64_t bdrv_qapi_perm_to_blk_perm(BlockPermission qapi_perm) 2231 + { 2232 + static const uint64_t permissions[] = { 2233 + [BLOCK_PERMISSION_CONSISTENT_READ] = BLK_PERM_CONSISTENT_READ, 2234 + [BLOCK_PERMISSION_WRITE] = BLK_PERM_WRITE, 2235 + [BLOCK_PERMISSION_WRITE_UNCHANGED] = BLK_PERM_WRITE_UNCHANGED, 2236 + [BLOCK_PERMISSION_RESIZE] = BLK_PERM_RESIZE, 2237 + [BLOCK_PERMISSION_GRAPH_MOD] = BLK_PERM_GRAPH_MOD, 2238 + }; 2239 + 2240 + QEMU_BUILD_BUG_ON(ARRAY_SIZE(permissions) != BLOCK_PERMISSION__MAX); 2241 + QEMU_BUILD_BUG_ON(1UL << ARRAY_SIZE(permissions) != BLK_PERM_ALL + 1); 2242 + 2243 + assert(qapi_perm < BLOCK_PERMISSION__MAX); 2244 + 2245 + return permissions[qapi_perm]; 2246 + } 2247 + 2230 2248 static void bdrv_replace_child_noperm(BdrvChild *child, 2231 2249 BlockDriverState *new_bs) 2232 2250 { ··· 4854 4872 static void xdbg_graph_add_edge(XDbgBlockGraphConstructor *gr, void *parent, 4855 4873 const BdrvChild *child) 4856 4874 { 4857 - typedef struct { 4858 - unsigned int flag; 4859 - BlockPermission num; 4860 - } PermissionMap; 4861 - 4862 - static const PermissionMap permissions[] = { 4863 - { BLK_PERM_CONSISTENT_READ, BLOCK_PERMISSION_CONSISTENT_READ }, 4864 - { BLK_PERM_WRITE, BLOCK_PERMISSION_WRITE }, 4865 - { BLK_PERM_WRITE_UNCHANGED, BLOCK_PERMISSION_WRITE_UNCHANGED }, 4866 - { BLK_PERM_RESIZE, BLOCK_PERMISSION_RESIZE }, 4867 - { BLK_PERM_GRAPH_MOD, BLOCK_PERMISSION_GRAPH_MOD }, 4868 - { 0, 0 } 4869 - }; 4870 - const PermissionMap *p; 4875 + BlockPermission qapi_perm; 4871 4876 XDbgBlockGraphEdge *edge; 4872 4877 4873 - QEMU_BUILD_BUG_ON(1UL << (ARRAY_SIZE(permissions) - 1) != BLK_PERM_ALL + 1); 4874 - 4875 4878 edge = g_new0(XDbgBlockGraphEdge, 1); 4876 4879 4877 4880 edge->parent = xdbg_graph_node_num(gr, parent); 4878 4881 edge->child = xdbg_graph_node_num(gr, child->bs); 4879 4882 edge->name = g_strdup(child->name); 4880 4883 4881 - for (p = permissions; p->flag; p++) { 4882 - if (p->flag & child->perm) { 4883 - QAPI_LIST_ADD(edge->perm, p->num); 4884 + for (qapi_perm = 0; qapi_perm < BLOCK_PERMISSION__MAX; qapi_perm++) { 4885 + uint64_t flag = bdrv_qapi_perm_to_blk_perm(qapi_perm); 4886 + 4887 + if (flag & child->perm) { 4888 + QAPI_LIST_ADD(edge->perm, qapi_perm); 4884 4889 } 4885 - if (p->flag & child->shared_perm) { 4886 - QAPI_LIST_ADD(edge->shared_perm, p->num); 4890 + if (flag & child->shared_perm) { 4891 + QAPI_LIST_ADD(edge->shared_perm, qapi_perm); 4887 4892 } 4888 4893 } 4889 4894
+1
block/Makefile.objs
··· 43 43 44 44 block-obj-y += aio_task.o 45 45 block-obj-y += backup-top.o 46 + block-obj-y += filter-compress.o 46 47 47 48 common-obj-y += stream.o 48 49
+2 -2
block/backup-top.c
··· 257 257 BDRVBackupTopState *s = bs->opaque; 258 258 AioContext *aio_context = bdrv_get_aio_context(bs); 259 259 260 - block_copy_state_free(s->bcs); 261 - 262 260 aio_context_acquire(aio_context); 263 261 264 262 bdrv_drained_begin(bs); 263 + 264 + block_copy_state_free(s->bcs); 265 265 266 266 s->active = false; 267 267 bdrv_child_refresh_perms(bs, bs->backing, &error_abort);
+92 -1
block/blkdebug.c
··· 28 28 #include "qemu/cutils.h" 29 29 #include "qemu/config-file.h" 30 30 #include "block/block_int.h" 31 + #include "block/qdict.h" 31 32 #include "qemu/module.h" 32 33 #include "qemu/option.h" 34 + #include "qapi/qapi-visit-block-core.h" 33 35 #include "qapi/qmp/qdict.h" 36 + #include "qapi/qmp/qlist.h" 34 37 #include "qapi/qmp/qstring.h" 38 + #include "qapi/qobject-input-visitor.h" 35 39 #include "sysemu/qtest.h" 36 40 37 41 typedef struct BDRVBlkdebugState { ··· 43 47 uint64_t max_write_zero; 44 48 uint64_t opt_discard; 45 49 uint64_t max_discard; 50 + 51 + uint64_t take_child_perms; 52 + uint64_t unshare_child_perms; 46 53 47 54 /* For blkdebug_refresh_filename() */ 48 55 char *config_file; ··· 344 351 qdict_put_str(options, "x-image", filename); 345 352 } 346 353 354 + static int blkdebug_parse_perm_list(uint64_t *dest, QDict *options, 355 + const char *prefix, Error **errp) 356 + { 357 + int ret = 0; 358 + QDict *subqdict = NULL; 359 + QObject *crumpled_subqdict = NULL; 360 + Visitor *v = NULL; 361 + BlockPermissionList *perm_list = NULL, *element; 362 + Error *local_err = NULL; 363 + 364 + *dest = 0; 365 + 366 + qdict_extract_subqdict(options, &subqdict, prefix); 367 + if (!qdict_size(subqdict)) { 368 + goto out; 369 + } 370 + 371 + crumpled_subqdict = qdict_crumple(subqdict, errp); 372 + if (!crumpled_subqdict) { 373 + ret = -EINVAL; 374 + goto out; 375 + } 376 + 377 + v = qobject_input_visitor_new(crumpled_subqdict); 378 + visit_type_BlockPermissionList(v, NULL, &perm_list, &local_err); 379 + if (local_err) { 380 + error_propagate(errp, local_err); 381 + ret = -EINVAL; 382 + goto out; 383 + } 384 + 385 + for (element = perm_list; element; element = element->next) { 386 + *dest |= bdrv_qapi_perm_to_blk_perm(element->value); 387 + } 388 + 389 + out: 390 + qapi_free_BlockPermissionList(perm_list); 391 + visit_free(v); 392 + qobject_unref(subqdict); 393 + qobject_unref(crumpled_subqdict); 394 + return ret; 395 + } 396 + 397 + static int blkdebug_parse_perms(BDRVBlkdebugState *s, QDict *options, 398 + Error **errp) 399 + { 400 + int ret; 401 + 402 + ret = blkdebug_parse_perm_list(&s->take_child_perms, options, 403 + "take-child-perms.", errp); 404 + if (ret < 0) { 405 + return ret; 406 + } 407 + 408 + ret = blkdebug_parse_perm_list(&s->unshare_child_perms, options, 409 + "unshare-child-perms.", errp); 410 + if (ret < 0) { 411 + return ret; 412 + } 413 + 414 + return 0; 415 + } 416 + 347 417 static QemuOptsList runtime_opts = { 348 418 .name = "blkdebug", 349 419 .head = QTAILQ_HEAD_INITIALIZER(runtime_opts.head), ··· 418 488 419 489 /* Set initial state */ 420 490 s->state = 1; 491 + 492 + /* Parse permissions modifiers before opening the image file */ 493 + ret = blkdebug_parse_perms(s, options, errp); 494 + if (ret < 0) { 495 + goto out; 496 + } 421 497 422 498 /* Open the image file */ 423 499 bs->file = bdrv_open_child(qemu_opt_get(opts, "x-image"), options, "image", ··· 916 992 return 0; 917 993 } 918 994 995 + static void blkdebug_child_perm(BlockDriverState *bs, BdrvChild *c, 996 + const BdrvChildRole *role, 997 + BlockReopenQueue *reopen_queue, 998 + uint64_t perm, uint64_t shared, 999 + uint64_t *nperm, uint64_t *nshared) 1000 + { 1001 + BDRVBlkdebugState *s = bs->opaque; 1002 + 1003 + bdrv_filter_default_perms(bs, c, role, reopen_queue, perm, shared, 1004 + nperm, nshared); 1005 + 1006 + *nperm |= s->take_child_perms; 1007 + *nshared &= ~s->unshare_child_perms; 1008 + } 1009 + 919 1010 static const char *const blkdebug_strong_runtime_opts[] = { 920 1011 "config", 921 1012 "inject-error.", ··· 940 1031 .bdrv_file_open = blkdebug_open, 941 1032 .bdrv_close = blkdebug_close, 942 1033 .bdrv_reopen_prepare = blkdebug_reopen_prepare, 943 - .bdrv_child_perm = bdrv_filter_default_perms, 1034 + .bdrv_child_perm = blkdebug_child_perm, 944 1035 945 1036 .bdrv_getlength = blkdebug_getlength, 946 1037 .bdrv_refresh_filename = blkdebug_refresh_filename,
+168
block/filter-compress.c
··· 1 + /* 2 + * Compress filter block driver 3 + * 4 + * Copyright (c) 2019 Virtuozzo International GmbH 5 + * 6 + * Author: 7 + * Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> 8 + * (based on block/copy-on-read.c by Max Reitz) 9 + * 10 + * This program is free software; you can redistribute it and/or 11 + * modify it under the terms of the GNU General Public License as 12 + * published by the Free Software Foundation; either version 2 or 13 + * (at your option) any later version of the License. 14 + * 15 + * This program is distributed in the hope that it will be useful, 16 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 + * GNU General Public License for more details. 19 + * 20 + * You should have received a copy of the GNU General Public License 21 + * along with this program; if not, see <http://www.gnu.org/licenses/>. 22 + */ 23 + 24 + #include "qemu/osdep.h" 25 + #include "block/block_int.h" 26 + #include "qemu/module.h" 27 + #include "qapi/error.h" 28 + 29 + 30 + static int compress_open(BlockDriverState *bs, QDict *options, int flags, 31 + Error **errp) 32 + { 33 + bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, false, 34 + errp); 35 + if (!bs->file) { 36 + return -EINVAL; 37 + } 38 + 39 + if (!bs->file->bs->drv || !block_driver_can_compress(bs->file->bs->drv)) { 40 + error_setg(errp, 41 + "Compression is not supported for underlying format: %s", 42 + bdrv_get_format_name(bs->file->bs) ?: "(no format)"); 43 + 44 + return -ENOTSUP; 45 + } 46 + 47 + bs->supported_write_flags = BDRV_REQ_WRITE_UNCHANGED | 48 + (BDRV_REQ_FUA & bs->file->bs->supported_write_flags); 49 + 50 + bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED | 51 + ((BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP | BDRV_REQ_NO_FALLBACK) & 52 + bs->file->bs->supported_zero_flags); 53 + 54 + return 0; 55 + } 56 + 57 + 58 + static int64_t compress_getlength(BlockDriverState *bs) 59 + { 60 + return bdrv_getlength(bs->file->bs); 61 + } 62 + 63 + 64 + static int coroutine_fn compress_co_preadv_part(BlockDriverState *bs, 65 + uint64_t offset, uint64_t bytes, 66 + QEMUIOVector *qiov, 67 + size_t qiov_offset, 68 + int flags) 69 + { 70 + return bdrv_co_preadv_part(bs->file, offset, bytes, qiov, qiov_offset, 71 + flags); 72 + } 73 + 74 + 75 + static int coroutine_fn compress_co_pwritev_part(BlockDriverState *bs, 76 + uint64_t offset, 77 + uint64_t bytes, 78 + QEMUIOVector *qiov, 79 + size_t qiov_offset, int flags) 80 + { 81 + return bdrv_co_pwritev_part(bs->file, offset, bytes, qiov, qiov_offset, 82 + flags | BDRV_REQ_WRITE_COMPRESSED); 83 + } 84 + 85 + 86 + static int coroutine_fn compress_co_pwrite_zeroes(BlockDriverState *bs, 87 + int64_t offset, int bytes, 88 + BdrvRequestFlags flags) 89 + { 90 + return bdrv_co_pwrite_zeroes(bs->file, offset, bytes, flags); 91 + } 92 + 93 + 94 + static int coroutine_fn compress_co_pdiscard(BlockDriverState *bs, 95 + int64_t offset, int bytes) 96 + { 97 + return bdrv_co_pdiscard(bs->file, offset, bytes); 98 + } 99 + 100 + 101 + static void compress_refresh_limits(BlockDriverState *bs, Error **errp) 102 + { 103 + BlockDriverInfo bdi; 104 + int ret; 105 + 106 + if (!bs->file) { 107 + return; 108 + } 109 + 110 + ret = bdrv_get_info(bs->file->bs, &bdi); 111 + if (ret < 0 || bdi.cluster_size == 0) { 112 + return; 113 + } 114 + 115 + bs->bl.request_alignment = bdi.cluster_size; 116 + } 117 + 118 + 119 + static void compress_eject(BlockDriverState *bs, bool eject_flag) 120 + { 121 + bdrv_eject(bs->file->bs, eject_flag); 122 + } 123 + 124 + 125 + static void compress_lock_medium(BlockDriverState *bs, bool locked) 126 + { 127 + bdrv_lock_medium(bs->file->bs, locked); 128 + } 129 + 130 + 131 + static bool compress_recurse_is_first_non_filter(BlockDriverState *bs, 132 + BlockDriverState *candidate) 133 + { 134 + return bdrv_recurse_is_first_non_filter(bs->file->bs, candidate); 135 + } 136 + 137 + 138 + static BlockDriver bdrv_compress = { 139 + .format_name = "compress", 140 + 141 + .bdrv_open = compress_open, 142 + .bdrv_child_perm = bdrv_filter_default_perms, 143 + 144 + .bdrv_getlength = compress_getlength, 145 + 146 + .bdrv_co_preadv_part = compress_co_preadv_part, 147 + .bdrv_co_pwritev_part = compress_co_pwritev_part, 148 + .bdrv_co_pwrite_zeroes = compress_co_pwrite_zeroes, 149 + .bdrv_co_pdiscard = compress_co_pdiscard, 150 + .bdrv_refresh_limits = compress_refresh_limits, 151 + 152 + .bdrv_eject = compress_eject, 153 + .bdrv_lock_medium = compress_lock_medium, 154 + 155 + .bdrv_co_block_status = bdrv_co_block_status_from_file, 156 + 157 + .bdrv_recurse_is_first_non_filter = compress_recurse_is_first_non_filter, 158 + 159 + .has_variable_length = true, 160 + .is_filter = true, 161 + }; 162 + 163 + static void bdrv_compress_init(void) 164 + { 165 + bdrv_register(&bdrv_compress); 166 + } 167 + 168 + block_init(bdrv_compress_init);
+18 -23
block/qcow2-bitmap.c
··· 1703 1703 Error **errp) 1704 1704 { 1705 1705 BDRVQcow2State *s = bs->opaque; 1706 - bool found; 1707 - Qcow2BitmapList *bm_list; 1706 + BdrvDirtyBitmap *bitmap; 1707 + uint64_t bitmap_directory_size = 0; 1708 + uint32_t nb_bitmaps = 0; 1709 + 1710 + if (bdrv_find_dirty_bitmap(bs, name)) { 1711 + error_setg(errp, "Bitmap already exists: %s", name); 1712 + return false; 1713 + } 1708 1714 1709 1715 if (s->qcow_version < 3) { 1710 1716 /* Without autoclear_features, we would always have to assume ··· 1720 1726 goto fail; 1721 1727 } 1722 1728 1723 - if (s->nb_bitmaps == 0) { 1724 - return true; 1729 + FOR_EACH_DIRTY_BITMAP(bs, bitmap) { 1730 + if (bdrv_dirty_bitmap_get_persistence(bitmap)) { 1731 + nb_bitmaps++; 1732 + bitmap_directory_size += 1733 + calc_dir_entry_size(strlen(bdrv_dirty_bitmap_name(bitmap)), 0); 1734 + } 1725 1735 } 1736 + nb_bitmaps++; 1737 + bitmap_directory_size += calc_dir_entry_size(strlen(name), 0); 1726 1738 1727 - if (s->nb_bitmaps >= QCOW2_MAX_BITMAPS) { 1739 + if (nb_bitmaps > QCOW2_MAX_BITMAPS) { 1728 1740 error_setg(errp, 1729 1741 "Maximum number of persistent bitmaps is already reached"); 1730 1742 goto fail; 1731 1743 } 1732 1744 1733 - if (s->bitmap_directory_size + calc_dir_entry_size(strlen(name), 0) > 1734 - QCOW2_MAX_BITMAP_DIRECTORY_SIZE) 1735 - { 1745 + if (bitmap_directory_size > QCOW2_MAX_BITMAP_DIRECTORY_SIZE) { 1736 1746 error_setg(errp, "Not enough space in the bitmap directory"); 1737 - goto fail; 1738 - } 1739 - 1740 - qemu_co_mutex_lock(&s->lock); 1741 - bm_list = bitmap_list_load(bs, s->bitmap_directory_offset, 1742 - s->bitmap_directory_size, errp); 1743 - qemu_co_mutex_unlock(&s->lock); 1744 - if (bm_list == NULL) { 1745 - goto fail; 1746 - } 1747 - 1748 - found = find_bitmap_by_name(bm_list, name); 1749 - bitmap_list_free(bm_list); 1750 - if (found) { 1751 - error_setg(errp, "Bitmap with the same name is already stored"); 1752 1747 goto fail; 1753 1748 } 1754 1749
+75 -27
block/qcow2.c
··· 4221 4221 return ret; 4222 4222 } 4223 4223 4224 - /* XXX: put compressed sectors first, then all the cluster aligned 4225 - tables to avoid losing bytes in alignment */ 4226 4224 static coroutine_fn int 4227 - qcow2_co_pwritev_compressed_part(BlockDriverState *bs, 4225 + qcow2_co_pwritev_compressed_task(BlockDriverState *bs, 4228 4226 uint64_t offset, uint64_t bytes, 4229 4227 QEMUIOVector *qiov, size_t qiov_offset) 4230 4228 { ··· 4234 4232 uint8_t *buf, *out_buf; 4235 4233 uint64_t cluster_offset; 4236 4234 4237 - if (has_data_file(bs)) { 4238 - return -ENOTSUP; 4239 - } 4240 - 4241 - if (bytes == 0) { 4242 - /* align end of file to a sector boundary to ease reading with 4243 - sector based I/Os */ 4244 - int64_t len = bdrv_getlength(bs->file->bs); 4245 - if (len < 0) { 4246 - return len; 4247 - } 4248 - return bdrv_co_truncate(bs->file, len, false, PREALLOC_MODE_OFF, NULL); 4249 - } 4250 - 4251 - if (offset_into_cluster(s, offset)) { 4252 - return -EINVAL; 4253 - } 4235 + assert(bytes == s->cluster_size || (bytes < s->cluster_size && 4236 + (offset + bytes == bs->total_sectors << BDRV_SECTOR_BITS))); 4254 4237 4255 4238 buf = qemu_blockalign(bs, s->cluster_size); 4256 - if (bytes != s->cluster_size) { 4257 - if (bytes > s->cluster_size || 4258 - offset + bytes != bs->total_sectors << BDRV_SECTOR_BITS) 4259 - { 4260 - qemu_vfree(buf); 4261 - return -EINVAL; 4262 - } 4239 + if (bytes < s->cluster_size) { 4263 4240 /* Zero-pad last write if image size is not cluster aligned */ 4264 4241 memset(buf + bytes, 0, s->cluster_size - bytes); 4265 4242 } ··· 4305 4282 fail: 4306 4283 qemu_vfree(buf); 4307 4284 g_free(out_buf); 4285 + return ret; 4286 + } 4287 + 4288 + static coroutine_fn int qcow2_co_pwritev_compressed_task_entry(AioTask *task) 4289 + { 4290 + Qcow2AioTask *t = container_of(task, Qcow2AioTask, task); 4291 + 4292 + assert(!t->cluster_type && !t->l2meta); 4293 + 4294 + return qcow2_co_pwritev_compressed_task(t->bs, t->offset, t->bytes, t->qiov, 4295 + t->qiov_offset); 4296 + } 4297 + 4298 + /* 4299 + * XXX: put compressed sectors first, then all the cluster aligned 4300 + * tables to avoid losing bytes in alignment 4301 + */ 4302 + static coroutine_fn int 4303 + qcow2_co_pwritev_compressed_part(BlockDriverState *bs, 4304 + uint64_t offset, uint64_t bytes, 4305 + QEMUIOVector *qiov, size_t qiov_offset) 4306 + { 4307 + BDRVQcow2State *s = bs->opaque; 4308 + AioTaskPool *aio = NULL; 4309 + int ret = 0; 4310 + 4311 + if (has_data_file(bs)) { 4312 + return -ENOTSUP; 4313 + } 4314 + 4315 + if (bytes == 0) { 4316 + /* 4317 + * align end of file to a sector boundary to ease reading with 4318 + * sector based I/Os 4319 + */ 4320 + int64_t len = bdrv_getlength(bs->file->bs); 4321 + if (len < 0) { 4322 + return len; 4323 + } 4324 + return bdrv_co_truncate(bs->file, len, false, PREALLOC_MODE_OFF, NULL); 4325 + } 4326 + 4327 + if (offset_into_cluster(s, offset)) { 4328 + return -EINVAL; 4329 + } 4330 + 4331 + while (bytes && aio_task_pool_status(aio) == 0) { 4332 + uint64_t chunk_size = MIN(bytes, s->cluster_size); 4333 + 4334 + if (!aio && chunk_size != bytes) { 4335 + aio = aio_task_pool_new(QCOW2_MAX_WORKERS); 4336 + } 4337 + 4338 + ret = qcow2_add_task(bs, aio, qcow2_co_pwritev_compressed_task_entry, 4339 + 0, 0, offset, chunk_size, qiov, qiov_offset, NULL); 4340 + if (ret < 0) { 4341 + break; 4342 + } 4343 + qiov_offset += chunk_size; 4344 + offset += chunk_size; 4345 + bytes -= chunk_size; 4346 + } 4347 + 4348 + if (aio) { 4349 + aio_task_pool_wait_all(aio); 4350 + if (ret == 0) { 4351 + ret = aio_task_pool_status(aio); 4352 + } 4353 + g_free(aio); 4354 + } 4355 + 4308 4356 return ret; 4309 4357 } 4310 4358
+2 -2
block/throttle-groups.c
··· 893 893 { 894 894 ThrottleGroup *tg = THROTTLE_GROUP(obj); 895 895 ThrottleConfig cfg; 896 - ThrottleLimits arg = { 0 }; 897 - ThrottleLimits *argp = &arg; 896 + ThrottleLimits *argp; 898 897 Error *local_err = NULL; 899 898 900 899 visit_type_ThrottleLimits(v, name, &argp, &local_err); ··· 912 911 unlock: 913 912 qemu_mutex_unlock(&tg->lock); 914 913 ret: 914 + qapi_free_ThrottleLimits(argp); 915 915 error_propagate(errp, local_err); 916 916 return; 917 917 }
+1
include/block/block.h
··· 280 280 }; 281 281 282 282 char *bdrv_perm_names(uint64_t perm); 283 + uint64_t bdrv_qapi_perm_to_blk_perm(BlockPermission qapi_perm); 283 284 284 285 /* disk I/O throttling */ 285 286 void bdrv_init(void);
+19 -5
qapi/block-core.json
··· 2884 2884 # @copy-on-read: Since 3.0 2885 2885 # @blklogwrites: Since 3.0 2886 2886 # @blkreplay: Since 4.2 2887 + # @compress: Since 5.0 2887 2888 # 2888 2889 # Since: 2.9 2889 2890 ## 2890 2891 { 'enum': 'BlockdevDriver', 2891 2892 'data': [ 'blkdebug', 'blklogwrites', 'blkreplay', 'blkverify', 'bochs', 2892 - 'cloop', 'copy-on-read', 'dmg', 'file', 'ftp', 'ftps', 'gluster', 2893 - 'host_cdrom', 'host_device', 'http', 'https', 'iscsi', 'luks', 2894 - 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallels', 'qcow', 2895 - 'qcow2', 'qed', 'quorum', 'raw', 'rbd', 2893 + 'cloop', 'compress', 'copy-on-read', 'dmg', 'file', 'ftp', 'ftps', 2894 + 'gluster', 'host_cdrom', 'host_device', 'http', 'https', 'iscsi', 2895 + 'luks', 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallels', 2896 + 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'rbd', 2896 2897 { 'name': 'replication', 'if': 'defined(CONFIG_REPLICATION)' }, 2897 2898 'sheepdog', 2898 2899 'ssh', 'throttle', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat', 'vxhs' ] } ··· 3454 3455 # 3455 3456 # @set-state: array of state-change descriptions 3456 3457 # 3458 + # @take-child-perms: Permissions to take on @image in addition to what 3459 + # is necessary anyway (which depends on how the 3460 + # blkdebug node is used). Defaults to none. 3461 + # (since 5.0) 3462 + # 3463 + # @unshare-child-perms: Permissions not to share on @image in addition 3464 + # to what cannot be shared anyway (which depends 3465 + # on how the blkdebug node is used). Defaults 3466 + # to none. (since 5.0) 3467 + # 3457 3468 # Since: 2.9 3458 3469 ## 3459 3470 { 'struct': 'BlockdevOptionsBlkdebug', ··· 3463 3474 '*opt-write-zero': 'int32', '*max-write-zero': 'int32', 3464 3475 '*opt-discard': 'int32', '*max-discard': 'int32', 3465 3476 '*inject-error': ['BlkdebugInjectErrorOptions'], 3466 - '*set-state': ['BlkdebugSetStateOptions'] } } 3477 + '*set-state': ['BlkdebugSetStateOptions'], 3478 + '*take-child-perms': ['BlockPermission'], 3479 + '*unshare-child-perms': ['BlockPermission'] } } 3467 3480 3468 3481 ## 3469 3482 # @BlockdevOptionsBlklogwrites: ··· 4048 4061 'blkreplay': 'BlockdevOptionsBlkreplay', 4049 4062 'bochs': 'BlockdevOptionsGenericFormat', 4050 4063 'cloop': 'BlockdevOptionsGenericFormat', 4064 + 'compress': 'BlockdevOptionsGenericFormat', 4051 4065 'copy-on-read':'BlockdevOptionsGenericFormat', 4052 4066 'dmg': 'BlockdevOptionsGenericFormat', 4053 4067 'file': 'BlockdevOptionsFile',
+3 -2
tests/qemu-iotests/007
··· 41 41 _supported_fmt qcow2 42 42 _supported_proto generic 43 43 # refcount_bits must be at least 4 so we can create ten internal snapshots 44 - # (1 bit supports none, 2 bits support two, 4 bits support 14) 45 - _unsupported_imgopts 'refcount_bits=\(1\|2\)[^0-9]' 44 + # (1 bit supports none, 2 bits support two, 4 bits support 14); 45 + # snapshot are generally impossible with external data files 46 + _unsupported_imgopts 'refcount_bits=\(1\|2\)[^0-9]' data_file 46 47 47 48 echo 48 49 echo "creating image"
+2
tests/qemu-iotests/014
··· 43 43 _supported_fmt qcow2 44 44 _supported_proto file 45 45 _supported_os Linux 46 + # Compression and snapshots do not work with external data files 47 + _unsupported_imgopts data_file 46 48 47 49 TEST_OFFSETS="0 4294967296" 48 50 TEST_OPS="writev read write readv"
+3 -2
tests/qemu-iotests/015
··· 40 40 # actually any format that supports snapshots 41 41 _supported_fmt qcow2 42 42 _supported_proto generic 43 - # Internal snapshots are (currently) impossible with refcount_bits=1 44 - _unsupported_imgopts 'refcount_bits=1[^0-9]' 43 + # Internal snapshots are (currently) impossible with refcount_bits=1, 44 + # and generally impossible with external data files 45 + _unsupported_imgopts 'refcount_bits=1[^0-9]' data_file 45 46 46 47 echo 47 48 echo "creating image"
+3 -3
tests/qemu-iotests/019
··· 30 30 31 31 _cleanup() 32 32 { 33 - _cleanup_test_img 34 - rm -f "$TEST_IMG.base" 35 - rm -f "$TEST_IMG.orig" 33 + _cleanup_test_img 34 + _rm_test_img "$TEST_IMG.base" 35 + _rm_test_img "$TEST_IMG.orig" 36 36 } 37 37 trap "_cleanup; exit \$status" 0 1 2 3 15 38 38
+3 -3
tests/qemu-iotests/020
··· 28 28 29 29 _cleanup() 30 30 { 31 - _cleanup_test_img 32 - rm -f "$TEST_IMG.base" 33 - rm -f "$TEST_IMG.orig" 31 + _cleanup_test_img 32 + _rm_test_img "$TEST_IMG.base" 33 + _rm_test_img "$TEST_IMG.orig" 34 34 } 35 35 trap "_cleanup; exit \$status" 0 1 2 3 15 36 36
+5 -5
tests/qemu-iotests/024
··· 29 29 _cleanup() 30 30 { 31 31 _cleanup_test_img 32 - rm -f "$TEST_DIR/t.$IMGFMT.base_old" 33 - rm -f "$TEST_DIR/t.$IMGFMT.base_new" 32 + _rm_test_img "$TEST_DIR/t.$IMGFMT.base_old" 33 + _rm_test_img "$TEST_DIR/t.$IMGFMT.base_new" 34 34 35 - rm -f "$TEST_DIR/subdir/t.$IMGFMT" 36 - rm -f "$TEST_DIR/subdir/t.$IMGFMT.base_old" 37 - rm -f "$TEST_DIR/subdir/t.$IMGFMT.base_new" 35 + _rm_test_img "$TEST_DIR/subdir/t.$IMGFMT" 36 + _rm_test_img "$TEST_DIR/subdir/t.$IMGFMT.base_old" 37 + _rm_test_img "$TEST_DIR/subdir/t.$IMGFMT.base_new" 38 38 rmdir "$TEST_DIR/subdir" 2> /dev/null 39 39 } 40 40 trap "_cleanup; exit \$status" 0 1 2 3 15
+4 -1
tests/qemu-iotests/026
··· 49 49 # 32 and 64 bits do not work either, however, due to different leaked cluster 50 50 # count on error. 51 51 # Thus, the only remaining option is refcount_bits=16. 52 - _unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' 52 + # 53 + # As for data_file, none of the refcount tests can work for it. 54 + _unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' \ 55 + data_file 53 56 54 57 echo "Errors while writing 128 kB" 55 58 echo
+1 -1
tests/qemu-iotests/028
··· 32 32 _cleanup() 33 33 { 34 34 _cleanup_qemu 35 - rm -f "${TEST_IMG}.copy" 35 + _rm_test_img "${TEST_IMG}.copy" 36 36 _cleanup_test_img 37 37 } 38 38 trap "_cleanup; exit \$status" 0 1 2 3 15
+4 -3
tests/qemu-iotests/029
··· 28 28 29 29 _cleanup() 30 30 { 31 - rm -f $TEST_IMG.snap 31 + _rm_test_img "$TEST_IMG.snap" 32 32 _cleanup_test_img 33 33 } 34 34 trap "_cleanup; exit \$status" 0 1 2 3 15 ··· 42 42 _supported_fmt qcow2 43 43 _supported_proto generic 44 44 _unsupported_proto vxhs 45 - # Internal snapshots are (currently) impossible with refcount_bits=1 46 - _unsupported_imgopts 'refcount_bits=1[^0-9]' 45 + # Internal snapshots are (currently) impossible with refcount_bits=1, 46 + # and generally impossible with external data files 47 + _unsupported_imgopts 'refcount_bits=1[^0-9]' data_file 47 48 48 49 offset_size=24 49 50 offset_l1_size=36
+6 -3
tests/qemu-iotests/031
··· 40 40 # This tests qcow2-specific low-level functionality 41 41 _supported_fmt qcow2 42 42 _supported_proto file 43 + # We want to test compat=0.10, which does not support external data 44 + # files or refcount widths other than 16 45 + _unsupported_imgopts data_file 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' 43 46 44 47 CLUSTER_SIZE=65536 45 48 46 49 # qcow2.py output depends on the exact options used, so override the command 47 50 # line here as an exception 48 - for IMGOPTS in "compat=0.10" "compat=1.1"; do 51 + for compat in "compat=0.10" "compat=1.1"; do 49 52 50 53 echo 51 - echo ===== Testing with -o $IMGOPTS ===== 54 + echo ===== Testing with -o $compat ===== 52 55 echo 53 56 echo === Create image with unknown header extension === 54 57 echo 55 - _make_test_img 64M 58 + _make_test_img -o $compat 64M 56 59 $PYTHON qcow2.py "$TEST_IMG" add-header-ext 0x12345678 "This is a test header extension" 57 60 $PYTHON qcow2.py "$TEST_IMG" dump-header 58 61 _check_test_img
+18 -18
tests/qemu-iotests/031.out
··· 18 18 refcount_table_clusters 1 19 19 nb_snapshots 0 20 20 snapshot_offset 0x0 21 - incompatible_features 0x0 22 - compatible_features 0x0 23 - autoclear_features 0x0 21 + incompatible_features [] 22 + compatible_features [] 23 + autoclear_features [] 24 24 refcount_order 4 25 25 header_length 72 26 26 ··· 46 46 refcount_table_clusters 1 47 47 nb_snapshots 0 48 48 snapshot_offset 0x0 49 - incompatible_features 0x0 50 - compatible_features 0x0 51 - autoclear_features 0x0 49 + incompatible_features [] 50 + compatible_features [] 51 + autoclear_features [] 52 52 refcount_order 4 53 53 header_length 72 54 54 ··· 74 74 refcount_table_clusters 1 75 75 nb_snapshots 0 76 76 snapshot_offset 0x0 77 - incompatible_features 0x0 78 - compatible_features 0x0 79 - autoclear_features 0x0 77 + incompatible_features [] 78 + compatible_features [] 79 + autoclear_features [] 80 80 refcount_order 4 81 81 header_length 72 82 82 ··· 109 109 refcount_table_clusters 1 110 110 nb_snapshots 0 111 111 snapshot_offset 0x0 112 - incompatible_features 0x0 113 - compatible_features 0x0 114 - autoclear_features 0x0 112 + incompatible_features [] 113 + compatible_features [] 114 + autoclear_features [] 115 115 refcount_order 4 116 116 header_length 104 117 117 ··· 142 142 refcount_table_clusters 1 143 143 nb_snapshots 0 144 144 snapshot_offset 0x0 145 - incompatible_features 0x0 146 - compatible_features 0x0 147 - autoclear_features 0x0 145 + incompatible_features [] 146 + compatible_features [] 147 + autoclear_features [] 148 148 refcount_order 4 149 149 header_length 104 150 150 ··· 175 175 refcount_table_clusters 1 176 176 nb_snapshots 0 177 177 snapshot_offset 0x0 178 - incompatible_features 0x0 179 - compatible_features 0x0 180 - autoclear_features 0x0 178 + incompatible_features [] 179 + compatible_features [] 180 + autoclear_features [] 181 181 refcount_order 4 182 182 header_length 104 183 183
+9 -6
tests/qemu-iotests/036
··· 43 43 # This tests qcow2-specific low-level functionality 44 44 _supported_fmt qcow2 45 45 _supported_proto file 46 - 47 - # Only qcow2v3 and later supports feature bits 48 - IMGOPTS="compat=1.1" 46 + # Only qcow2v3 and later supports feature bits; 47 + # qcow2.py does not support external data files 48 + _unsupported_imgopts 'compat=0.10' data_file 49 49 50 50 echo 51 51 echo === Image with unknown incompatible feature bit === ··· 55 55 56 56 # Without feature table 57 57 $PYTHON qcow2.py "$TEST_IMG" del-header-ext 0x6803f857 58 - $PYTHON qcow2.py "$TEST_IMG" dump-header 58 + $PYTHON qcow2.py "$TEST_IMG" dump-header | grep features 59 + $PYTHON qcow2.py "$TEST_IMG" dump-header-exts 59 60 _img_info 60 61 61 62 # With feature table containing bit 63 ··· 103 104 echo 104 105 _make_test_img 64M 105 106 $PYTHON qcow2.py "$TEST_IMG" set-feature-bit autoclear 63 106 - $PYTHON qcow2.py "$TEST_IMG" dump-header 107 + $PYTHON qcow2.py "$TEST_IMG" dump-header | grep features 108 + $PYTHON qcow2.py "$TEST_IMG" dump-header-exts 107 109 108 110 echo 109 111 echo === Repair image === 110 112 echo 111 113 _check_test_img -r all 112 114 113 - $PYTHON qcow2.py "$TEST_IMG" dump-header 115 + $PYTHON qcow2.py "$TEST_IMG" dump-header | grep features 116 + $PYTHON qcow2.py "$TEST_IMG" dump-header-exts 114 117 115 118 # success, all done 116 119 echo "*** done"
+9 -57
tests/qemu-iotests/036.out
··· 3 3 === Image with unknown incompatible feature bit === 4 4 5 5 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 6 - magic 0x514649fb 7 - version 3 8 - backing_file_offset 0x0 9 - backing_file_size 0x0 10 - cluster_bits 16 11 - size 67108864 12 - crypt_method 0 13 - l1_size 1 14 - l1_table_offset 0x30000 15 - refcount_table_offset 0x10000 16 - refcount_table_clusters 1 17 - nb_snapshots 0 18 - snapshot_offset 0x0 19 - incompatible_features 0x8000000000000000 20 - compatible_features 0x0 21 - autoclear_features 0x0 22 - refcount_order 4 23 - header_length 104 24 - 6 + incompatible_features [63] 7 + compatible_features [] 8 + autoclear_features [] 25 9 qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Unknown incompatible feature: 8000000000000000 26 10 qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Unsupported IMGFMT feature(s): Test feature 27 11 ··· 37 21 === Create image with unknown autoclear feature bit === 38 22 39 23 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 40 - magic 0x514649fb 41 - version 3 42 - backing_file_offset 0x0 43 - backing_file_size 0x0 44 - cluster_bits 16 45 - size 67108864 46 - crypt_method 0 47 - l1_size 1 48 - l1_table_offset 0x30000 49 - refcount_table_offset 0x10000 50 - refcount_table_clusters 1 51 - nb_snapshots 0 52 - snapshot_offset 0x0 53 - incompatible_features 0x0 54 - compatible_features 0x0 55 - autoclear_features 0x8000000000000000 56 - refcount_order 4 57 - header_length 104 58 - 24 + incompatible_features [] 25 + compatible_features [] 26 + autoclear_features [63] 59 27 Header extension: 60 28 magic 0x6803f857 61 29 length 192 ··· 65 33 === Repair image === 66 34 67 35 No errors were found on the image. 68 - magic 0x514649fb 69 - version 3 70 - backing_file_offset 0x0 71 - backing_file_size 0x0 72 - cluster_bits 16 73 - size 67108864 74 - crypt_method 0 75 - l1_size 1 76 - l1_table_offset 0x30000 77 - refcount_table_offset 0x10000 78 - refcount_table_clusters 1 79 - nb_snapshots 0 80 - snapshot_offset 0x0 81 - incompatible_features 0x0 82 - compatible_features 0x0 83 - autoclear_features 0x0 84 - refcount_order 4 85 - header_length 104 86 - 36 + incompatible_features [] 37 + compatible_features [] 38 + autoclear_features [] 87 39 Header extension: 88 40 magic 0x6803f857 89 41 length 192
+11 -16
tests/qemu-iotests/039
··· 44 44 _supported_os Linux 45 45 _default_cache_mode writethrough 46 46 _supported_cache_modes writethrough 47 + # Some of these test cases expect no external data file so that all 48 + # clusters are part of the qcow2 image and refcounted 49 + _unsupported_imgopts data_file 47 50 48 51 size=128M 49 52 50 53 echo 51 54 echo "== Checking that image is clean on shutdown ==" 52 55 53 - IMGOPTS="compat=1.1,lazy_refcounts=on" 54 - _make_test_img $size 56 + _make_test_img -o "compat=1.1,lazy_refcounts=on" $size 55 57 56 58 $QEMU_IO -c "write -P 0x5a 0 512" "$TEST_IMG" | _filter_qemu_io 57 59 ··· 62 64 echo 63 65 echo "== Creating a dirty image file ==" 64 66 65 - IMGOPTS="compat=1.1,lazy_refcounts=on" 66 - _make_test_img $size 67 + _make_test_img -o "compat=1.1,lazy_refcounts=on" $size 67 68 68 69 _NO_VALGRIND \ 69 70 $QEMU_IO -c "write -P 0x5a 0 512" \ ··· 98 99 echo 99 100 echo "== Opening a dirty image read/write should repair it ==" 100 101 101 - IMGOPTS="compat=1.1,lazy_refcounts=on" 102 - _make_test_img $size 102 + _make_test_img -o "compat=1.1,lazy_refcounts=on" $size 103 103 104 104 _NO_VALGRIND \ 105 105 $QEMU_IO -c "write -P 0x5a 0 512" \ ··· 117 117 echo 118 118 echo "== Creating an image file with lazy_refcounts=off ==" 119 119 120 - IMGOPTS="compat=1.1,lazy_refcounts=off" 121 - _make_test_img $size 120 + _make_test_img -o "compat=1.1,lazy_refcounts=off" $size 122 121 123 122 _NO_VALGRIND \ 124 123 $QEMU_IO -c "write -P 0x5a 0 512" \ ··· 132 131 echo 133 132 echo "== Committing to a backing file with lazy_refcounts=on ==" 134 133 135 - IMGOPTS="compat=1.1,lazy_refcounts=on" 136 - TEST_IMG="$TEST_IMG".base _make_test_img $size 134 + TEST_IMG="$TEST_IMG".base _make_test_img -o "compat=1.1,lazy_refcounts=on" $size 137 135 138 - IMGOPTS="compat=1.1,lazy_refcounts=on,backing_file=$TEST_IMG.base" 139 - _make_test_img $size 136 + _make_test_img -o "compat=1.1,lazy_refcounts=on,backing_file=$TEST_IMG.base" $size 140 137 141 138 $QEMU_IO -c "write 0 512" "$TEST_IMG" | _filter_qemu_io 142 139 $QEMU_IMG commit "$TEST_IMG" ··· 151 148 echo 152 149 echo "== Changing lazy_refcounts setting at runtime ==" 153 150 154 - IMGOPTS="compat=1.1,lazy_refcounts=off" 155 - _make_test_img $size 151 + _make_test_img -o "compat=1.1,lazy_refcounts=off" $size 156 152 157 153 _NO_VALGRIND \ 158 154 $QEMU_IO -c "reopen -o lazy-refcounts=on" \ ··· 164 160 $PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features 165 161 _check_test_img 166 162 167 - IMGOPTS="compat=1.1,lazy_refcounts=on" 168 - _make_test_img $size 163 + _make_test_img -o "compat=1.1,lazy_refcounts=on" $size 169 164 170 165 _NO_VALGRIND \ 171 166 $QEMU_IO -c "reopen -o lazy-refcounts=off" \
+11 -11
tests/qemu-iotests/039.out
··· 4 4 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 5 5 wrote 512/512 bytes at offset 0 6 6 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 7 - incompatible_features 0x0 7 + incompatible_features [] 8 8 No errors were found on the image. 9 9 10 10 == Creating a dirty image file == ··· 12 12 wrote 512/512 bytes at offset 0 13 13 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 14 14 ./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) 15 - incompatible_features 0x1 15 + incompatible_features [0] 16 16 ERROR cluster 5 refcount=0 reference=1 17 17 ERROR OFLAG_COPIED data cluster: l2_entry=8000000000050000 refcount=0 18 18 ··· 22 22 == Read-only access must still work == 23 23 read 512/512 bytes at offset 0 24 24 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 25 - incompatible_features 0x1 25 + incompatible_features [0] 26 26 27 27 == Repairing the image file must succeed == 28 28 ERROR cluster 5 refcount=0 reference=1 ··· 36 36 37 37 Double checking the fixed image now... 38 38 No errors were found on the image. 39 - incompatible_features 0x0 39 + incompatible_features [] 40 40 41 41 == Data should still be accessible after repair == 42 42 read 512/512 bytes at offset 0 ··· 47 47 wrote 512/512 bytes at offset 0 48 48 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 49 49 ./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) 50 - incompatible_features 0x1 50 + incompatible_features [0] 51 51 ERROR cluster 5 refcount=0 reference=1 52 52 Rebuilding refcount structure 53 53 Repairing cluster 1 refcount=1 reference=0 54 54 Repairing cluster 2 refcount=1 reference=0 55 55 wrote 512/512 bytes at offset 0 56 56 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 57 - incompatible_features 0x0 57 + incompatible_features [] 58 58 59 59 == Creating an image file with lazy_refcounts=off == 60 60 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 61 61 wrote 512/512 bytes at offset 0 62 62 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 63 63 ./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) 64 - incompatible_features 0x0 64 + incompatible_features [] 65 65 No errors were found on the image. 66 66 67 67 == Committing to a backing file with lazy_refcounts=on == ··· 70 70 wrote 512/512 bytes at offset 0 71 71 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 72 72 Image committed. 73 - incompatible_features 0x0 74 - incompatible_features 0x0 73 + incompatible_features [] 74 + incompatible_features [] 75 75 No errors were found on the image. 76 76 No errors were found on the image. 77 77 ··· 80 80 wrote 512/512 bytes at offset 0 81 81 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 82 82 ./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) 83 - incompatible_features 0x1 83 + incompatible_features [0] 84 84 ERROR cluster 5 refcount=0 reference=1 85 85 ERROR OFLAG_COPIED data cluster: l2_entry=8000000000050000 refcount=0 86 86 ··· 90 90 wrote 512/512 bytes at offset 0 91 91 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 92 92 ./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) 93 - incompatible_features 0x0 93 + incompatible_features [] 94 94 No errors were found on the image. 95 95 *** done
+44
tests/qemu-iotests/041
··· 1121 1121 target='dest-ro') 1122 1122 self.assert_qmp(result, 'error/class', 'GenericError') 1123 1123 1124 + def test_failing_permission_in_complete(self): 1125 + self.assert_no_active_block_jobs() 1126 + 1127 + # Unshare consistent-read on the target 1128 + # (The mirror job does not care) 1129 + result = self.vm.qmp('blockdev-add', 1130 + driver='blkdebug', 1131 + node_name='dest-perm', 1132 + image='dest', 1133 + unshare_child_perms=['consistent-read']) 1134 + self.assert_qmp(result, 'return', {}) 1135 + 1136 + result = self.vm.qmp('blockdev-mirror', job_id='job', device='src', 1137 + sync='full', target='dest', 1138 + filter_node_name='mirror-filter') 1139 + self.assert_qmp(result, 'return', {}) 1140 + 1141 + # Require consistent-read on the source 1142 + # (We can only add this node once the job has started, or it 1143 + # will complain that it does not want to run on non-root nodes) 1144 + result = self.vm.qmp('blockdev-add', 1145 + driver='blkdebug', 1146 + node_name='src-perm', 1147 + image='src', 1148 + take_child_perms=['consistent-read']) 1149 + self.assert_qmp(result, 'return', {}) 1150 + 1151 + # While completing, mirror will attempt to replace src by 1152 + # dest, which must fail because src-perm requires 1153 + # consistent-read but dest-perm does not share it; thus 1154 + # aborting the job when it is supposed to complete 1155 + self.complete_and_wait('job', 1156 + completion_error='Operation not permitted') 1157 + 1158 + # Assert that all of our nodes are still there (except for the 1159 + # mirror filter, which should be gone despite the failure) 1160 + nodes = self.vm.qmp('query-named-block-nodes')['return'] 1161 + nodes = [node['node-name'] for node in nodes] 1162 + 1163 + for expect in ('src', 'src-perm', 'dest', 'dest-perm'): 1164 + self.assertTrue(expect in nodes, '%s disappeared' % expect) 1165 + self.assertFalse('mirror-filter' in nodes, 1166 + 'Mirror filter node did not disappear') 1167 + 1124 1168 if __name__ == '__main__': 1125 1169 iotests.main(supported_fmts=['qcow2', 'qed'], 1126 1170 supported_protocols=['file'])
+2 -2
tests/qemu-iotests/041.out
··· 1 - .......................................................................................... 1 + ........................................................................................... 2 2 ---------------------------------------------------------------------- 3 - Ran 90 tests 3 + Ran 91 tests 4 4 5 5 OK
+3 -1
tests/qemu-iotests/043
··· 29 29 _cleanup() 30 30 { 31 31 _cleanup_test_img 32 - rm -f "$TEST_IMG".[123].base 32 + for img in "$TEST_IMG".[123].base; do 33 + _rm_test_img "$img" 34 + done 33 35 } 34 36 trap "_cleanup; exit \$status" 0 1 2 3 15 35 37
+2
tests/qemu-iotests/046
··· 38 38 39 39 _supported_fmt qcow2 40 40 _supported_proto file 41 + # data_file does not support compressed clusters 42 + _unsupported_imgopts data_file 41 43 42 44 CLUSTER_SIZE=64k 43 45 size=128M
+3 -1
tests/qemu-iotests/048
··· 31 31 { 32 32 echo "Cleanup" 33 33 _cleanup_test_img 34 - rm "${TEST_IMG_FILE2}" 34 + _rm_test_img "${TEST_IMG_FILE2}" 35 35 } 36 36 trap "_cleanup; exit \$status" 0 1 2 3 15 37 37 ··· 49 49 _supported_fmt raw qcow2 qed luks 50 50 _supported_proto file 51 51 _supported_os Linux 52 + # Using 'cp' is incompatible with external data files 53 + _unsupported_imgopts data_file 52 54 53 55 # Remove once all tests are fixed to use TEST_IMG_FILE 54 56 # correctly and common.rc sets it unconditionally
+2 -6
tests/qemu-iotests/050
··· 29 29 _cleanup() 30 30 { 31 31 _cleanup_test_img 32 - rm -f "$TEST_IMG.old" 33 - rm -f "$TEST_IMG.new" 32 + _rm_test_img "$TEST_IMG.old" 33 + _rm_test_img "$TEST_IMG.new" 34 34 } 35 35 trap "_cleanup; exit \$status" 0 1 2 3 15 36 36 ··· 40 40 41 41 _supported_fmt qcow2 qed 42 42 _supported_proto file 43 - 44 - if test "$IMGFMT" = qcow2 && test $IMGOPTS = ""; then 45 - IMGOPTS=compat=1.1 46 - fi 47 43 48 44 echo 49 45 echo "== Creating images =="
+4 -3
tests/qemu-iotests/051
··· 39 39 _supported_fmt qcow2 40 40 _supported_proto file 41 41 # A compat=0.10 image is created in this test which does not support anything 42 - # other than refcount_bits=16 43 - _unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' 42 + # other than refcount_bits=16; 43 + # it also will not support an external data file 44 + _unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file 44 45 _require_drivers nbd 45 46 46 47 do_run_qemu() ··· 158 159 echo === With version 2 images enabling lazy refcounts must fail === 159 160 echo 160 161 161 - _make_test_img -ocompat=0.10 $size 162 + _make_test_img -o compat=0.10 $size 162 163 163 164 run_qemu -drive file="$TEST_IMG",format=qcow2,lazy-refcounts=on 164 165 run_qemu -drive file="$TEST_IMG",format=qcow2,lazy-refcounts=off
+2 -2
tests/qemu-iotests/053
··· 28 28 29 29 _cleanup() 30 30 { 31 - rm -f "$TEST_IMG.orig" 32 - _cleanup_test_img 31 + _rm_test_img "$TEST_IMG.orig" 32 + _cleanup_test_img 33 33 } 34 34 trap "_cleanup; exit \$status" 0 1 2 3 15 35 35
+4 -3
tests/qemu-iotests/058
··· 42 42 { 43 43 nbd_server_stop 44 44 _cleanup_test_img 45 - rm -f "$converted_image" 45 + _rm_test_img "$converted_image" 46 46 } 47 47 trap "_cleanup; exit \$status" 0 1 2 3 15 48 48 ··· 56 56 _supported_proto file 57 57 _supported_os Linux 58 58 _require_command QEMU_NBD 59 - # Internal snapshots are (currently) impossible with refcount_bits=1 60 - _unsupported_imgopts 'refcount_bits=1[^0-9]' 59 + # Internal snapshots are (currently) impossible with refcount_bits=1, 60 + # and generally impossible with external data files 61 + _unsupported_imgopts 'refcount_bits=1[^0-9]' data_file 61 62 62 63 nbd_snapshot_img="nbd:unix:$nbd_unix_socket" 63 64
+10 -10
tests/qemu-iotests/059
··· 29 29 _cleanup() 30 30 { 31 31 _cleanup_test_img 32 - rm -f "$TEST_IMG.qcow2" 32 + IMGFMT=qcow2 _rm_test_img "$TEST_IMG.qcow2" 33 33 } 34 34 trap "_cleanup; exit \$status" 0 1 2 3 15 35 35 ··· 70 70 71 71 echo 72 72 echo "=== Testing monolithicFlat creation and opening ===" 73 - IMGOPTS="subformat=monolithicFlat" _make_test_img 2G 73 + _make_test_img -o "subformat=monolithicFlat" 2G 74 74 _img_info 75 75 _cleanup_test_img 76 76 77 77 echo 78 78 echo "=== Testing monolithicFlat with zeroed_grain ===" 79 - IMGOPTS="subformat=monolithicFlat,zeroed_grain=on" _make_test_img 2G 79 + _make_test_img -o "subformat=monolithicFlat,zeroed_grain=on" 2G 80 80 _cleanup_test_img 81 81 82 82 echo 83 83 echo "=== Testing big twoGbMaxExtentFlat ===" 84 - IMGOPTS="subformat=twoGbMaxExtentFlat" _make_test_img 1000G 84 + _make_test_img -o "subformat=twoGbMaxExtentFlat" 1000G 85 85 $QEMU_IMG info $TEST_IMG | _filter_testdir | sed -e 's/cid: [0-9]*/cid: XXXXXXXX/' 86 86 _cleanup_test_img 87 87 ··· 101 101 102 102 echo 103 103 echo "=== Testing truncated sparse ===" 104 - IMGOPTS="subformat=monolithicSparse" _make_test_img 100G 104 + _make_test_img -o "subformat=monolithicSparse" 100G 105 105 truncate -s 10M $TEST_IMG 106 106 _img_info 107 107 108 108 echo 109 109 echo "=== Converting to streamOptimized from image with small cluster size===" 110 - TEST_IMG="$TEST_IMG.qcow2" IMGFMT=qcow2 IMGOPTS="cluster_size=4096" _make_test_img 1G 110 + TEST_IMG="$TEST_IMG.qcow2" IMGFMT=qcow2 _make_test_img -o "cluster_size=4096" 1G 111 111 $QEMU_IO -f qcow2 -c "write -P 0xa 0 512" "$TEST_IMG.qcow2" | _filter_qemu_io 112 112 $QEMU_IO -f qcow2 -c "write -P 0xb 10240 512" "$TEST_IMG.qcow2" | _filter_qemu_io 113 113 $QEMU_IMG convert -f qcow2 -O vmdk -o subformat=streamOptimized "$TEST_IMG.qcow2" "$TEST_IMG" 2>&1 ··· 117 117 118 118 echo '--- blkdebug ---' 119 119 # Should work, because bdrv_dirname() works fine with blkdebug 120 - IMGOPTS="subformat=monolithicFlat" _make_test_img 64M 120 + _make_test_img -o "subformat=monolithicFlat" 64M 121 121 $QEMU_IO -c "open -o driver=$IMGFMT,file.driver=blkdebug,file.image.filename=$TEST_IMG,file.inject-error.0.event=read_aio" \ 122 122 -c info \ 123 123 2>&1 \ ··· 126 126 127 127 echo '--- quorum ---' 128 128 # Should not work, because bdrv_dirname() does not work with quorum 129 - IMGOPTS="subformat=monolithicFlat" _make_test_img 64M 129 + _make_test_img -o "subformat=monolithicFlat" 64M 130 130 cp "$TEST_IMG" "$TEST_IMG.orig" 131 131 132 132 filename="json:{ ··· 161 161 162 162 echo 163 163 echo "=== Testing 4TB monolithicFlat creation and IO ===" 164 - IMGOPTS="subformat=monolithicFlat" _make_test_img 4T 164 + _make_test_img -o "subformat=monolithicFlat" 4T 165 165 _img_info 166 166 $QEMU_IO -c "write -P 0xa 900G 512" "$TEST_IMG" | _filter_qemu_io 167 167 $QEMU_IO -c "read -v 900G 1024" "$TEST_IMG" | _filter_qemu_io ··· 170 170 echo 171 171 echo "=== Testing qemu-img map on extents ===" 172 172 for fmt in monolithicSparse twoGbMaxExtentSparse; do 173 - IMGOPTS="subformat=$fmt" _make_test_img 31G 173 + _make_test_img -o "subformat=$fmt" 31G 174 174 $QEMU_IO -c "write 65024 1k" "$TEST_IMG" | _filter_qemu_io 175 175 $QEMU_IO -c "write 2147483136 1k" "$TEST_IMG" | _filter_qemu_io 176 176 $QEMU_IO -c "write 5G 1k" "$TEST_IMG" | _filter_qemu_io
+8 -6
tests/qemu-iotests/060
··· 44 44 . ./common.rc 45 45 . ./common.filter 46 46 47 - # This tests qocw2-specific low-level functionality 47 + # This tests qcow2-specific low-level functionality 48 48 _supported_fmt qcow2 49 49 _supported_proto file 50 50 _supported_os Linux 51 + # These tests only work for compat=1.1 images without an external 52 + # data file with refcount_bits=16 53 + _unsupported_imgopts 'compat=0.10' data_file \ 54 + 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' 51 55 52 56 # The repair process will create a large file - so check for availability first 53 57 _require_large_file 64G ··· 57 61 l1_offset=196608 # 0x30000 (XXX: just an assumption) 58 62 l2_offset=262144 # 0x40000 (XXX: just an assumption) 59 63 l2_offset_after_snapshot=524288 # 0x80000 (XXX: just an assumption) 60 - 61 - IMGOPTS="compat=1.1" 62 64 63 65 OPEN_RW="open -o overlap-check=all $TEST_IMG" 64 66 # Overlap checks are done before write operations only, therefore opening an ··· 161 163 # compat=0.10 is required in order to make the following discard actually 162 164 # unallocate the sector rather than make it a zero sector - we want COW, after 163 165 # all. 164 - IMGOPTS='compat=0.10' _make_test_img -b "$BACKING_IMG" 1G 166 + _make_test_img -o 'compat=0.10' -b "$BACKING_IMG" 1G 165 167 # Write two clusters, the second one enforces creation of an L2 table after 166 168 # the first data cluster. 167 169 $QEMU_IO -c 'write 0k 64k' -c 'write 512M 64k' "$TEST_IMG" | _filter_qemu_io ··· 401 403 echo "=== Discarding a non-covered in-bounds refblock ===" 402 404 echo 403 405 404 - IMGOPTS='refcount_bits=1' _make_test_img 64M 406 + _make_test_img -o 'refcount_bits=1' 64M 405 407 406 408 # Pretend there's a refblock somewhere where there is no refblock to 407 409 # cover it (but the covering refblock has a valid index in the ··· 425 427 echo "=== Discarding a refblock covered by an unaligned refblock ===" 426 428 echo 427 429 428 - IMGOPTS='refcount_bits=1' _make_test_img 64M 430 + _make_test_img -o 'refcount_bits=1' 64M 429 431 430 432 # Same as above 431 433 poke_file "$TEST_IMG" "$(($rt_offset+8))" "\x00\x00\x00\x10\x00\x00\x00\x00"
+10 -10
tests/qemu-iotests/060.out
··· 7 7 8 8 1 errors were found on the image. 9 9 Data may be corrupted, or further writes to the image may corrupt it. 10 - incompatible_features 0x0 10 + incompatible_features [] 11 11 qcow2: Marking image as corrupt: Preventing invalid write on metadata (overlaps with active L1 table); further corruption events will be suppressed 12 12 write failed: Input/output error 13 - incompatible_features 0x2 13 + incompatible_features [1] 14 14 image: TEST_DIR/t.IMGFMT 15 15 file format: IMGFMT 16 16 virtual size: 64 MiB (67108864 bytes) ··· 33 33 34 34 2 errors were found on the image. 35 35 Data may be corrupted, or further writes to the image may corrupt it. 36 - incompatible_features 0x0 36 + incompatible_features [] 37 37 qcow2: Marking image as corrupt: Preventing invalid write on metadata (overlaps with refcount block); further corruption events will be suppressed 38 38 write failed: Input/output error 39 - incompatible_features 0x2 39 + incompatible_features [1] 40 40 ERROR refcount block 0 refcount=2 41 41 ERROR cluster 2 refcount=1 reference=2 42 42 Rebuilding refcount structure ··· 49 49 50 50 Double checking the fixed image now... 51 51 No errors were found on the image. 52 - incompatible_features 0x0 52 + incompatible_features [] 53 53 wrote 512/512 bytes at offset 0 54 54 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 55 - incompatible_features 0x0 55 + incompatible_features [] 56 56 57 57 === Testing cluster data reference into inactive L2 table === 58 58 ··· 69 69 70 70 1 leaked clusters were found on the image. 71 71 This means waste of disk space, but no harm to data. 72 - incompatible_features 0x0 72 + incompatible_features [] 73 73 qcow2: Marking image as corrupt: Preventing invalid write on metadata (overlaps with inactive L2 table); further corruption events will be suppressed 74 74 write failed: Input/output error 75 - incompatible_features 0x2 75 + incompatible_features [1] 76 76 ERROR cluster 4 refcount=1 reference=2 77 77 Leaked cluster 9 refcount=1 reference=0 78 78 Repairing cluster 4 refcount=1 reference=2 ··· 85 85 86 86 Double checking the fixed image now... 87 87 No errors were found on the image. 88 - incompatible_features 0x0 88 + incompatible_features [] 89 89 wrote 512/512 bytes at offset 0 90 90 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 91 - incompatible_features 0x0 91 + incompatible_features [] 92 92 read 512/512 bytes at offset 0 93 93 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 94 94 No errors were found on the image.
+34 -29
tests/qemu-iotests/061
··· 29 29 _cleanup() 30 30 { 31 31 _cleanup_test_img 32 - rm -f $TEST_IMG.data 32 + _rm_test_img "$TEST_IMG.data" 33 33 } 34 34 trap "_cleanup; exit \$status" 0 1 2 3 15 35 35 ··· 37 37 . ./common.rc 38 38 . ./common.filter 39 39 40 - # This tests qocw2-specific low-level functionality 40 + # This tests qcow2-specific low-level functionality 41 41 _supported_fmt qcow2 42 42 _supported_proto file 43 43 _supported_os Linux 44 + # Conversion between different compat versions can only really work 45 + # with refcount_bits=16; 46 + # we have explicit tests for data_file here, but the whole test does 47 + # not work with it 48 + _unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file 44 49 45 50 echo 46 51 echo "=== Testing version downgrade with zero expansion ===" 47 52 echo 48 - IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img 64M 53 + _make_test_img -o "compat=1.1,lazy_refcounts=on" 64M 49 54 $QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io 50 55 $PYTHON qcow2.py "$TEST_IMG" dump-header 51 56 $QEMU_IMG amend -o "compat=0.10" "$TEST_IMG" ··· 56 61 echo 57 62 echo "=== Testing version downgrade with zero expansion and 4K cache entries ===" 58 63 echo 59 - IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img 64M 64 + _make_test_img -o "compat=1.1,lazy_refcounts=on" 64M 60 65 $QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io 61 66 $QEMU_IO -c "write -z 32M 128k" "$TEST_IMG" | _filter_qemu_io 62 67 $QEMU_IO -c map "$TEST_IMG" | _filter_qemu_io ··· 72 77 echo 73 78 echo "=== Testing dirty version downgrade ===" 74 79 echo 75 - IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img 64M 80 + _make_test_img -o "compat=1.1,lazy_refcounts=on" 64M 76 81 _NO_VALGRIND \ 77 82 $QEMU_IO -c "write -P 0x2a 0 128k" -c flush \ 78 83 -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 | _filter_qemu_io ··· 85 90 echo 86 91 echo "=== Testing version downgrade with unknown compat/autoclear flags ===" 87 92 echo 88 - IMGOPTS="compat=1.1" _make_test_img 64M 93 + _make_test_img -o "compat=1.1" 64M 89 94 $PYTHON qcow2.py "$TEST_IMG" set-feature-bit compatible 42 90 95 $PYTHON qcow2.py "$TEST_IMG" set-feature-bit autoclear 42 91 96 $PYTHON qcow2.py "$TEST_IMG" dump-header ··· 96 101 echo 97 102 echo "=== Testing version upgrade and resize ===" 98 103 echo 99 - IMGOPTS="compat=0.10" _make_test_img 64M 104 + _make_test_img -o "compat=0.10" 64M 100 105 $QEMU_IO -c "write -P 0x2a 42M 64k" "$TEST_IMG" | _filter_qemu_io 101 106 $PYTHON qcow2.py "$TEST_IMG" dump-header 102 107 $QEMU_IMG amend -o "compat=1.1,lazy_refcounts=on,size=128M" "$TEST_IMG" ··· 107 112 echo 108 113 echo "=== Testing dirty lazy_refcounts=off ===" 109 114 echo 110 - IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img 64M 115 + _make_test_img -o "compat=1.1,lazy_refcounts=on" 64M 111 116 _NO_VALGRIND \ 112 117 $QEMU_IO -c "write -P 0x2a 0 128k" -c flush \ 113 118 -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 | _filter_qemu_io ··· 120 125 echo 121 126 echo "=== Testing backing file ===" 122 127 echo 123 - IMGOPTS="compat=1.1" _make_test_img 64M 124 - IMGOPTS="compat=1.1" TEST_IMG="$TEST_IMG.base" _make_test_img 64M 128 + _make_test_img -o "compat=1.1" 64M 129 + TEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 64M 125 130 $QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG.base" | _filter_qemu_io 126 131 $QEMU_IO -c "read -P 0 0 128k" "$TEST_IMG" | _filter_qemu_io 127 132 $QEMU_IMG amend -o "backing_file=$TEST_IMG.base,backing_fmt=qcow2" "$TEST_IMG" ··· 131 136 echo 132 137 echo "=== Testing invalid configurations ===" 133 138 echo 134 - IMGOPTS="compat=0.10" _make_test_img 64M 139 + _make_test_img -o "compat=0.10" 64M 135 140 $QEMU_IMG amend -o "lazy_refcounts=on" "$TEST_IMG" 136 141 $QEMU_IMG amend -o "compat=1.1" "$TEST_IMG" # actually valid 137 142 $QEMU_IMG amend -o "compat=0.10,lazy_refcounts=on" "$TEST_IMG" ··· 144 149 echo 145 150 echo "=== Testing correct handling of unset value ===" 146 151 echo 147 - IMGOPTS="compat=1.1,cluster_size=1k" _make_test_img 64M 152 + _make_test_img -o "compat=1.1,cluster_size=1k" 64M 148 153 echo "Should work:" 149 154 $QEMU_IMG amend -o "lazy_refcounts=on" "$TEST_IMG" 150 155 echo "Should not work:" # Just to know which of these tests actually fails ··· 153 158 echo 154 159 echo "=== Testing zero expansion on inactive clusters ===" 155 160 echo 156 - IMGOPTS="compat=1.1" _make_test_img 64M 161 + _make_test_img -o "compat=1.1" 64M 157 162 $QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io 158 163 $QEMU_IMG snapshot -c foo "$TEST_IMG" 159 164 $QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG" | _filter_qemu_io ··· 167 172 echo 168 173 echo "=== Testing zero expansion on shared L2 table ===" 169 174 echo 170 - IMGOPTS="compat=1.1" _make_test_img 64M 175 + _make_test_img -o "compat=1.1" 64M 171 176 $QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io 172 177 $QEMU_IMG snapshot -c foo "$TEST_IMG" 173 178 $QEMU_IMG amend -o "compat=0.10" "$TEST_IMG" ··· 180 185 echo 181 186 echo "=== Testing zero expansion on backed image ===" 182 187 echo 183 - IMGOPTS="compat=1.1" TEST_IMG="$TEST_IMG.base" _make_test_img 64M 188 + TEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 64M 184 189 $QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG.base" | _filter_qemu_io 185 - IMGOPTS="compat=1.1" _make_test_img -b "$TEST_IMG.base" 64M 190 + _make_test_img -o "compat=1.1" -b "$TEST_IMG.base" 64M 186 191 $QEMU_IO -c "read -P 0x2a 0 128k" -c "write -z 0 64k" "$TEST_IMG" | _filter_qemu_io 187 192 $QEMU_IMG amend -o "compat=0.10" "$TEST_IMG" 188 193 _check_test_img ··· 191 196 echo 192 197 echo "=== Testing zero expansion on backed inactive clusters ===" 193 198 echo 194 - IMGOPTS="compat=1.1" TEST_IMG="$TEST_IMG.base" _make_test_img 64M 199 + TEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 64M 195 200 $QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG.base" | _filter_qemu_io 196 - IMGOPTS="compat=1.1" _make_test_img -b "$TEST_IMG.base" 64M 201 + _make_test_img -o "compat=1.1" -b "$TEST_IMG.base" 64M 197 202 $QEMU_IO -c "write -z 0 64k" "$TEST_IMG" | _filter_qemu_io 198 203 $QEMU_IMG snapshot -c foo "$TEST_IMG" 199 204 $QEMU_IO -c "write -P 0x42 0 128k" "$TEST_IMG" | _filter_qemu_io ··· 207 212 echo 208 213 echo "=== Testing zero expansion on backed image with shared L2 table ===" 209 214 echo 210 - IMGOPTS="compat=1.1" TEST_IMG="$TEST_IMG.base" _make_test_img 64M 215 + TEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 64M 211 216 $QEMU_IO -c "write -P 0x2a 0 128k" "$TEST_IMG.base" | _filter_qemu_io 212 - IMGOPTS="compat=1.1" _make_test_img -b "$TEST_IMG.base" 64M 217 + _make_test_img -o "compat=1.1" -b "$TEST_IMG.base" 64M 213 218 $QEMU_IO -c "write -z 0 128k" "$TEST_IMG" | _filter_qemu_io 214 219 $QEMU_IMG snapshot -c foo "$TEST_IMG" 215 220 $QEMU_IMG amend -o "compat=0.10" "$TEST_IMG" ··· 222 227 echo 223 228 echo "=== Testing preallocated zero expansion on full image ===" 224 229 echo 225 - IMGOPTS="compat=1.1" TEST_IMG="$TEST_IMG" _make_test_img 64M 230 + TEST_IMG="$TEST_IMG" _make_test_img -o "compat=1.1" 64M 226 231 $QEMU_IO -c "write -P 0x2a 0 64M" "$TEST_IMG" -c "write -z 0 64M" | _filter_qemu_io 227 232 $QEMU_IMG amend -o "compat=0.10" "$TEST_IMG" 228 233 _check_test_img ··· 231 236 echo 232 237 echo "=== Testing progress report without snapshot ===" 233 238 echo 234 - IMGOPTS="compat=1.1" TEST_IMG="$TEST_IMG.base" _make_test_img 4G 235 - IMGOPTS="compat=1.1" _make_test_img -b "$TEST_IMG.base" 4G 239 + TEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 4G 240 + _make_test_img -o "compat=1.1" -b "$TEST_IMG.base" 4G 236 241 $QEMU_IO -c "write -z 0 64k" \ 237 242 -c "write -z 1G 64k" \ 238 243 -c "write -z 2G 64k" \ ··· 243 248 echo 244 249 echo "=== Testing progress report with snapshot ===" 245 250 echo 246 - IMGOPTS="compat=1.1" TEST_IMG="$TEST_IMG.base" _make_test_img 4G 247 - IMGOPTS="compat=1.1" _make_test_img -b "$TEST_IMG.base" 4G 251 + TEST_IMG="$TEST_IMG.base" _make_test_img -o "compat=1.1" 4G 252 + _make_test_img -o "compat=1.1" -b "$TEST_IMG.base" 4G 248 253 $QEMU_IO -c "write -z 0 64k" \ 249 254 -c "write -z 1G 64k" \ 250 255 -c "write -z 2G 64k" \ ··· 256 261 echo 257 262 echo "=== Testing version downgrade with external data file ===" 258 263 echo 259 - IMGOPTS="compat=1.1,data_file=$TEST_IMG.data" _make_test_img 64M 264 + _make_test_img -o "compat=1.1,data_file=$TEST_IMG.data" 64M 260 265 $QEMU_IMG amend -o "compat=0.10" "$TEST_IMG" 261 266 _img_info --format-specific 262 267 _check_test_img ··· 264 269 echo 265 270 echo "=== Try changing the external data file ===" 266 271 echo 267 - IMGOPTS="compat=1.1" _make_test_img 64M 272 + _make_test_img -o "compat=1.1" 64M 268 273 $QEMU_IMG amend -o "data_file=foo" "$TEST_IMG" 269 274 270 275 echo 271 - IMGOPTS="compat=1.1,data_file=$TEST_IMG.data" _make_test_img 64M 276 + _make_test_img -o "compat=1.1,data_file=$TEST_IMG.data" 64M 272 277 $QEMU_IMG amend -o "data_file=foo" "$TEST_IMG" 273 278 _img_info --format-specific 274 279 TEST_IMG="data-file.filename=$TEST_IMG.data,file.filename=$TEST_IMG" _img_info --format-specific --image-opts ··· 281 286 echo 282 287 echo "=== Clearing and setting data-file-raw ===" 283 288 echo 284 - IMGOPTS="compat=1.1,data_file=$TEST_IMG.data,data_file_raw=on" _make_test_img 64M 289 + _make_test_img -o "compat=1.1,data_file=$TEST_IMG.data,data_file_raw=on" 64M 285 290 $QEMU_IMG amend -o "data_file_raw=on" "$TEST_IMG" 286 291 _img_info --format-specific 287 292 _check_test_img
+36 -36
tests/qemu-iotests/061.out
··· 18 18 refcount_table_clusters 1 19 19 nb_snapshots 0 20 20 snapshot_offset 0x0 21 - incompatible_features 0x0 22 - compatible_features 0x1 23 - autoclear_features 0x0 21 + incompatible_features [] 22 + compatible_features [0] 23 + autoclear_features [] 24 24 refcount_order 4 25 25 header_length 104 26 26 ··· 42 42 refcount_table_clusters 1 43 43 nb_snapshots 0 44 44 snapshot_offset 0x0 45 - incompatible_features 0x0 46 - compatible_features 0x0 47 - autoclear_features 0x0 45 + incompatible_features [] 46 + compatible_features [] 47 + autoclear_features [] 48 48 refcount_order 4 49 49 header_length 72 50 50 ··· 76 76 refcount_table_clusters 1 77 77 nb_snapshots 0 78 78 snapshot_offset 0x0 79 - incompatible_features 0x0 80 - compatible_features 0x1 81 - autoclear_features 0x0 79 + incompatible_features [] 80 + compatible_features [0] 81 + autoclear_features [] 82 82 refcount_order 4 83 83 header_length 104 84 84 ··· 100 100 refcount_table_clusters 1 101 101 nb_snapshots 0 102 102 snapshot_offset 0x0 103 - incompatible_features 0x0 104 - compatible_features 0x0 105 - autoclear_features 0x0 103 + incompatible_features [] 104 + compatible_features [] 105 + autoclear_features [] 106 106 refcount_order 4 107 107 header_length 72 108 108 ··· 132 132 refcount_table_clusters 1 133 133 nb_snapshots 0 134 134 snapshot_offset 0x0 135 - incompatible_features 0x1 136 - compatible_features 0x1 137 - autoclear_features 0x0 135 + incompatible_features [0] 136 + compatible_features [0] 137 + autoclear_features [] 138 138 refcount_order 4 139 139 header_length 104 140 140 ··· 161 161 refcount_table_clusters 1 162 162 nb_snapshots 0 163 163 snapshot_offset 0x0 164 - incompatible_features 0x0 165 - compatible_features 0x0 166 - autoclear_features 0x0 164 + incompatible_features [] 165 + compatible_features [] 166 + autoclear_features [] 167 167 refcount_order 4 168 168 header_length 72 169 169 ··· 187 187 refcount_table_clusters 1 188 188 nb_snapshots 0 189 189 snapshot_offset 0x0 190 - incompatible_features 0x0 191 - compatible_features 0x40000000000 192 - autoclear_features 0x40000000000 190 + incompatible_features [] 191 + compatible_features [42] 192 + autoclear_features [42] 193 193 refcount_order 4 194 194 header_length 104 195 195 ··· 211 211 refcount_table_clusters 1 212 212 nb_snapshots 0 213 213 snapshot_offset 0x0 214 - incompatible_features 0x0 215 - compatible_features 0x0 216 - autoclear_features 0x0 214 + incompatible_features [] 215 + compatible_features [] 216 + autoclear_features [] 217 217 refcount_order 4 218 218 header_length 72 219 219 ··· 237 237 refcount_table_clusters 1 238 238 nb_snapshots 0 239 239 snapshot_offset 0x0 240 - incompatible_features 0x0 241 - compatible_features 0x0 242 - autoclear_features 0x0 240 + incompatible_features [] 241 + compatible_features [] 242 + autoclear_features [] 243 243 refcount_order 4 244 244 header_length 72 245 245 ··· 256 256 refcount_table_clusters 1 257 257 nb_snapshots 0 258 258 snapshot_offset 0x0 259 - incompatible_features 0x0 260 - compatible_features 0x1 261 - autoclear_features 0x0 259 + incompatible_features [] 260 + compatible_features [0] 261 + autoclear_features [] 262 262 refcount_order 4 263 263 header_length 104 264 264 ··· 290 290 refcount_table_clusters 1 291 291 nb_snapshots 0 292 292 snapshot_offset 0x0 293 - incompatible_features 0x1 294 - compatible_features 0x1 295 - autoclear_features 0x0 293 + incompatible_features [0] 294 + compatible_features [0] 295 + autoclear_features [] 296 296 refcount_order 4 297 297 header_length 104 298 298 ··· 319 319 refcount_table_clusters 1 320 320 nb_snapshots 0 321 321 snapshot_offset 0x0 322 - incompatible_features 0x0 323 - compatible_features 0x0 324 - autoclear_features 0x0 322 + incompatible_features [] 323 + compatible_features [] 324 + autoclear_features [] 325 325 refcount_order 4 326 326 header_length 104 327 327
+3 -2
tests/qemu-iotests/062
··· 37 37 . ./common.rc 38 38 . ./common.filter 39 39 40 - # This tests qocw2-specific low-level functionality 40 + # This tests qcow2-specific low-level functionality 41 41 _supported_fmt qcow2 42 42 _supported_proto generic 43 + # We need zero clusters and snapshots 44 + _unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' data_file 43 45 44 - IMGOPTS="compat=1.1" 45 46 IMG_SIZE=64M 46 47 47 48 echo
+8 -10
tests/qemu-iotests/063
··· 29 29 30 30 _cleanup() 31 31 { 32 - _cleanup_test_img 33 - rm -f "$TEST_IMG.orig" "$TEST_IMG.raw1" "$TEST_IMG.raw2" 32 + _cleanup_test_img 33 + for img in "$TEST_IMG".{orig,raw1,raw2,target}; do 34 + _rm_test_img "$img" 35 + done 34 36 } 35 37 trap "_cleanup; exit \$status" 0 1 2 3 15 36 38 ··· 49 51 _make_test_img 4M 50 52 51 53 echo "== Testing conversion with -n fails with no target file ==" 52 - # check .orig file does not exist 53 - rm -f "$TEST_IMG.orig" 54 54 if $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n "$TEST_IMG" "$TEST_IMG.orig" >/dev/null 2>&1; then 55 55 exit 1 56 56 fi 57 57 58 58 echo "== Testing conversion with -n succeeds with a target file ==" 59 - rm -f "$TEST_IMG.orig" 60 - cp "$TEST_IMG" "$TEST_IMG.orig" 59 + _rm_test_img "$TEST_IMG.orig" 60 + TEST_IMG="$TEST_IMG.orig" _make_test_img 4M 61 61 if ! $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n "$TEST_IMG" "$TEST_IMG.orig" ; then 62 62 exit 1 63 63 fi ··· 83 83 _check_test_img 84 84 85 85 echo "== Testing conversion to a smaller file fails ==" 86 - rm -f "$TEST_IMG.orig" 87 - mv "$TEST_IMG" "$TEST_IMG.orig" 88 - _make_test_img 2M 89 - if $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n "$TEST_IMG.orig" "$TEST_IMG" >/dev/null 2>&1; then 86 + TEST_IMG="$TEST_IMG.target" _make_test_img 2M 87 + if $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n "$TEST_IMG" "$TEST_IMG.target" >/dev/null 2>&1; then 90 88 exit 1 91 89 fi 92 90
+2 -1
tests/qemu-iotests/063.out
··· 2 2 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4194304 3 3 == Testing conversion with -n fails with no target file == 4 4 == Testing conversion with -n succeeds with a target file == 5 + Formatting 'TEST_DIR/t.IMGFMT.orig', fmt=IMGFMT size=4194304 5 6 == Testing conversion to raw is the same after conversion with -n == 6 7 == Testing conversion back to original format == 7 8 No errors were found on the image. 8 9 == Testing conversion to a smaller file fails == 9 - Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2097152 10 + Formatting 'TEST_DIR/t.IMGFMT.target', fmt=IMGFMT size=2097152 10 11 == Regression testing for copy offloading bug == 11 12 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 12 13 Formatting 'TEST_DIR/t.IMGFMT.target', fmt=IMGFMT size=1048576
+5 -2
tests/qemu-iotests/066
··· 36 36 . ./common.rc 37 37 . ./common.filter 38 38 39 - # This tests qocw2-specific low-level functionality 39 + # This tests qcow2-specific low-level functionality 40 40 _supported_fmt qcow2 41 41 _supported_proto generic 42 + # We need zero clusters and snapshots 43 + # (TODO: Consider splitting the snapshot part into a separate test 44 + # file, so this one runs with refcount_bits=1 and data_file) 45 + _unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' data_file 42 46 43 47 # Intentionally create an unaligned image 44 - IMGOPTS="compat=1.1" 45 48 IMG_SIZE=$((64 * 1024 * 1024 + 512)) 46 49 47 50 echo
+4 -2
tests/qemu-iotests/067
··· 32 32 33 33 _supported_fmt qcow2 34 34 _supported_proto file 35 - # Because anything other than 16 would change the output of query-block 36 - _unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' 35 + # Because anything other than 16 would change the output of query-block, 36 + # and external data files would change the output of 37 + # query-named-block-nodes 38 + _unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file 37 39 38 40 do_run_qemu() 39 41 {
+4 -2
tests/qemu-iotests/068
··· 36 36 . ./common.rc 37 37 . ./common.filter 38 38 39 - # This tests qocw2-specific low-level functionality 39 + # This tests qcow2-specific low-level functionality 40 40 _supported_fmt qcow2 41 41 _supported_proto generic 42 + # Internal snapshots are (currently) impossible with refcount_bits=1, 43 + # and generally impossible with external data files 44 + _unsupported_imgopts 'compat=0.10' 'refcount_bits=1[^0-9]' data_file 42 45 43 - IMGOPTS="compat=1.1" 44 46 IMG_SIZE=128K 45 47 46 48 case "$QEMU_DEFAULT_MACHINE" in
+1 -1
tests/qemu-iotests/069
··· 47 47 echo 48 48 TEST_IMG="$TEST_IMG.base" _make_test_img $IMG_SIZE 49 49 _make_test_img -b "$TEST_IMG.base" $IMG_SIZE 50 - rm -f "$TEST_IMG.base" 50 + _rm_test_img "$TEST_IMG.base" 51 51 # Just open the image and close it right again (this should print an error message) 52 52 $QEMU_IO -c quit "$TEST_IMG" 2>&1 | _filter_testdir | _filter_imgfmt 53 53
+5 -2
tests/qemu-iotests/071
··· 39 39 _supported_fmt qcow2 40 40 _supported_proto file 41 41 _require_drivers blkdebug blkverify 42 + # blkdebug can only inject errors on bs->file, not on the data_file, 43 + # so thie test does not work with external data files 44 + _unsupported_imgopts data_file 42 45 43 46 do_run_qemu() 44 47 { ··· 58 61 echo "=== Testing blkverify through filename ===" 59 62 echo 60 63 61 - TEST_IMG="$TEST_IMG.base" IMGOPTS="" IMGFMT="raw" _make_test_img $IMG_SIZE |\ 64 + TEST_IMG="$TEST_IMG.base" IMGFMT="raw" _make_test_img --no-opts $IMG_SIZE |\ 62 65 _filter_imgfmt 63 66 _make_test_img $IMG_SIZE 64 67 $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base $TEST_IMG" \ ··· 73 76 echo "=== Testing blkverify through file blockref ===" 74 77 echo 75 78 76 - TEST_IMG="$TEST_IMG.base" IMGOPTS="" IMGFMT="raw" _make_test_img $IMG_SIZE |\ 79 + TEST_IMG="$TEST_IMG.base" IMGFMT="raw" _make_test_img --no-opts $IMG_SIZE |\ 77 80 _filter_imgfmt 78 81 _make_test_img $IMG_SIZE 79 82 $QEMU_IO -c "open -o driver=raw,file.driver=blkverify,file.raw.filename=$TEST_IMG.base,file.test.driver=$IMGFMT,file.test.file.filename=$TEST_IMG" \
+4
tests/qemu-iotests/073
··· 39 39 _supported_fmt qcow2 40 40 _supported_proto generic 41 41 _unsupported_proto vxhs 42 + # External data files do not support compressed clusters 43 + # (TODO: Consider writing a version for external data files that does 44 + # not test compressed clusters) 45 + _unsupported_imgopts data_file 42 46 43 47 CLUSTER_SIZE=64k 44 48 size=128M
+3 -1
tests/qemu-iotests/074
··· 31 31 { 32 32 echo "Cleanup" 33 33 _cleanup_test_img 34 - rm "${TEST_IMG2}" 34 + _rm_test_img "${TEST_IMG2}" 35 35 rm -f "$TEST_DIR/blkdebug.conf" 36 36 } 37 37 trap "_cleanup; exit \$status" 0 1 2 3 15 ··· 50 50 _supported_fmt qcow2 51 51 _supported_proto file 52 52 _supported_os Linux 53 + # blkdebug can only inject errors on bs->file 54 + _unsupported_imgopts data_file 53 55 54 56 # Setup test basic parameters 55 57 TEST_IMG2=$TEST_IMG.2
+1 -2
tests/qemu-iotests/079
··· 47 47 cluster_sizes="16384 32768 65536 131072 262144 524288 1048576 2097152 4194304" 48 48 49 49 for s in $cluster_sizes; do 50 - IMGOPTS=$(_optstr_add "$IMGOPTS" "preallocation=metadata,cluster_size=$s") \ 51 - _make_test_img 4G 50 + _make_test_img -o "preallocation=metadata,cluster_size=$s" 4G 52 51 done 53 52 54 53 # success, all done
+4 -3
tests/qemu-iotests/080
··· 28 28 29 29 _cleanup() 30 30 { 31 - rm -f $TEST_IMG.snap 31 + _rm_test_img "$TEST_IMG.snap" 32 32 _cleanup_test_img 33 33 } 34 34 trap "_cleanup; exit \$status" 0 1 2 3 15 ··· 40 40 _supported_fmt qcow2 41 41 _supported_proto file 42 42 _supported_os Linux 43 - # - Internal snapshots are (currently) impossible with refcount_bits=1 43 + # - Internal snapshots are (currently) impossible with refcount_bits=1, 44 + # and generally impossible with external data files 44 45 # - This is generally a test for compat=1.1 images 45 - _unsupported_imgopts 'refcount_bits=1[^0-9]' 'compat=0.10' 46 + _unsupported_imgopts 'refcount_bits=1[^0-9]' data_file 'compat=0.10' 46 47 47 48 header_size=104 48 49
+3 -3
tests/qemu-iotests/081
··· 28 28 29 29 _cleanup() 30 30 { 31 - rm -rf $TEST_DIR/1.raw 32 - rm -rf $TEST_DIR/2.raw 33 - rm -rf $TEST_DIR/3.raw 31 + _rm_test_img "$TEST_DIR/1.raw" 32 + _rm_test_img "$TEST_DIR/2.raw" 33 + _rm_test_img "$TEST_DIR/3.raw" 34 34 } 35 35 trap "_cleanup; exit \$status" 0 1 2 3 15 36 36
+9 -9
tests/qemu-iotests/085
··· 41 41 _cleanup_qemu 42 42 for i in $(seq 1 ${SNAPSHOTS}) 43 43 do 44 - rm -f "${TEST_DIR}/${i}-${snapshot_virt0}" 45 - rm -f "${TEST_DIR}/${i}-${snapshot_virt1}" 44 + _rm_test_img "${TEST_DIR}/${i}-${snapshot_virt0}" 45 + _rm_test_img "${TEST_DIR}/${i}-${snapshot_virt1}" 46 + done 47 + for img in "${TEST_IMG}".{1,2,base} 48 + do 49 + _rm_test_img "$img" 46 50 done 47 - rm -f "${TEST_IMG}" "${TEST_IMG}.1" "${TEST_IMG}.2" "${TEST_IMG}.base" 48 51 49 52 } 50 53 trap "_cleanup; exit \$status" 0 1 2 3 15 ··· 102 105 { 103 106 base_image="${TEST_DIR}/$((${1}-1))-${snapshot_virt0}" 104 107 snapshot_file="${TEST_DIR}/${1}-${snapshot_virt0}" 105 - _make_test_img -u -b "${base_image}" "$size" 106 - mv "${TEST_IMG}" "${snapshot_file}" 108 + TEST_IMG=$snapshot_file _make_test_img -u -b "${base_image}" "$size" 107 109 do_blockdev_add "$1" "'backing': null, " "${snapshot_file}" 108 110 } 109 111 ··· 119 121 120 122 size=128M 121 123 122 - _make_test_img $size 123 - mv "${TEST_IMG}" "${TEST_IMG}.1" 124 - _make_test_img $size 125 - mv "${TEST_IMG}" "${TEST_IMG}.2" 124 + TEST_IMG="$TEST_IMG.1" _make_test_img $size 125 + TEST_IMG="$TEST_IMG.2" _make_test_img $size 126 126 127 127 echo 128 128 echo === Running QEMU ===
+4 -4
tests/qemu-iotests/085.out
··· 1 1 QA output created by 085 2 - Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 3 - Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 2 + Formatting 'TEST_DIR/t.IMGFMT.1', fmt=IMGFMT size=134217728 3 + Formatting 'TEST_DIR/t.IMGFMT.2', fmt=IMGFMT size=134217728 4 4 5 5 === Running QEMU === 6 6 ··· 68 68 69 69 === Create a couple of snapshots using blockdev-snapshot === 70 70 71 - Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/10-snapshot-v0.IMGFMT 71 + Formatting 'TEST_DIR/11-snapshot-v0.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/10-snapshot-v0.IMGFMT 72 72 { 'execute': 'blockdev-add', 'arguments': { 'driver': 'IMGFMT', 'node-name': 'snap_11', 'backing': null, 'file': { 'driver': 'file', 'filename': 'TEST_DIR/11-snapshot-v0.IMGFMT', 'node-name': 'file_11' } } } 73 73 {"return": {}} 74 74 { 'execute': 'blockdev-snapshot', 'arguments': { 'node': 'virtio0', 'overlay':'snap_11' } } 75 75 {"return": {}} 76 - Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/11-snapshot-v0.IMGFMT 76 + Formatting 'TEST_DIR/12-snapshot-v0.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/11-snapshot-v0.IMGFMT 77 77 { 'execute': 'blockdev-add', 'arguments': { 'driver': 'IMGFMT', 'node-name': 'snap_12', 'backing': null, 'file': { 'driver': 'file', 'filename': 'TEST_DIR/12-snapshot-v0.IMGFMT', 'node-name': 'file_12' } } } 78 78 {"return": {}} 79 79 { 'execute': 'blockdev-snapshot', 'arguments': { 'node': 'virtio0', 'overlay':'snap_12' } }
+1 -1
tests/qemu-iotests/088
··· 28 28 29 29 _cleanup() 30 30 { 31 - rm -f $TEST_IMG.snap 31 + _rm_test_img "$TEST_IMG.snap" 32 32 _cleanup_test_img 33 33 } 34 34 trap "_cleanup; exit \$status" 0 1 2 3 15
+2
tests/qemu-iotests/090
··· 38 38 39 39 _supported_fmt qcow2 40 40 _supported_proto file nfs 41 + # External data files do not support compressed clusters 42 + _unsupported_imgopts data_file 41 43 42 44 IMG_SIZE=128K 43 45
+1 -1
tests/qemu-iotests/091
··· 101 101 ${QEMU_IO} -c "read -P 0x22 0 4M" "${TEST_IMG}" | _filter_testdir | _filter_qemu_io 102 102 103 103 echo "Running 'qemu-img check -r all \$TEST_IMG'" 104 - "${QEMU_IMG}" check -r all "${TEST_IMG}" 2>&1 | _filter_testdir | _filter_qemu 104 + _check_test_img -r all 105 105 106 106 echo "*** done" 107 107 rm -f $seq.full
-2
tests/qemu-iotests/091.out
··· 23 23 4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 24 24 Running 'qemu-img check -r all $TEST_IMG' 25 25 No errors were found on the image. 26 - 80/16384 = 0.49% allocated, 0.00% fragmented, 0.00% compressed clusters 27 - Image end offset: 5570560 28 26 *** done
+1 -1
tests/qemu-iotests/092
··· 28 28 29 29 _cleanup() 30 30 { 31 - rm -f $TEST_IMG.snap 31 + _rm_test_img "$TEST_IMG.snap" 32 32 _cleanup_test_img 33 33 } 34 34 trap "_cleanup; exit \$status" 0 1 2 3 15
+2 -2
tests/qemu-iotests/094
··· 30 30 { 31 31 _cleanup_qemu 32 32 _cleanup_test_img 33 - rm -f "$TEST_DIR/source.$IMGFMT" 33 + _rm_test_img "$TEST_DIR/source.$IMGFMT" 34 34 } 35 35 36 36 trap "_cleanup; exit \$status" 0 1 2 3 15 ··· 45 45 _unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" 46 46 47 47 _make_test_img 64M 48 - $QEMU_IMG create -f $IMGFMT "$TEST_DIR/source.$IMGFMT" 64M | _filter_img_create 48 + TEST_IMG_FILE="$TEST_DIR/source.$IMGFMT" IMGPROTO=file _make_test_img 64M 49 49 50 50 _launch_qemu -drive if=none,id=src,file="$TEST_DIR/source.$IMGFMT",format=raw \ 51 51 -nodefaults
+3 -2
tests/qemu-iotests/095
··· 32 32 _cleanup() 33 33 { 34 34 _cleanup_qemu 35 - rm -f "${TEST_IMG}.base" "${TEST_IMG}.snp1" 36 - _cleanup_test_img 35 + _rm_test_img "${TEST_IMG}.base" 36 + _rm_test_img "${TEST_IMG}.snp1" 37 + _cleanup_test_img 37 38 } 38 39 trap "_cleanup; exit \$status" 0 1 2 3 15 39 40
+4 -2
tests/qemu-iotests/098
··· 40 40 41 41 _supported_fmt qcow2 42 42 _supported_proto file 43 - 44 - IMGOPTS="compat=1.1" 43 + # The code path we want to test here only works for compat=1.1 images; 44 + # blkdebug can only inject errors on bs->file, so external data files 45 + # do not work with this test 46 + _unsupported_imgopts 'compat=0.10' data_file 45 47 46 48 for event in l1_update empty_image_prepare reftable_update refblock_alloc; do 47 49
+6 -4
tests/qemu-iotests/099
··· 29 29 30 30 _cleanup() 31 31 { 32 - _cleanup_test_img 32 + _cleanup_test_img 33 + _rm_test_img "$TEST_IMG.compare" 34 + rm -f "$TEST_DIR/blkdebug.conf" 35 + 33 36 } 34 37 trap "_cleanup; exit \$status" 0 1 2 3 15 35 38 ··· 43 46 _supported_proto file 44 47 _supported_os Linux 45 48 _require_drivers blkdebug blkverify 49 + # data_file would change the json:{} filenames 46 50 _unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" \ 47 - "subformat=twoGbMaxExtentSparse" 51 + "subformat=twoGbMaxExtentSparse" data_file 48 52 49 53 do_run_qemu() 50 54 { ··· 120 124 121 125 test_qemu "file.driver=blkdebug,file.image.filename=$TEST_IMG" 122 126 123 - 124 - rm -f "$TEST_IMG.compare" "$TEST_DIR/blkdebug.conf" 125 127 126 128 # success, all done 127 129 echo "*** done"
+3 -2
tests/qemu-iotests/103
··· 38 38 39 39 _supported_fmt qcow2 40 40 _supported_proto file nfs 41 - # Internal snapshots are (currently) impossible with refcount_bits=1 42 - _unsupported_imgopts 'refcount_bits=1[^0-9]' 41 + # Internal snapshots are (currently) impossible with refcount_bits=1, 42 + # and generally impossible with external data files 43 + _unsupported_imgopts 'refcount_bits=1[^0-9]' data_file 43 44 44 45 IMG_SIZE=64K 45 46
+1 -1
tests/qemu-iotests/106
··· 51 51 echo 52 52 echo "--- create_mode=$create_mode growth_mode=$growth_mode ---" 53 53 54 - IMGOPTS="preallocation=$create_mode" _make_test_img ${CREATION_SIZE}K 54 + _make_test_img -o "preallocation=$create_mode" ${CREATION_SIZE}K 55 55 $QEMU_IMG resize -f "$IMGFMT" --preallocation=$growth_mode "$TEST_IMG" +${GROWTH_SIZE}K 56 56 57 57 expected_size=0
+6 -4
tests/qemu-iotests/108
··· 37 37 . ./common.rc 38 38 . ./common.filter 39 39 40 - # This tests qocw2-specific low-level functionality 40 + # This tests qcow2-specific low-level functionality 41 41 _supported_fmt qcow2 42 42 _supported_proto file 43 43 _supported_os Linux 44 - # This test directly modifies a refblock so it relies on refcount_bits being 16 45 - _unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' 44 + # This test directly modifies a refblock so it relies on refcount_bits being 16; 45 + # and the low-level modification it performs are not tuned for external data 46 + # files 47 + _unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file 46 48 47 49 echo 48 50 echo '=== Repairing an image without any refcount table ===' ··· 65 67 echo '=== Repairing unreferenced data cluster in new refblock area ===' 66 68 echo 67 69 68 - IMGOPTS='cluster_size=512' _make_test_img 64M 70 + _make_test_img -o 'cluster_size=512' 64M 69 71 # Allocate the first 128 kB in the image (first refblock) 70 72 $QEMU_IO -c 'write 0 0x1b200' "$TEST_IMG" | _filter_qemu_io 71 73 # should be 131072 == 0x20000
+2 -2
tests/qemu-iotests/109
··· 29 29 _cleanup() 30 30 { 31 31 _cleanup_qemu 32 - rm -f $TEST_IMG.src 33 - _cleanup_test_img 32 + _rm_test_img "$TEST_IMG.src" 33 + _cleanup_test_img 34 34 } 35 35 trap "_cleanup; exit \$status" 0 1 2 3 15 36 36
+7 -4
tests/qemu-iotests/110
··· 28 28 29 29 _cleanup() 30 30 { 31 - _cleanup_test_img 32 - rm -f "$TEST_IMG.copy" 31 + _cleanup_test_img 32 + _rm_test_img "$TEST_IMG.copy" 33 33 } 34 34 trap "_cleanup; exit \$status" 0 1 2 3 15 35 35 ··· 67 67 # Across blkdebug without a config file, you cannot reconstruct filenames, so 68 68 # qemu is incapable of knowing the directory of the top image from the filename 69 69 # alone. However, using bdrv_dirname(), it should still work. 70 + # (Filter out the json:{} filename so this test works with external data files) 70 71 TEST_IMG="json:{ 71 72 'driver': '$IMGFMT', 72 73 'file': { ··· 82 83 } 83 84 ] 84 85 } 85 - }" _img_info | _filter_img_info | grep -v 'backing file format' 86 + }" _img_info | _filter_img_info | grep -v 'backing file format' \ 87 + | _filter_json_filename 86 88 87 89 echo 88 90 echo '=== Backing name is always relative to the backed image ===' ··· 114 116 } 115 117 ] 116 118 } 117 - }" _img_info | _filter_img_info | grep -v 'backing file format' 119 + }" _img_info | _filter_img_info | grep -v 'backing file format' \ 120 + | _filter_json_filename 118 121 119 122 120 123 # success, all done
+2 -2
tests/qemu-iotests/110.out
··· 11 11 12 12 === Non-reconstructable filename === 13 13 14 - image: json:{"driver": "IMGFMT", "file": {"set-state.0.event": "read_aio", "image": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, "driver": "blkdebug", "set-state.0.new_state": 42}} 14 + image: json:{ /* filtered */ } 15 15 file format: IMGFMT 16 16 virtual size: 64 MiB (67108864 bytes) 17 17 backing file: t.IMGFMT.base (actual path: TEST_DIR/t.IMGFMT.base) ··· 22 22 23 23 === Nodes without a common directory === 24 24 25 - image: json:{"driver": "IMGFMT", "file": {"children": [{"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}, {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.copy"}], "driver": "quorum", "vote-threshold": 1}} 25 + image: json:{ /* filtered */ } 26 26 file format: IMGFMT 27 27 virtual size: 64 MiB (67108864 bytes) 28 28 backing file: t.IMGFMT.base (cannot determine actual path)
+1 -2
tests/qemu-iotests/111
··· 41 41 _supported_proto file 42 42 _unsupported_imgopts "subformat=monolithicFlat" "subformat=twoGbMaxExtentFlat" 43 43 44 - $QEMU_IMG create -f $IMGFMT -b "$TEST_IMG.inexistent" "$TEST_IMG" 2>&1 \ 45 - | _filter_testdir | _filter_imgfmt 44 + _make_test_img -b "$TEST_IMG.inexistent" 46 45 47 46 # success, all done 48 47 echo '*** done'
+19 -18
tests/qemu-iotests/112
··· 40 40 _supported_fmt qcow2 41 41 _supported_proto file 42 42 # This test will set refcount_bits on its own which would conflict with the 43 - # manual setting; compat will be overridden as well 44 - _unsupported_imgopts refcount_bits 'compat=0.10' 43 + # manual setting; compat will be overridden as well; 44 + # and external data files do not work well with our refcount testing 45 + _unsupported_imgopts refcount_bits 'compat=0.10' data_file 45 46 46 47 print_refcount_bits() 47 48 { ··· 53 54 echo 54 55 55 56 # Must be positive (non-zero) 56 - IMGOPTS="$IMGOPTS,refcount_bits=0" _make_test_img 64M 57 + _make_test_img -o "refcount_bits=0" 64M 57 58 # Must be positive (non-negative) 58 - IMGOPTS="$IMGOPTS,refcount_bits=-1" _make_test_img 64M 59 + _make_test_img -o "refcount_bits=-1" 64M 59 60 # May not exceed 64 60 - IMGOPTS="$IMGOPTS,refcount_bits=128" _make_test_img 64M 61 + _make_test_img -o "refcount_bits=128" 64M 61 62 # Must be a power of two 62 - IMGOPTS="$IMGOPTS,refcount_bits=42" _make_test_img 64M 63 + _make_test_img -o "refcount_bits=42" 64M 63 64 64 65 # 1 is the minimum 65 - IMGOPTS="$IMGOPTS,refcount_bits=1" _make_test_img 64M 66 + _make_test_img -o "refcount_bits=1" 64M 66 67 print_refcount_bits 67 68 68 69 # 64 is the maximum 69 - IMGOPTS="$IMGOPTS,refcount_bits=64" _make_test_img 64M 70 + _make_test_img -o "refcount_bits=64" 64M 70 71 print_refcount_bits 71 72 72 73 # 16 is the default ··· 78 79 echo 79 80 80 81 # Should work 81 - IMGOPTS="$IMGOPTS,compat=0.10,refcount_bits=16" _make_test_img 64M 82 + _make_test_img -o "compat=0.10,refcount_bits=16" 64M 82 83 print_refcount_bits 83 84 84 85 # Should not work 85 - IMGOPTS="$IMGOPTS,compat=0.10,refcount_bits=1" _make_test_img 64M 86 - IMGOPTS="$IMGOPTS,compat=0.10,refcount_bits=64" _make_test_img 64M 86 + _make_test_img -o "compat=0.10,refcount_bits=1" 64M 87 + _make_test_img -o "compat=0.10,refcount_bits=64" 64M 87 88 88 89 89 90 echo 90 91 echo '=== Snapshot limit on refcount_bits=1 ===' 91 92 echo 92 93 93 - IMGOPTS="$IMGOPTS,refcount_bits=1" _make_test_img 64M 94 + _make_test_img -o "refcount_bits=1" 64M 94 95 print_refcount_bits 95 96 96 97 $QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io ··· 106 107 echo '=== Snapshot limit on refcount_bits=2 ===' 107 108 echo 108 109 109 - IMGOPTS="$IMGOPTS,refcount_bits=2" _make_test_img 64M 110 + _make_test_img -o "refcount_bits=2" 64M 110 111 print_refcount_bits 111 112 112 113 $QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io ··· 124 125 echo '=== Compressed clusters with refcount_bits=1 ===' 125 126 echo 126 127 127 - IMGOPTS="$IMGOPTS,refcount_bits=1" _make_test_img 64M 128 + _make_test_img -o "refcount_bits=1" 64M 128 129 print_refcount_bits 129 130 130 131 # Both should fit into a single host cluster; instead of failing to increase the ··· 140 141 echo '=== MSb set in 64 bit refcount ===' 141 142 echo 142 143 143 - IMGOPTS="$IMGOPTS,refcount_bits=64" _make_test_img 64M 144 + _make_test_img -o "refcount_bits=64" 64M 144 145 print_refcount_bits 145 146 146 147 $QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io ··· 158 159 echo '=== Snapshot on maximum 64 bit refcount value ===' 159 160 echo 160 161 161 - IMGOPTS="$IMGOPTS,refcount_bits=64" _make_test_img 64M 162 + _make_test_img -o "refcount_bits=64" 64M 162 163 print_refcount_bits 163 164 164 165 $QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io ··· 239 240 echo '=== Testing too many references for check ===' 240 241 echo 241 242 242 - IMGOPTS="$IMGOPTS,refcount_bits=1" _make_test_img 64M 243 + _make_test_img -o "refcount_bits=1" 64M 243 244 print_refcount_bits 244 245 245 246 # This cluster should be created at 0x50000 ··· 262 263 echo '=== Multiple walks necessary during amend ===' 263 264 echo 264 265 265 - IMGOPTS="$IMGOPTS,refcount_bits=1,cluster_size=512" _make_test_img 64k 266 + _make_test_img -o "refcount_bits=1,cluster_size=512" 64k 266 267 267 268 # Cluster 0 is the image header, clusters 1 to 4 are used by the L1 table, a 268 269 # single L2 table, the reftable and a single refblock. This creates 58 data
+2
tests/qemu-iotests/114
··· 39 39 _supported_fmt qcow2 40 40 _supported_proto generic 41 41 _unsupported_proto vxhs 42 + # qcow2.py does not work too well with external data files 43 + _unsupported_imgopts data_file 42 44 43 45 44 46 TEST_IMG="$TEST_IMG.base" _make_test_img 64M
+1 -2
tests/qemu-iotests/115
··· 64 64 # least 256 MB. We can achieve that by using preallocation=metadata for an image 65 65 # which has a guest disk size of 256 MB. 66 66 67 - IMGOPTS="$IMGOPTS,refcount_bits=64,cluster_size=512,preallocation=metadata" \ 68 - _make_test_img 256M 67 + _make_test_img -o "refcount_bits=64,cluster_size=512,preallocation=metadata" 256M 69 68 70 69 # We know for sure that the L1 and refcount tables do not overlap with any other 71 70 # structure because the metadata overlap checks would have caught that case.
+6 -3
tests/qemu-iotests/121
··· 39 39 _supported_fmt qcow2 40 40 _supported_proto file 41 41 _supported_os Linux 42 + # Refcount structures are used much differently with external data 43 + # files 44 + _unsupported_imgopts data_file 42 45 43 46 echo 44 47 echo '=== New refcount structures may not conflict with existing structures ===' ··· 50 53 # Preallocation speeds up the write operation, but preallocating everything will 51 54 # destroy the purpose of the write; so preallocate one KB less than what would 52 55 # cause a reftable growth... 53 - IMGOPTS='preallocation=metadata,cluster_size=1k' _make_test_img 64512K 56 + _make_test_img -o 'preallocation=metadata,cluster_size=1k' 64512K 54 57 # ...and make the image the desired size afterwards. 55 58 $QEMU_IMG resize "$TEST_IMG" 65M 56 59 ··· 73 76 echo '--- Test 2 ---' 74 77 echo 75 78 76 - IMGOPTS='preallocation=metadata,cluster_size=1k' _make_test_img 64513K 79 + _make_test_img -o 'preallocation=metadata,cluster_size=1k' 64513K 77 80 # This results in an L1 table growth which in turn results in some clusters at 78 81 # the start of the image becoming free 79 82 $QEMU_IMG resize "$TEST_IMG" 65M ··· 96 99 echo '=== Allocating a new refcount block must not leave holes in the image ===' 97 100 echo 98 101 99 - IMGOPTS='cluster_size=512,refcount_bits=16' _make_test_img 1M 102 + _make_test_img -o 'cluster_size=512,refcount_bits=16' 1M 100 103 101 104 # This results in an image with 256 used clusters: the qcow2 header, 102 105 # the refcount table, one refcount block, the L1 table, four L2 tables
+4 -2
tests/qemu-iotests/122
··· 28 28 29 29 _cleanup() 30 30 { 31 - rm -f "$TEST_IMG".[123] 32 - _cleanup_test_img 31 + for img in "$TEST_IMG".[123]; do 32 + _rm_test_img "$img" 33 + done 34 + _cleanup_test_img 33 35 } 34 36 trap "_cleanup; exit \$status" 0 1 2 3 15 35 37
+2 -2
tests/qemu-iotests/123
··· 29 29 _cleanup() 30 30 { 31 31 _cleanup_test_img 32 - rm -f "$SRC_IMG" 32 + _rm_test_img "$SRC_IMG" 33 33 } 34 34 trap "_cleanup; exit \$status" 0 1 2 3 15 35 35 ··· 44 44 SRC_IMG="$TEST_DIR/source.$IMGFMT" 45 45 46 46 _make_test_img 1M 47 - $QEMU_IMG create -f $IMGFMT "$SRC_IMG" 1M | _filter_img_create 47 + TEST_IMG_FILE=$SRC_IMG IMGPROTO=file _make_test_img 1M 48 48 49 49 $QEMU_IO -c 'write -P 42 0 1M' "$SRC_IMG" | _filter_qemu_io 50 50
+1 -1
tests/qemu-iotests/125
··· 114 114 for growth_mode in off metadata falloc full; do 115 115 echo "--- cluster_size=$cluster_size growth_size=$GROWTH_SIZE create_mode=$create_mode growth_mode=$growth_mode ---" 116 116 117 - IMGOPTS="preallocation=$create_mode,cluster_size=$cluster_size" _make_test_img ${CREATION_SIZE} 117 + _make_test_img -o "preallocation=$create_mode,cluster_size=$cluster_size" ${CREATION_SIZE} 118 118 $QEMU_IMG resize -f "$IMGFMT" --preallocation=$growth_mode "$TEST_IMG" +${GROWTH_SIZE}K 119 119 120 120 host_size_0=$(get_image_size_on_host)
+12 -5
tests/qemu-iotests/137
··· 117 117 -c "reopen -o cache-clean-interval=-1" \ 118 118 "$TEST_IMG" | _filter_qemu_io 119 119 120 - IMGOPTS="cluster_size=256k" _make_test_img 32P 120 + _make_test_img -o "cluster_size=256k" 32P 121 121 $QEMU_IO \ 122 122 -c "reopen -o l2-cache-entry-size=512,l2-cache-size=1T" \ 123 123 "$TEST_IMG" | _filter_qemu_io ··· 138 138 "$TEST_IMG" 2>&1 | _filter_qemu_io 139 139 140 140 # The dirty bit must not be set 141 - $PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features 141 + # (Filter the external data file bit) 142 + if $PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features \ 143 + | grep -q '\<0\>' 144 + then 145 + echo 'ERROR: Dirty bit set' 146 + else 147 + echo 'OK: Dirty bit not set' 148 + fi 142 149 143 150 # Similarly we can test whether corruption detection has been enabled: 144 - # Create L1/L2, overwrite first entry in refcount block, allocate something. 151 + # Create L1, overwrite refcounts, force allocation of L2 by writing 152 + # data. 145 153 # Disabling the checks should fail, so the corruption must be detected. 146 154 _make_test_img 64M 147 - $QEMU_IO -c "write 0 64k" "$TEST_IMG" | _filter_qemu_io 148 - poke_file "$TEST_IMG" "$((0x20000))" "\x00\x00" 155 + poke_file "$TEST_IMG" "$((0x20000))" "\x00\x00\x00\x00\x00\x00\x00\x00" 149 156 $QEMU_IO \ 150 157 -c "reopen -o overlap-check=none,lazy-refcounts=42" \ 151 158 -c "write 64k 64k" \
+2 -4
tests/qemu-iotests/137.out
··· 36 36 wrote 512/512 bytes at offset 0 37 37 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 38 38 ./common.rc: Killed ( VALGRIND_QEMU="${VALGRIND_QEMU_IO}" _qemu_proc_exec "${VALGRIND_LOGFILE}" "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@" ) 39 - incompatible_features 0x0 39 + OK: Dirty bit not set 40 40 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 41 - wrote 65536/65536 bytes at offset 0 42 - 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 43 41 qemu-io: Parameter 'lazy-refcounts' expects 'on' or 'off' 44 - qcow2: Marking image as corrupt: Preventing invalid write on metadata (overlaps with qcow2_header); further corruption events will be suppressed 42 + qcow2: Marking image as corrupt: Preventing invalid allocation of L2 table at offset 0; further corruption events will be suppressed 45 43 write failed: Input/output error 46 44 *** done
+5 -3
tests/qemu-iotests/138
··· 36 36 . ./common.rc 37 37 . ./common.filter 38 38 39 - # This tests qocw2-specific low-level functionality 39 + # This tests qcow2-specific low-level functionality 40 40 _supported_fmt qcow2 41 41 _supported_proto file 42 42 _supported_os Linux 43 + # With an external data file, data clusters are not refcounted 44 + # (and so qemu-img check does not check their refcount) 45 + _unsupported_imgopts data_file 43 46 44 47 echo 45 48 echo '=== Check on an image with a multiple of 2^32 clusters ===' 46 49 echo 47 50 48 - IMGOPTS=$(_optstr_add "$IMGOPTS" "cluster_size=512") \ 49 - _make_test_img 512 51 + _make_test_img -o "cluster_size=512" 512 50 52 51 53 # Allocate L2 table 52 54 $QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io
+3 -1
tests/qemu-iotests/141
··· 30 30 { 31 31 _cleanup_qemu 32 32 _cleanup_test_img 33 - rm -f "$TEST_DIR"/{b,m,o}.$IMGFMT 33 + for img in "$TEST_DIR"/{b,m,o}.$IMGFMT; do 34 + _rm_test_img "$img" 35 + done 34 36 } 35 37 trap "_cleanup; exit \$status" 0 1 2 3 15 36 38
+1 -1
tests/qemu-iotests/142
··· 29 29 _cleanup() 30 30 { 31 31 _cleanup_test_img 32 - rm -f $TEST_IMG.snap 32 + _rm_test_img "$TEST_IMG.snap" 33 33 } 34 34 trap "_cleanup; exit \$status" 0 1 2 3 15 35 35
+3 -1
tests/qemu-iotests/144
··· 34 34 _cleanup() 35 35 { 36 36 _cleanup_qemu 37 - rm -f "${TEST_IMG}" "${TMP_SNAP1}" "${TMP_SNAP2}" 37 + for img in "${TEST_IMG}" "${TMP_SNAP1}" "${TMP_SNAP2}"; do 38 + _rm_test_img "$img" 39 + done 38 40 } 39 41 40 42 trap "_cleanup; exit \$status" 0 1 2 3 15
+4 -8
tests/qemu-iotests/153
··· 30 30 _cleanup() 31 31 { 32 32 _cleanup_test_img 33 - rm -f "${TEST_IMG}.base" 34 - rm -f "${TEST_IMG}.overlay" 35 - rm -f "${TEST_IMG}.convert" 36 - rm -f "${TEST_IMG}.a" 37 - rm -f "${TEST_IMG}.b" 38 - rm -f "${TEST_IMG}.c" 39 - rm -f "${TEST_IMG}.lnk" 33 + for img in "${TEST_IMG}".{base,overlay,convert,a,b,c,lnk}; do 34 + _rm_test_img "$img" 35 + done 40 36 } 41 37 trap "_cleanup; exit \$status" 0 1 2 3 15 42 38 ··· 98 94 99 95 echo 100 96 echo "== Creating test image ==" 101 - $QEMU_IMG create -f $IMGFMT "${TEST_IMG}" -b ${TEST_IMG}.base | _filter_img_create 97 + _make_test_img -b "${TEST_IMG}.base" 102 98 103 99 echo 104 100 echo "== Launching QEMU, opts: '$opts1' =="
+8 -2
tests/qemu-iotests/156
··· 37 37 _cleanup() 38 38 { 39 39 _cleanup_qemu 40 - rm -f "$TEST_IMG"{,.target}{,.backing,.overlay} 40 + for img in "$TEST_IMG"{,.target}{,.backing,.overlay}; do 41 + _rm_test_img "$img" 42 + done 41 43 } 42 44 trap "_cleanup; exit \$status" 0 1 2 3 15 43 45 ··· 49 51 _supported_fmt qcow2 qed 50 52 _supported_proto generic 51 53 _unsupported_proto vxhs 54 + # Copying files around with cp does not work with external data files 55 + _unsupported_imgopts data_file 52 56 53 57 # Create source disk 54 58 TEST_IMG="$TEST_IMG.backing" _make_test_img 1M ··· 120 124 '"status": "null"' 121 125 122 126 # Remove the source images 123 - rm -f "$TEST_IMG{,.backing,.overlay}" 127 + for img in "$TEST_IMG{,.backing,.overlay}"; do 128 + _rm_test_img "$img" 129 + done 124 130 125 131 echo 126 132
+1 -1
tests/qemu-iotests/159
··· 28 28 _cleanup() 29 29 { 30 30 _cleanup_test_img 31 - rm -f "$TEST_IMG.out" 31 + _rm_test_img "$TEST_IMG.out" 32 32 } 33 33 trap "_cleanup; exit \$status" 0 1 2 3 15 34 34
+2 -1
tests/qemu-iotests/160
··· 28 28 _cleanup() 29 29 { 30 30 _cleanup_test_img 31 - rm -f "$TEST_IMG.out" "$TEST_IMG.out.dd" 31 + _rm_test_img "$TEST_IMG.out" 32 + _rm_test_img "$TEST_IMG.out.dd" 32 33 } 33 34 trap "_cleanup; exit \$status" 0 1 2 3 15 34 35
+2 -2
tests/qemu-iotests/161
··· 30 30 _cleanup() 31 31 { 32 32 _cleanup_test_img 33 - rm -f "$TEST_IMG.base" 34 - rm -f "$TEST_IMG.int" 33 + _rm_test_img "$TEST_IMG.base" 34 + _rm_test_img "$TEST_IMG.int" 35 35 } 36 36 trap "_cleanup; exit \$status" 0 1 2 3 15 37 37
+1 -1
tests/qemu-iotests/170
··· 28 28 _cleanup() 29 29 { 30 30 _cleanup_test_img 31 - rm -f "$TEST_IMG.out" 31 + _rm_test_img "$TEST_IMG.out" 32 32 } 33 33 trap "_cleanup; exit \$status" 0 1 2 3 15 34 34
+3 -3
tests/qemu-iotests/172
··· 28 28 29 29 _cleanup() 30 30 { 31 - _cleanup_test_img 32 - rm -f "$TEST_IMG.2" 33 - rm -f "$TEST_IMG.3" 31 + _cleanup_test_img 32 + _rm_test_img "$TEST_IMG.2" 33 + _rm_test_img "$TEST_IMG.3" 34 34 } 35 35 trap "_cleanup; exit \$status" 0 1 2 3 15 36 36
+2 -1
tests/qemu-iotests/173
··· 29 29 _cleanup() 30 30 { 31 31 _cleanup_qemu 32 - rm -f "${QEMU_TEST_DIR}/image.base" "${QEMU_TEST_DIR}/image.snp1" 32 + _rm_test_img "${TEST_DIR}/image.base" 33 + _rm_test_img "${TEST_DIR}/image.snp1" 33 34 _cleanup_test_img 34 35 } 35 36 trap "_cleanup; exit \$status" 0 1 2 3 15
+1 -1
tests/qemu-iotests/174
··· 40 40 41 41 42 42 size=256K 43 - IMGFMT=raw IMGKEYSECRET= IMGOPTS= _make_test_img $size | _filter_imgfmt 43 + IMGFMT=raw IMGKEYSECRET= _make_test_img --no-opts $size | _filter_imgfmt 44 44 45 45 echo 46 46 echo "== reading wrong format should fail =="
+1 -1
tests/qemu-iotests/175
··· 95 95 for mode in off full falloc; do 96 96 echo 97 97 echo "== creating image with preallocation $mode ==" 98 - IMGOPTS=preallocation=$mode _make_test_img $size | _filter_imgfmt 98 + _make_test_img -o preallocation=$mode $size | _filter_imgfmt 99 99 stat -c "size=%s, blocks=%b" $TEST_IMG | _filter_blocks $extra_blocks $min_blocks $size 100 100 done 101 101
+5 -2
tests/qemu-iotests/176
··· 47 47 _supported_fmt qcow2 48 48 _supported_proto file 49 49 _supported_os Linux 50 - # Persistent dirty bitmaps require compat=1.1 51 - _unsupported_imgopts 'compat=0.10' 50 + # Persistent dirty bitmaps require compat=1.1; 51 + # Internal snapshots forbid using an external data file 52 + # (they work with refcount_bits=1 here, though, because there actually 53 + # is no data when creating the snapshot) 54 + _unsupported_imgopts 'compat=0.10' data_file 52 55 53 56 run_qemu() 54 57 {
+3 -3
tests/qemu-iotests/178
··· 29 29 _cleanup() 30 30 { 31 31 _cleanup_test_img 32 - rm -f "$TEST_IMG.converted" 32 + _rm_test_img "$TEST_IMG.converted" 33 33 } 34 34 trap "_cleanup; exit \$status" 0 1 2 3 15 35 35 ··· 62 62 63 63 make_test_img_with_fmt() { 64 64 # Shadow global variables within this function 65 - local IMGFMT="$1" IMGOPTS="" 66 - _make_test_img "$2" 65 + local IMGFMT="$1" 66 + _make_test_img --no-opts "$2" 67 67 } 68 68 69 69 qemu_io_with_fmt() {
+1 -1
tests/qemu-iotests/182
··· 30 30 _cleanup() 31 31 { 32 32 _cleanup_test_img 33 - rm -f "$TEST_IMG.overlay" 33 + _rm_test_img "$TEST_IMG.overlay" 34 34 rm -f "$SOCK_DIR/nbd.socket" 35 35 } 36 36 trap "_cleanup; exit \$status" 0 1 2 3 15
+1 -1
tests/qemu-iotests/183
··· 31 31 _cleanup() 32 32 { 33 33 rm -f "${MIG_SOCKET}" 34 - rm -f "${TEST_IMG}.dest" 34 + _rm_test_img "${TEST_IMG}.dest" 35 35 _cleanup_test_img 36 36 _cleanup_qemu 37 37 }
+2 -2
tests/qemu-iotests/185
··· 28 28 29 29 _cleanup() 30 30 { 31 - rm -f "${TEST_IMG}.mid" 32 - rm -f "${TEST_IMG}.copy" 31 + _rm_test_img "${TEST_IMG}.mid" 32 + _rm_test_img "${TEST_IMG}.copy" 33 33 _cleanup_test_img 34 34 _cleanup_qemu 35 35 }
+3 -3
tests/qemu-iotests/187
··· 28 28 29 29 _cleanup() 30 30 { 31 - _cleanup_test_img 32 - rm -f "$TEST_IMG.2" 33 - rm -f "$TEST_IMG.3" 31 + _cleanup_test_img 32 + _rm_test_img "$TEST_IMG.2" 33 + _rm_test_img "$TEST_IMG.3" 34 34 } 35 35 trap "_cleanup; exit \$status" 0 1 2 3 15 36 36
+2 -2
tests/qemu-iotests/190
··· 29 29 _cleanup() 30 30 { 31 31 _cleanup_test_img 32 - rm -f "$TEST_IMG.converted" 32 + _rm_test_img "$TEST_IMG.converted" 33 33 } 34 34 trap "_cleanup; exit \$status" 0 1 2 3 15 35 35 ··· 45 45 echo "== Huge file ==" 46 46 echo 47 47 48 - IMGOPTS='cluster_size=2M' _make_test_img 2T 48 + _make_test_img -o 'cluster_size=2M' 2T 49 49 50 50 $QEMU_IMG measure -O raw -f qcow2 "$TEST_IMG" 51 51 $QEMU_IMG measure -O qcow2 -o cluster_size=64k -f qcow2 "$TEST_IMG"
+6 -5
tests/qemu-iotests/191
··· 28 28 29 29 _cleanup() 30 30 { 31 - rm -f "${TEST_IMG}.mid" 32 - rm -f "${TEST_IMG}.ovl2" 33 - rm -f "${TEST_IMG}.ovl3" 31 + _rm_test_img "${TEST_IMG}.mid" 32 + _rm_test_img "${TEST_IMG}.ovl2" 33 + _rm_test_img "${TEST_IMG}.ovl3" 34 34 _cleanup_test_img 35 35 _cleanup_qemu 36 36 } ··· 43 43 44 44 _supported_fmt qcow2 45 45 _supported_proto file 46 + # An external data file would change the query-named-block-nodes output 47 + _unsupported_imgopts data_file 46 48 47 49 size=64M 48 50 ··· 51 53 echo 52 54 53 55 TEST_IMG="${TEST_IMG}.base" _make_test_img $size 54 - IMGOPTS=$(_optstr_add "$IMGOPTS" "backing_fmt=$IMGFMT") \ 55 - TEST_IMG="${TEST_IMG}.mid" _make_test_img -b "${TEST_IMG}.base" 56 + TEST_IMG="${TEST_IMG}.mid" _make_test_img -o "backing_fmt=$IMGFMT" -b "${TEST_IMG}.base" 56 57 _make_test_img -b "${TEST_IMG}.mid" 57 58 TEST_IMG="${TEST_IMG}.ovl2" _make_test_img -b "${TEST_IMG}.mid" 58 59
+1 -1
tests/qemu-iotests/195
··· 29 29 _cleanup() 30 30 { 31 31 _cleanup_test_img 32 - rm -f "$TEST_IMG.mid" 32 + _rm_test_img "$TEST_IMG.mid" 33 33 } 34 34 trap "_cleanup; exit \$status" 0 1 2 3 15 35 35
+3 -3
tests/qemu-iotests/197
··· 43 43 _cleanup() 44 44 { 45 45 _cleanup_test_img 46 - rm -f "$TEST_WRAP" 46 + _rm_test_img "$TEST_WRAP" 47 47 rm -f "$BLKDBG_CONF" 48 48 } 49 49 trap "_cleanup; exit \$status" 0 1 2 3 15 ··· 66 66 fi 67 67 _make_test_img 4G 68 68 $QEMU_IO -c "write -P 55 3G 1k" "$TEST_IMG" | _filter_qemu_io 69 - IMGPROTO=file IMGFMT=qcow2 IMGOPTS= TEST_IMG_FILE="$TEST_WRAP" \ 70 - _make_test_img -F "$IMGFMT" -b "$TEST_IMG" | _filter_img_create 69 + IMGPROTO=file IMGFMT=qcow2 TEST_IMG_FILE="$TEST_WRAP" \ 70 + _make_test_img --no-opts -F "$IMGFMT" -b "$TEST_IMG" | _filter_img_create 71 71 $QEMU_IO -f qcow2 -c "write -z -u 1M 64k" "$TEST_WRAP" | _filter_qemu_io 72 72 73 73 # Ensure that a read of two clusters, but where one is already allocated,
+4 -2
tests/qemu-iotests/198
··· 92 92 echo "== checking image base ==" 93 93 $QEMU_IMG info --image-opts $IMGSPECBASE | _filter_img_info --format-specific \ 94 94 | sed -e "/^disk size:/ D" -e '/refcount bits:/ D' -e '/compat:/ D' \ 95 - -e '/lazy refcounts:/ D' -e '/corrupt:/ D' 95 + -e '/lazy refcounts:/ D' -e '/corrupt:/ D' -e '/^\s*data file/ D' \ 96 + | _filter_json_filename 96 97 97 98 echo 98 99 echo "== checking image layer ==" 99 100 $QEMU_IMG info --image-opts $IMGSPECLAYER | _filter_img_info --format-specific \ 100 101 | sed -e "/^disk size:/ D" -e '/refcount bits:/ D' -e '/compat:/ D' \ 101 - -e '/lazy refcounts:/ D' -e '/corrupt:/ D' 102 + -e '/lazy refcounts:/ D' -e '/corrupt:/ D' -e '/^\s*data file/ D' \ 103 + | _filter_json_filename 102 104 103 105 104 106 # success, all done
+2 -2
tests/qemu-iotests/198.out
··· 32 32 16 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 33 33 34 34 == checking image base == 35 - image: json:{"encrypt.key-secret": "sec0", "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT.base"}} 35 + image: json:{ /* filtered */ } 36 36 file format: IMGFMT 37 37 virtual size: 16 MiB (16777216 bytes) 38 38 Format specific information: ··· 74 74 master key iters: 1024 75 75 76 76 == checking image layer == 77 - image: json:{"encrypt.key-secret": "sec1", "driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}} 77 + image: json:{ /* filtered */ } 78 78 file format: IMGFMT 79 79 virtual size: 16 MiB (16777216 bytes) 80 80 backing file: TEST_DIR/t.IMGFMT.base
+4 -3
tests/qemu-iotests/200
··· 31 31 _cleanup() 32 32 { 33 33 _cleanup_qemu 34 - rm -f "${TEST_IMG}" "${BACKING_IMG}" 34 + _rm_test_img "${TEST_IMG}" 35 + _rm_test_img "${BACKING_IMG}" 35 36 } 36 37 trap "_cleanup; exit \$status" 0 1 2 3 15 37 38 ··· 46 47 BACKING_IMG="${TEST_DIR}/backing.img" 47 48 TEST_IMG="${TEST_DIR}/test.img" 48 49 49 - ${QEMU_IMG} create -f $IMGFMT "${BACKING_IMG}" 512M | _filter_img_create 50 - ${QEMU_IMG} create -f $IMGFMT -F $IMGFMT "${TEST_IMG}" -b "${BACKING_IMG}" 512M | _filter_img_create 50 + TEST_IMG="$BACKING_IMG" _make_test_img 512M 51 + _make_test_img -F $IMGFMT -b "$BACKING_IMG" 512M 51 52 52 53 ${QEMU_IO} -c "write -P 0xa5 512 300M" "${BACKING_IMG}" | _filter_qemu_io 53 54
+3 -3
tests/qemu-iotests/201
··· 43 43 _supported_proto generic 44 44 _supported_os Linux 45 45 46 - # Internal snapshots are (currently) impossible with refcount_bits=1 47 - # This was taken from test 080 48 - _unsupported_imgopts 'refcount_bits=1[^0-9]' 46 + # Internal snapshots are (currently) impossible with refcount_bits=1, 47 + # and generally impossible with external data files 48 + _unsupported_imgopts 'refcount_bits=1[^0-9]' data_file 49 49 50 50 size=64M 51 51 _make_test_img $size
+45 -1
tests/qemu-iotests/214
··· 39 39 40 40 # Repairing the corrupted image requires qemu-img check to store a 41 41 # refcount up to 3, which requires at least two refcount bits. 42 - _unsupported_imgopts 'refcount_bits=1[^0-9]' 42 + # External data files do not support compressed clusters. 43 + _unsupported_imgopts 'refcount_bits=1[^0-9]' data_file 43 44 44 45 45 46 echo ··· 88 89 _check_test_img -r all 89 90 $QEMU_IO -c "read -P 0x11 0 4M" "$TEST_IMG" 2>&1 | _filter_qemu_io | _filter_testdir 90 91 $QEMU_IO -c "read -P 0x22 4M 4M" "$TEST_IMG" 2>&1 | _filter_qemu_io | _filter_testdir 92 + 93 + echo 94 + echo "=== Write compressed data of multiple clusters ===" 95 + echo 96 + cluster_size=0x10000 97 + _make_test_img 2M -o cluster_size=$cluster_size 98 + 99 + echo "Write uncompressed data:" 100 + let data_size="8 * $cluster_size" 101 + $QEMU_IO -c "write -P 0xaa 0 $data_size" "$TEST_IMG" \ 102 + 2>&1 | _filter_qemu_io | _filter_testdir 103 + sizeA=$($QEMU_IMG info --output=json "$TEST_IMG" | 104 + sed -n '/"actual-size":/ s/[^0-9]//gp') 105 + 106 + _make_test_img 2M -o cluster_size=$cluster_size 107 + echo "Write compressed data:" 108 + let data_size="3 * $cluster_size + $cluster_size / 2" 109 + # Set compress on. That will align the written data 110 + # by the cluster size and will write them compressed. 111 + QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT \ 112 + $QEMU_IO -c "write -P 0xbb 0 $data_size" --image-opts \ 113 + "driver=compress,file.driver=$IMGFMT,file.file.driver=file,file.file.filename=$TEST_IMG" \ 114 + 2>&1 | _filter_qemu_io | _filter_testdir 115 + 116 + let offset="4 * $cluster_size + $cluster_size / 4" 117 + QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT \ 118 + $QEMU_IO -c "write -P 0xcc $offset $data_size" "json:{\ 119 + 'driver': 'compress', 120 + 'file': {'driver': '$IMGFMT', 121 + 'file': {'driver': 'file', 122 + 'filename': '$TEST_IMG'}}}" | \ 123 + _filter_qemu_io | _filter_testdir 124 + 125 + sizeB=$($QEMU_IMG info --output=json "$TEST_IMG" | 126 + sed -n '/"actual-size":/ s/[^0-9]//gp') 127 + 128 + if [ $sizeA -le $sizeB ] 129 + then 130 + echo "Compression ERROR" 131 + fi 132 + 133 + $QEMU_IMG check --output=json "$TEST_IMG" | 134 + sed -n 's/,$//; /"compressed-clusters":/ s/^ *//p' 91 135 92 136 # success, all done 93 137 echo '*** done'
+14
tests/qemu-iotests/214.out
··· 32 32 4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 33 33 read 4194304/4194304 bytes at offset 4194304 34 34 4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 35 + 36 + === Write compressed data of multiple clusters === 37 + 38 + Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2097152 39 + Write uncompressed data: 40 + wrote 524288/524288 bytes at offset 0 41 + 512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 42 + Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=2097152 43 + Write compressed data: 44 + wrote 229376/229376 bytes at offset 0 45 + 224 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 46 + wrote 229376/229376 bytes at offset 278528 47 + 224 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) 48 + "compressed-clusters": 8 35 49 *** done
+3 -3
tests/qemu-iotests/215
··· 40 40 _cleanup() 41 41 { 42 42 _cleanup_test_img 43 - rm -f "$TEST_WRAP" 43 + _rm_test_img "$TEST_WRAP" 44 44 rm -f "$BLKDBG_CONF" 45 45 } 46 46 trap "_cleanup; exit \$status" 0 1 2 3 15 ··· 63 63 fi 64 64 _make_test_img 4G 65 65 $QEMU_IO -c "write -P 55 3G 1k" "$TEST_IMG" | _filter_qemu_io 66 - IMGPROTO=file IMGFMT=qcow2 IMGOPTS= TEST_IMG_FILE="$TEST_WRAP" \ 67 - _make_test_img -F "$IMGFMT" -b "$TEST_IMG" | _filter_img_create 66 + IMGPROTO=file IMGFMT=qcow2 TEST_IMG_FILE="$TEST_WRAP" \ 67 + _make_test_img --no-opts -F "$IMGFMT" -b "$TEST_IMG" | _filter_img_create 68 68 $QEMU_IO -f qcow2 -c "write -z -u 1M 64k" "$TEST_WRAP" | _filter_qemu_io 69 69 70 70 # Ensure that a read of two clusters, but where one is already allocated,
+2 -1
tests/qemu-iotests/217
··· 40 40 41 41 # This test needs clusters with at least a refcount of 2 so that 42 42 # OFLAG_COPIED is not set. refcount_bits=1 is therefore unsupported. 43 - _unsupported_imgopts 'refcount_bits=1[^0-9]' 43 + # (As are external data files.) 44 + _unsupported_imgopts 'refcount_bits=1[^0-9]' data_file 44 45 45 46 echo 46 47 echo '=== Simulating an I/O error during snapshot deletion ==='
+4 -1
tests/qemu-iotests/220
··· 37 37 _supported_fmt qcow2 38 38 _supported_proto file 39 39 _supported_os Linux 40 + # To use a different refcount width but 16 bits we need compat=1.1, 41 + # and external data files do not support compressed clusters. 42 + _unsupported_imgopts 'compat=0.10' data_file 40 43 41 44 echo "== Creating huge file ==" 42 45 ··· 44 47 # of a HUGE (but very sparse) file. tmpfs works, ext4 does not. 45 48 _require_large_file 513T 46 49 47 - IMGOPTS='cluster_size=2M,refcount_bits=1' _make_test_img 513T 50 + _make_test_img -o 'cluster_size=2M,refcount_bits=1' 513T 48 51 49 52 echo "== Populating refcounts ==" 50 53 # We want an image with 256M refcounts * 2M clusters = 512T referenced.
+1 -1
tests/qemu-iotests/225
··· 29 29 _cleanup() 30 30 { 31 31 _cleanup_test_img 32 - rm -f "$TEST_IMG.not_base" 32 + _rm_test_img "$TEST_IMG.not_base" 33 33 } 34 34 trap "_cleanup; exit \$status" 0 1 2 3 15 35 35
+2 -1
tests/qemu-iotests/229
··· 31 31 { 32 32 _cleanup_qemu 33 33 _cleanup_test_img 34 - rm -f "$TEST_IMG" "$DEST_IMG" 34 + _rm_test_img "$TEST_IMG" 35 + _rm_test_img "$DEST_IMG" 35 36 } 36 37 trap "_cleanup; exit \$status" 0 1 2 3 15 37 38
+3 -1
tests/qemu-iotests/232
··· 29 29 _cleanup() 30 30 { 31 31 _cleanup_test_img 32 - rm -f $TEST_IMG.[01234] 32 + for img in "$TEST_IMG".[01234]; do 33 + _rm_test_img "$img" 34 + done 33 35 } 34 36 trap "_cleanup; exit \$status" 0 1 2 3 15 35 37
+1 -1
tests/qemu-iotests/235
··· 49 49 str(size)) 50 50 51 51 vm = QEMUMachine(iotests.qemu_prog) 52 - vm.add_args('-machine', 'accel=kvm:tcg') 52 + vm.add_args('-accel', 'kvm', '-accel', 'tcg') 53 53 if iotests.qemu_default_machine == 's390-ccw-virtio': 54 54 vm.add_args('-no-shutdown') 55 55 vm.add_args('-drive', 'id=src,file=' + disk)
+7 -3
tests/qemu-iotests/243
··· 29 29 _cleanup() 30 30 { 31 31 _cleanup_test_img 32 - rm -f $TEST_IMG.data 32 + _rm_test_img "$TEST_IMG.data" 33 33 } 34 34 trap "_cleanup; exit \$status" 0 1 2 3 15 35 35 ··· 40 40 _supported_fmt qcow2 41 41 _supported_proto file 42 42 _supported_os Linux 43 + # External data files do not work with compat=0.10, and because there 44 + # is an explicit case for external data files here, we cannot allow 45 + # the user to specify whether to use one 46 + _unsupported_imgopts 'compat=0.10' data_file 43 47 44 48 for mode in off metadata falloc full; do 45 49 ··· 47 51 echo "=== preallocation=$mode ===" 48 52 echo 49 53 50 - IMGOPTS="preallocation=$mode" _make_test_img 64M 54 + _make_test_img -o "preallocation=$mode" 64M 51 55 52 56 printf "File size: " 53 57 du -b $TEST_IMG | cut -f1 ··· 64 68 echo "=== External data file: preallocation=$mode ===" 65 69 echo 66 70 67 - IMGOPTS="data_file=$TEST_IMG.data,preallocation=$mode" _make_test_img 64M 71 + _make_test_img -o "data_file=$TEST_IMG.data,preallocation=$mode" 64M 68 72 69 73 echo -n "qcow2 file size: " 70 74 du -b $TEST_IMG | cut -f1
+9 -6
tests/qemu-iotests/244
··· 29 29 _cleanup() 30 30 { 31 31 _cleanup_test_img 32 - rm -f $TEST_IMG.data 33 - rm -f $TEST_IMG.src 32 + _rm_test_img "$TEST_IMG.data" 33 + _rm_test_img "$TEST_IMG.src" 34 34 } 35 35 trap "_cleanup; exit \$status" 0 1 2 3 15 36 36 ··· 41 41 _supported_fmt qcow2 42 42 _supported_proto file 43 43 _supported_os Linux 44 + # External data files do not work with compat=0.10, and because we use 45 + # our own external data file, we cannot let the user specify one 46 + _unsupported_imgopts 'compat=0.10' data_file 44 47 45 48 echo 46 49 echo "=== Create and open image with external data file ===" 47 50 echo 48 51 49 52 echo "With data file name in the image:" 50 - IMGOPTS="data_file=$TEST_IMG.data" _make_test_img 64M 53 + _make_test_img -o "data_file=$TEST_IMG.data" 64M 51 54 _check_test_img 52 55 53 56 $QEMU_IO -c "open $TEST_IMG" -c "read -P 0 0 64k" 2>&1 | _filter_qemu_io | _filter_testdir ··· 104 107 echo "=== Standalone image with external data file (efficient) ===" 105 108 echo 106 109 107 - IMGOPTS="data_file=$TEST_IMG.data" _make_test_img 64M 110 + _make_test_img -o "data_file=$TEST_IMG.data" 64M 108 111 109 112 echo -n "qcow2 file size before I/O: " 110 113 du -b $TEST_IMG | cut -f1 ··· 154 157 echo "=== Standalone image with external data file (valid raw) ===" 155 158 echo 156 159 157 - IMGOPTS="data_file=$TEST_IMG.data,data_file_raw=on" _make_test_img 64M 160 + _make_test_img -o "data_file=$TEST_IMG.data,data_file_raw=on" 64M 158 161 159 162 echo -n "qcow2 file size before I/O: " 160 163 du -b $TEST_IMG | cut -f1 ··· 187 190 echo "=== bdrv_co_block_status test for file and offset=0 ===" 188 191 echo 189 192 190 - IMGOPTS="data_file=$TEST_IMG.data" _make_test_img 64M 193 + _make_test_img -o "data_file=$TEST_IMG.data" 64M 191 194 192 195 $QEMU_IO -c 'write -P 0x11 0 1M' -f $IMGFMT "$TEST_IMG" | _filter_qemu_io 193 196 $QEMU_IO -c 'read -P 0x11 0 1M' -f $IMGFMT "$TEST_IMG" | _filter_qemu_io
+3 -1
tests/qemu-iotests/247
··· 29 29 _cleanup() 30 30 { 31 31 _cleanup_test_img 32 - rm -f $TEST_IMG.[01234] 32 + for img in "$TEST_IMG".[01234]; do 33 + _rm_test_img "$img" 34 + done 33 35 } 34 36 trap "_cleanup; exit \$status" 0 1 2 3 15 35 37
+2 -2
tests/qemu-iotests/249
··· 30 30 _cleanup() 31 31 { 32 32 _cleanup_test_img 33 - rm -f "$TEST_IMG.base" 34 - rm -f "$TEST_IMG.int" 33 + _rm_test_img "$TEST_IMG.base" 34 + _rm_test_img "$TEST_IMG.int" 35 35 } 36 36 trap "_cleanup; exit \$status" 0 1 2 3 15 37 37
+3 -2
tests/qemu-iotests/250
··· 39 39 _supported_fmt qcow2 40 40 _supported_proto file 41 41 _supported_os Linux 42 + # This test does not make much sense with external data files 43 + _unsupported_imgopts data_file 42 44 43 45 # This test checks that qcow2_process_discards does not truncate a discard 44 46 # request > 2G. ··· 55 57 } 56 58 57 59 size=2100M 58 - IMGOPTS="cluster_size=1M,preallocation=metadata" 59 60 60 - _make_test_img $size 61 + _make_test_img -o "cluster_size=1M,preallocation=metadata" $size 61 62 $QEMU_IO -c 'discard 0 10M' -c 'discard 2090M 10M' \ 62 63 -c 'write 2090M 10M' -c 'write 0 10M' "$TEST_IMG" | _filter_qemu_io 63 64
+1 -1
tests/qemu-iotests/252
··· 29 29 _cleanup() 30 30 { 31 31 _cleanup_test_img 32 - rm -f "$TEST_IMG.base_new" 32 + _rm_test_img "$TEST_IMG.base_new" 33 33 } 34 34 trap "_cleanup; exit \$status" 0 1 2 3 15 35 35
+3 -2
tests/qemu-iotests/261
··· 40 40 . ./common.rc 41 41 . ./common.filter 42 42 43 - # This tests qocw2-specific low-level functionality 43 + # This tests qcow2-specific low-level functionality 44 44 _supported_fmt qcow2 45 45 _supported_proto file 46 46 _supported_os Linux 47 47 # (1) We create a v2 image that supports nothing but refcount_bits=16 48 48 # (2) We do some refcount management on our own which expects 49 49 # refcount_bits=16 50 - _unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' 50 + # As for data files, they do not support snapshots at all. 51 + _unsupported_imgopts 'refcount_bits=\([^1]\|.\([^6]\|$\)\)' data_file 51 52 52 53 # Parameters: 53 54 # $1: image filename
+1 -1
tests/qemu-iotests/265
··· 41 41 echo '--- Writing to the image ---' 42 42 43 43 # Reduce cluster size so we get more and quicker I/O 44 - IMGOPTS='cluster_size=4096' _make_test_img 1M 44 + _make_test_img -o 'cluster_size=4096' 1M 45 45 (for ((kb = 1024 - 4; kb >= 0; kb -= 4)); do \ 46 46 echo "aio_write -P 42 $((kb + 1))k 2k"; \ 47 47 done) \
+11 -6
tests/qemu-iotests/267
··· 42 42 _supported_os Linux 43 43 _require_drivers copy-on-read 44 44 45 - # Internal snapshots are (currently) impossible with refcount_bits=1 46 - _unsupported_imgopts 'refcount_bits=1[^0-9]' 45 + # Internal snapshots are (currently) impossible with refcount_bits=1, 46 + # and generally impossible with external data files 47 + _unsupported_imgopts 'refcount_bits=1[^0-9]' data_file 47 48 48 49 do_run_qemu() 49 50 { ··· 69 70 70 71 run_test() 71 72 { 72 - _make_test_img $size 73 + if [ -n "$BACKING_FILE" ]; then 74 + _make_test_img -b "$BACKING_FILE" $size 75 + else 76 + _make_test_img $size 77 + fi 73 78 printf "savevm snap0\ninfo snapshots\nloadvm snap0\n" | run_qemu "$@" | _filter_date 74 79 } 75 80 ··· 120 125 121 126 TEST_IMG="$TEST_IMG.base" _make_test_img $size 122 127 123 - IMGOPTS="backing_file=$TEST_IMG.base" \ 128 + BACKING_FILE="$TEST_IMG.base" \ 124 129 run_test -blockdev driver=file,filename="$TEST_IMG.base",node-name=backing-file \ 125 130 -blockdev driver=file,filename="$TEST_IMG",node-name=file \ 126 131 -blockdev driver=$IMGFMT,file=file,backing=backing-file,node-name=fmt 127 132 128 - IMGOPTS="backing_file=$TEST_IMG.base" \ 133 + BACKING_FILE="$TEST_IMG.base" \ 129 134 run_test -blockdev driver=file,filename="$TEST_IMG.base",node-name=backing-file \ 130 135 -blockdev driver=$IMGFMT,file=backing-file,node-name=backing-fmt \ 131 136 -blockdev driver=file,filename="$TEST_IMG",node-name=file \ ··· 142 147 echo "=== -blockdev with NBD server on the backing file ===" 143 148 echo 144 149 145 - IMGOPTS="backing_file=$TEST_IMG.base" _make_test_img $size 150 + _make_test_img -b "$TEST_IMG.base" $size 146 151 cat <<EOF | 147 152 nbd_server_start unix:$SOCK_DIR/nbd 148 153 nbd_server_add -w backing-fmt
+3
tests/qemu-iotests/273
··· 37 37 _supported_fmt qcow2 38 38 _supported_proto file 39 39 _supported_os Linux 40 + # External data files would add nodes to the block graph, so it would 41 + # not match the reference output 42 + _unsupported_imgopts data_file 40 43 41 44 do_run_qemu() 42 45 {
+3 -3
tests/qemu-iotests/check
··· 587 587 588 588 case "$QEMU_PROG" in 589 589 *qemu-system-arm|*qemu-system-aarch64) 590 - export QEMU_OPTIONS="-nodefaults -display none -machine virt,accel=qtest" 590 + export QEMU_OPTIONS="-nodefaults -display none -machine virt -accel qtest" 591 591 ;; 592 592 *qemu-system-tricore) 593 - export QEMU_OPTIONS="-nodefaults -display none -machine tricore_testboard,accel=qtest" 593 + export QEMU_OPTIONS="-nodefaults -display none -machine tricore_testboard -accel qtest" 594 594 ;; 595 595 *) 596 - export QEMU_OPTIONS="-nodefaults -display none -machine accel=qtest" 596 + export QEMU_OPTIONS="-nodefaults -display none -accel qtest" 597 597 ;; 598 598 esac 599 599
+45 -2
tests/qemu-iotests/common.filter
··· 122 122 # replace driver-specific options in the "Formatting..." line 123 123 _filter_img_create() 124 124 { 125 - $SED -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \ 125 + data_file_filter=() 126 + if data_file=$(_get_data_file "$TEST_IMG"); then 127 + data_file_filter=(-e "s# data_file=$data_file##") 128 + fi 129 + 130 + $SED "${data_file_filter[@]}" \ 131 + -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \ 126 132 -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \ 127 133 -e "s#$TEST_DIR#TEST_DIR#g" \ 128 134 -e "s#$SOCK_DIR#SOCK_DIR#g" \ ··· 209 215 # human and json output 210 216 _filter_qemu_img_map() 211 217 { 218 + # Assuming the data_file value in $IMGOPTS contains a '$TEST_IMG', 219 + # create a filter that replaces the data file name by $TEST_IMG. 220 + # Example: 221 + # In $IMGOPTS: 'data_file=$TEST_IMG.data_file' 222 + # Then data_file_pattern == '\(.*\).data_file' 223 + # And data_file_filter == -e 's#\(.*\).data_file#\1# 224 + data_file_filter=() 225 + if data_file_pattern=$(_get_data_file '\\(.*\\)'); then 226 + data_file_filter=(-e "s#$data_file_pattern#\\1#") 227 + fi 228 + 212 229 $SED -e 's/\([0-9a-fx]* *[0-9a-fx]* *\)[0-9a-fx]* */\1/g' \ 213 230 -e 's/"offset": [0-9]\+/"offset": OFFSET/g' \ 214 - -e 's/Mapped to *//' | _filter_testdir | _filter_imgfmt 231 + -e 's/Mapped to *//' \ 232 + "${data_file_filter[@]}" \ 233 + | _filter_testdir | _filter_imgfmt 215 234 } 216 235 217 236 _filter_nbd() ··· 230 249 _filter_qmp_empty_return() 231 250 { 232 251 grep -v '{"return": {}}' 252 + } 253 + 254 + _filter_json_filename() 255 + { 256 + $PYTHON -c 'import sys 257 + result, *fnames = sys.stdin.read().split("json:{") 258 + depth = 0 259 + for fname in fnames: 260 + depth += 1 # For the opening brace in the split separator 261 + for chr_i, chr in enumerate(fname): 262 + if chr == "{": 263 + depth += 1 264 + elif chr == "}": 265 + depth -= 1 266 + if depth == 0: 267 + break 268 + 269 + # json:{} filenames may be nested; filter out everything from 270 + # inside the outermost one 271 + if depth == 0: 272 + chr_i += 1 # First character past the filename 273 + result += "json:{ /* filtered */ }" + fname[chr_i:] 274 + 275 + sys.stdout.write(result)' 233 276 } 234 277 235 278 # make sure this script returns success
+54 -9
tests/qemu-iotests/common.rc
··· 298 298 fi 299 299 } 300 300 301 + # Gets the data_file value from IMGOPTS and replaces the '$TEST_IMG' 302 + # pattern by '$1' 303 + # Caution: The replacement is done with sed, so $1 must be escaped 304 + # properly. (The delimiter is '#'.) 305 + _get_data_file() 306 + { 307 + if ! echo "$IMGOPTS" | grep -q 'data_file='; then 308 + return 1 309 + fi 310 + 311 + echo "$IMGOPTS" | sed -e 's/.*data_file=\([^,]*\).*/\1/' \ 312 + | sed -e "s#\\\$TEST_IMG#$1#" 313 + } 314 + 301 315 _make_test_img() 302 316 { 303 317 # extra qemu-img options can be added by tests 304 318 # at least one argument (the image size) needs to be added 305 319 local extra_img_options="" 306 - local image_size=$* 307 320 local optstr="" 308 321 local img_name="" 309 322 local use_backing=0 310 323 local backing_file="" 311 324 local object_options="" 325 + local opts_param=false 326 + local misc_params=() 312 327 313 328 if [ -n "$TEST_IMG_FILE" ]; then 314 329 img_name=$TEST_IMG_FILE ··· 317 332 fi 318 333 319 334 if [ -n "$IMGOPTS" ]; then 320 - optstr=$(_optstr_add "$optstr" "$IMGOPTS") 335 + imgopts_expanded=$(echo "$IMGOPTS" | sed -e "s#\\\$TEST_IMG#$img_name#") 336 + optstr=$(_optstr_add "$optstr" "$imgopts_expanded") 321 337 fi 322 338 if [ -n "$IMGKEYSECRET" ]; then 323 339 object_options="--object secret,id=keysec0,data=$IMGKEYSECRET" 324 340 optstr=$(_optstr_add "$optstr" "key-secret=keysec0") 325 341 fi 326 342 327 - if [ "$1" = "-b" ]; then 328 - use_backing=1 329 - backing_file=$2 330 - image_size=$3 331 - fi 343 + for param; do 344 + if [ "$use_backing" = "1" -a -z "$backing_file" ]; then 345 + backing_file=$param 346 + continue 347 + elif $opts_param; then 348 + optstr=$(_optstr_add "$optstr" "$param") 349 + opts_param=false 350 + continue 351 + fi 352 + 353 + case "$param" in 354 + -b) 355 + use_backing=1 356 + ;; 357 + 358 + -o) 359 + opts_param=true 360 + ;; 361 + 362 + --no-opts) 363 + optstr="" 364 + ;; 365 + 366 + *) 367 + misc_params=("${misc_params[@]}" "$param") 368 + ;; 369 + esac 370 + done 371 + 332 372 if [ \( "$IMGFMT" = "qcow2" -o "$IMGFMT" = "qed" \) -a -n "$CLUSTER_SIZE" ]; then 333 373 optstr=$(_optstr_add "$optstr" "cluster_size=$CLUSTER_SIZE") 334 374 fi ··· 344 384 # XXX(hch): have global image options? 345 385 ( 346 386 if [ $use_backing = 1 ]; then 347 - $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options -b "$backing_file" "$img_name" $image_size 2>&1 387 + $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options -b "$backing_file" "$img_name" "${misc_params[@]}" 2>&1 348 388 else 349 - $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options "$img_name" $image_size 2>&1 389 + $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options "$img_name" "${misc_params[@]}" 2>&1 350 390 fi 351 391 ) | _filter_img_create 352 392 ··· 375 415 # Remove all the extents for vmdk 376 416 "$QEMU_IMG" info "$img" 2>/dev/null | grep 'filename:' | cut -f 2 -d: \ 377 417 | xargs -I {} rm -f "{}" 418 + elif [ "$IMGFMT" = "qcow2" ]; then 419 + # Remove external data file 420 + if data_file=$(_get_data_file "$img"); then 421 + rm -f "$data_file" 422 + fi 378 423 fi 379 424 rm -f "$img" 380 425 }
+12 -6
tests/qemu-iotests/iotests.py
··· 811 811 self.assert_no_active_block_jobs() 812 812 return result 813 813 814 - def wait_until_completed(self, drive='drive0', check_offset=True, wait=60.0): 814 + def wait_until_completed(self, drive='drive0', check_offset=True, wait=60.0, 815 + error=None): 815 816 '''Wait for a block job to finish, returning the event''' 816 817 while True: 817 818 for event in self.vm.get_qmp_events(wait=wait): 818 819 if event['event'] == 'BLOCK_JOB_COMPLETED': 819 820 self.assert_qmp(event, 'data/device', drive) 820 - self.assert_qmp_absent(event, 'data/error') 821 - if check_offset: 822 - self.assert_qmp(event, 'data/offset', event['data']['len']) 821 + if error is None: 822 + self.assert_qmp_absent(event, 'data/error') 823 + if check_offset: 824 + self.assert_qmp(event, 'data/offset', 825 + event['data']['len']) 826 + else: 827 + self.assert_qmp(event, 'data/error', error) 823 828 self.assert_no_active_block_jobs() 824 829 return event 825 830 elif event['event'] == 'JOB_STATUS_CHANGE': ··· 837 842 self.assert_qmp(event, 'data/type', 'mirror') 838 843 self.assert_qmp(event, 'data/offset', event['data']['len']) 839 844 840 - def complete_and_wait(self, drive='drive0', wait_ready=True): 845 + def complete_and_wait(self, drive='drive0', wait_ready=True, 846 + completion_error=None): 841 847 '''Complete a block job and wait for it to finish''' 842 848 if wait_ready: 843 849 self.wait_ready(drive=drive) ··· 845 851 result = self.vm.qmp('block-job-complete', device=drive) 846 852 self.assert_qmp(result, 'return', {}) 847 853 848 - event = self.wait_until_completed(drive=drive) 854 + event = self.wait_until_completed(drive=drive, error=completion_error) 849 855 self.assert_qmp(event, 'data/type', 'mirror') 850 856 851 857 def pause_wait(self, job_id='job0'):
+19 -4
tests/qemu-iotests/qcow2.py
··· 42 42 [ uint64_t, '%#x', 'snapshot_offset' ], 43 43 44 44 # Version 3 header fields 45 - [ uint64_t, '%#x', 'incompatible_features' ], 46 - [ uint64_t, '%#x', 'compatible_features' ], 47 - [ uint64_t, '%#x', 'autoclear_features' ], 45 + [ uint64_t, 'mask', 'incompatible_features' ], 46 + [ uint64_t, 'mask', 'compatible_features' ], 47 + [ uint64_t, 'mask', 'autoclear_features' ], 48 48 [ uint32_t, '%d', 'refcount_order' ], 49 49 [ uint32_t, '%d', 'header_length' ], 50 50 ]; ··· 130 130 131 131 def dump(self): 132 132 for f in QcowHeader.fields: 133 - print("%-25s" % f[2], f[1] % self.__dict__[f[2]]) 133 + value = self.__dict__[f[2]] 134 + if f[1] == 'mask': 135 + bits = [] 136 + for bit in range(64): 137 + if value & (1 << bit): 138 + bits.append(bit) 139 + value_str = str(bits) 140 + else: 141 + value_str = f[1] % value 142 + 143 + print("%-25s" % f[2], value_str) 134 144 print("") 135 145 136 146 def dump_extensions(self): ··· 152 162 def cmd_dump_header(fd): 153 163 h = QcowHeader(fd) 154 164 h.dump() 165 + h.dump_extensions() 166 + 167 + def cmd_dump_header_exts(fd): 168 + h = QcowHeader(fd) 155 169 h.dump_extensions() 156 170 157 171 def cmd_set_header(fd, name, value): ··· 230 244 231 245 cmds = [ 232 246 [ 'dump-header', cmd_dump_header, 0, 'Dump image header and header extensions' ], 247 + [ 'dump-header-exts', cmd_dump_header_exts, 0, 'Dump image header extensions' ], 233 248 [ 'set-header', cmd_set_header, 2, 'Set a field in the header'], 234 249 [ 'add-header-ext', cmd_add_header_ext, 2, 'Add a header extension' ], 235 250 [ 'add-header-ext-stdio', cmd_add_header_ext_stdio, 1, 'Add a header extension, data from stdin' ],