Loading block/qcow2.c +32 −2 Original line number Diff line number Diff line Loading @@ -1453,8 +1453,31 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, goto fail; } /* TODO Open external data file */ /* Open external data file */ s->data_file = bdrv_open_child(NULL, options, "data-file", bs, &child_file, true, &local_err); if (local_err) { error_propagate(errp, local_err); ret = -EINVAL; goto fail; } if (s->incompatible_features & QCOW2_INCOMPAT_DATA_FILE) { if (!s->data_file) { error_setg(errp, "'data-file' is required for this image"); ret = -EINVAL; goto fail; } } else { if (s->data_file) { error_setg(errp, "'data-file' can only be set for images with an " "external data file"); ret = -EINVAL; goto fail; } else { s->data_file = bs->file; } } /* qcow2_read_extension may have set up the crypto context * if the crypt method needs a header region, some methods Loading Loading @@ -1627,6 +1650,9 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, return ret; fail: if (has_data_file(bs)) { bdrv_unref_child(bs, s->data_file); } g_free(s->unknown_header_fields); cleanup_unknown_header_ext(bs); qcow2_free_snapshots(bs); Loading Loading @@ -2246,6 +2272,10 @@ static void qcow2_close(BlockDriverState *bs) g_free(s->image_backing_file); g_free(s->image_backing_format); if (has_data_file(bs)) { bdrv_unref_child(bs, s->data_file); } qcow2_refcount_close(bs); qcow2_free_snapshots(bs); } Loading block/qcow2.h +3 −1 Original line number Diff line number Diff line Loading @@ -91,6 +91,7 @@ #define DEFAULT_CLUSTER_SIZE 65536 #define QCOW2_OPT_DATA_FILE "data-file" #define QCOW2_OPT_LAZY_REFCOUNTS "lazy-refcounts" #define QCOW2_OPT_DISCARD_REQUEST "pass-discard-request" #define QCOW2_OPT_DISCARD_SNAPSHOT "pass-discard-snapshot" Loading Loading @@ -205,7 +206,8 @@ enum { QCOW2_INCOMPAT_DATA_FILE = 1 << QCOW2_INCOMPAT_DATA_FILE_BITNR, QCOW2_INCOMPAT_MASK = QCOW2_INCOMPAT_DIRTY | QCOW2_INCOMPAT_CORRUPT, | QCOW2_INCOMPAT_CORRUPT | QCOW2_INCOMPAT_DATA_FILE, }; /* Compatible feature bits */ Loading qapi/block-core.json +6 −1 Original line number Diff line number Diff line Loading @@ -3080,6 +3080,10 @@ # encrypted images, except when doing a metadata-only # probe of the image. (since 2.10) # # @data-file: reference to or definition of the external data file. # This may only be specified for images that require an # external data file. (since 4.0) # # Since: 2.9 ## { 'struct': 'BlockdevOptionsQcow2', Loading @@ -3094,7 +3098,8 @@ '*l2-cache-entry-size': 'int', '*refcount-cache-size': 'int', '*cache-clean-interval': 'int', '*encrypt': 'BlockdevQcow2Encryption' } } '*encrypt': 'BlockdevQcow2Encryption', '*data-file': 'BlockdevRef' } } ## # @SshHostKeyCheckMode: Loading Loading
block/qcow2.c +32 −2 Original line number Diff line number Diff line Loading @@ -1453,8 +1453,31 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, goto fail; } /* TODO Open external data file */ /* Open external data file */ s->data_file = bdrv_open_child(NULL, options, "data-file", bs, &child_file, true, &local_err); if (local_err) { error_propagate(errp, local_err); ret = -EINVAL; goto fail; } if (s->incompatible_features & QCOW2_INCOMPAT_DATA_FILE) { if (!s->data_file) { error_setg(errp, "'data-file' is required for this image"); ret = -EINVAL; goto fail; } } else { if (s->data_file) { error_setg(errp, "'data-file' can only be set for images with an " "external data file"); ret = -EINVAL; goto fail; } else { s->data_file = bs->file; } } /* qcow2_read_extension may have set up the crypto context * if the crypt method needs a header region, some methods Loading Loading @@ -1627,6 +1650,9 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, return ret; fail: if (has_data_file(bs)) { bdrv_unref_child(bs, s->data_file); } g_free(s->unknown_header_fields); cleanup_unknown_header_ext(bs); qcow2_free_snapshots(bs); Loading Loading @@ -2246,6 +2272,10 @@ static void qcow2_close(BlockDriverState *bs) g_free(s->image_backing_file); g_free(s->image_backing_format); if (has_data_file(bs)) { bdrv_unref_child(bs, s->data_file); } qcow2_refcount_close(bs); qcow2_free_snapshots(bs); } Loading
block/qcow2.h +3 −1 Original line number Diff line number Diff line Loading @@ -91,6 +91,7 @@ #define DEFAULT_CLUSTER_SIZE 65536 #define QCOW2_OPT_DATA_FILE "data-file" #define QCOW2_OPT_LAZY_REFCOUNTS "lazy-refcounts" #define QCOW2_OPT_DISCARD_REQUEST "pass-discard-request" #define QCOW2_OPT_DISCARD_SNAPSHOT "pass-discard-snapshot" Loading Loading @@ -205,7 +206,8 @@ enum { QCOW2_INCOMPAT_DATA_FILE = 1 << QCOW2_INCOMPAT_DATA_FILE_BITNR, QCOW2_INCOMPAT_MASK = QCOW2_INCOMPAT_DIRTY | QCOW2_INCOMPAT_CORRUPT, | QCOW2_INCOMPAT_CORRUPT | QCOW2_INCOMPAT_DATA_FILE, }; /* Compatible feature bits */ Loading
qapi/block-core.json +6 −1 Original line number Diff line number Diff line Loading @@ -3080,6 +3080,10 @@ # encrypted images, except when doing a metadata-only # probe of the image. (since 2.10) # # @data-file: reference to or definition of the external data file. # This may only be specified for images that require an # external data file. (since 4.0) # # Since: 2.9 ## { 'struct': 'BlockdevOptionsQcow2', Loading @@ -3094,7 +3098,8 @@ '*l2-cache-entry-size': 'int', '*refcount-cache-size': 'int', '*cache-clean-interval': 'int', '*encrypt': 'BlockdevQcow2Encryption' } } '*encrypt': 'BlockdevQcow2Encryption', '*data-file': 'BlockdevRef' } } ## # @SshHostKeyCheckMode: Loading