mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Block layer patches: - file-posix: Mitigate file fragmentation with extent size hints - Tighten qemu-img rules on missing backing format - qemu-img map: Don't limit block status request size - Fix crash with virtio-scsi and iothreads # gpg: Signature made Tue 14 Jul 2020 14:24:19 BST # gpg: using RSA key DC3DEB159A9AF95D3D7456FE7F09B272C88F2FD6 # gpg: issuer "kwolf@redhat.com" # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" [full] # Primary key fingerprint: DC3D EB15 9A9A F95D 3D74 56FE 7F09 B272 C88F 2FD6 * remotes/kevin/tags/for-upstream: block: Avoid stale pointer dereference in blk_get_aio_context() qemu-img: Deprecate use of -b without -F block: Add support to warn on backing file change without format iotests: Specify explicit backing format where sensible qcow2: Deprecate use of qemu-img amend to change backing file block: Error if backing file fails during creation without -u qcow: Tolerate backing_fmt= vmdk: Add trivial backing_fmt support sheepdog: Add trivial backing_fmt support block: Finish deprecation of 'qemu-img convert -n -o' qemu-img: Flush stdout before before potential stderr messages file-posix: Mitigate file fragmentation with extent size hints iotests/059: Filter out disk size with more standard filter qemu-img map: Don't limit block status request size iotests: Simplify _filter_img_create() a bit Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
@@ -1206,7 +1206,8 @@ static int bdrv_backing_update_filename(BdrvChild *c, BlockDriverState *base,
|
||||
}
|
||||
|
||||
ret = bdrv_change_backing_file(parent, filename,
|
||||
base->drv ? base->drv->format_name : "");
|
||||
base->drv ? base->drv->format_name : "",
|
||||
false);
|
||||
if (ret < 0) {
|
||||
error_setg_errno(errp, -ret, "Could not update backing file link");
|
||||
}
|
||||
@@ -4680,8 +4681,8 @@ int bdrv_check(BlockDriverState *bs,
|
||||
* image file header
|
||||
* -ENOTSUP - format driver doesn't support changing the backing file
|
||||
*/
|
||||
int bdrv_change_backing_file(BlockDriverState *bs,
|
||||
const char *backing_file, const char *backing_fmt)
|
||||
int bdrv_change_backing_file(BlockDriverState *bs, const char *backing_file,
|
||||
const char *backing_fmt, bool warn)
|
||||
{
|
||||
BlockDriver *drv = bs->drv;
|
||||
int ret;
|
||||
@@ -4695,6 +4696,12 @@ int bdrv_change_backing_file(BlockDriverState *bs,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (warn && backing_file && !backing_fmt) {
|
||||
warn_report("Deprecated use of backing file without explicit "
|
||||
"backing format, use of this image requires "
|
||||
"potentially unsafe format probing");
|
||||
}
|
||||
|
||||
if (drv->bdrv_change_backing_file != NULL) {
|
||||
ret = drv->bdrv_change_backing_file(bs, backing_file, backing_fmt);
|
||||
} else {
|
||||
@@ -6128,18 +6135,30 @@ void bdrv_img_create(const char *filename, const char *fmt,
|
||||
bs = bdrv_open(full_backing, NULL, backing_options, back_flags,
|
||||
&local_err);
|
||||
g_free(full_backing);
|
||||
if (!bs && size != -1) {
|
||||
/* Couldn't open BS, but we have a size, so it's nonfatal */
|
||||
warn_reportf_err(local_err,
|
||||
"Could not verify backing image. "
|
||||
"This may become an error in future versions.\n");
|
||||
local_err = NULL;
|
||||
} else if (!bs) {
|
||||
/* Couldn't open bs, do not have size */
|
||||
error_append_hint(&local_err,
|
||||
"Could not open backing image to determine size.\n");
|
||||
if (!bs) {
|
||||
error_append_hint(&local_err, "Could not open backing image.\n");
|
||||
goto out;
|
||||
} else {
|
||||
if (!backing_fmt) {
|
||||
warn_report("Deprecated use of backing file without explicit "
|
||||
"backing format (detected format of %s)",
|
||||
bs->drv->format_name);
|
||||
if (bs->drv != &bdrv_raw) {
|
||||
/*
|
||||
* A probe of raw deserves the most attention:
|
||||
* leaving the backing format out of the image
|
||||
* will ensure bs->probed is set (ensuring we
|
||||
* don't accidentally commit into the backing
|
||||
* file), and allow more spots to warn the users
|
||||
* to fix their toolchain when opening this image
|
||||
* later. For other images, we can safely record
|
||||
* the format that we probed.
|
||||
*/
|
||||
backing_fmt = bs->drv->format_name;
|
||||
qemu_opt_set(opts, BLOCK_OPT_BACKING_FMT, backing_fmt,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
if (size == -1) {
|
||||
/* Opened BS, have no size */
|
||||
size = bdrv_getlength(bs);
|
||||
@@ -6153,7 +6172,12 @@ void bdrv_img_create(const char *filename, const char *fmt,
|
||||
}
|
||||
bdrv_unref(bs);
|
||||
}
|
||||
} /* (backing_file && !(flags & BDRV_O_NO_BACKING)) */
|
||||
/* (backing_file && !(flags & BDRV_O_NO_BACKING)) */
|
||||
} else if (backing_file && !backing_fmt) {
|
||||
warn_report("Deprecated use of unopened backing file without "
|
||||
"explicit backing format, use of this image requires "
|
||||
"potentially unsafe format probing");
|
||||
}
|
||||
|
||||
if (size == -1) {
|
||||
error_setg(errp, "Image creation needs a size parameter");
|
||||
@@ -6164,6 +6188,7 @@ void bdrv_img_create(const char *filename, const char *fmt,
|
||||
printf("Formatting '%s', fmt=%s ", filename, fmt);
|
||||
qemu_opts_print(opts, " ");
|
||||
puts("");
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
ret = bdrv_create(drv, filename, opts, &local_err);
|
||||
|
||||
@@ -808,6 +808,7 @@ void blk_remove_bs(BlockBackend *blk)
|
||||
{
|
||||
ThrottleGroupMember *tgm = &blk->public.throttle_group_member;
|
||||
BlockDriverState *bs;
|
||||
BdrvChild *root;
|
||||
|
||||
notifier_list_notify(&blk->remove_bs_notifiers, blk);
|
||||
if (tgm->throttle_state) {
|
||||
@@ -825,8 +826,9 @@ void blk_remove_bs(BlockBackend *blk)
|
||||
* to avoid that and a potential QEMU crash.
|
||||
*/
|
||||
blk_drain(blk);
|
||||
bdrv_root_unref_child(blk->root);
|
||||
root = blk->root;
|
||||
blk->root = NULL;
|
||||
bdrv_root_unref_child(root);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "block/block_int.h"
|
||||
#include "qemu/module.h"
|
||||
#include "qemu/option.h"
|
||||
#include "qemu/units.h"
|
||||
#include "trace.h"
|
||||
#include "block/thread-pool.h"
|
||||
#include "qemu/iov.h"
|
||||
@@ -2318,6 +2319,14 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
||||
if (!file_opts->has_preallocation) {
|
||||
file_opts->preallocation = PREALLOC_MODE_OFF;
|
||||
}
|
||||
if (!file_opts->has_extent_size_hint) {
|
||||
file_opts->extent_size_hint = 1 * MiB;
|
||||
}
|
||||
if (file_opts->extent_size_hint > UINT32_MAX) {
|
||||
result = -EINVAL;
|
||||
error_setg(errp, "Extent size hint is too large");
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Create file */
|
||||
fd = qemu_open(file_opts->filename, O_RDWR | O_CREAT | O_BINARY, 0644);
|
||||
@@ -2375,6 +2384,27 @@ raw_co_create(BlockdevCreateOptions *options, Error **errp)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef FS_IOC_FSSETXATTR
|
||||
/*
|
||||
* Try to set the extent size hint. Failure is not fatal, and a warning is
|
||||
* only printed if the option was explicitly specified.
|
||||
*/
|
||||
{
|
||||
struct fsxattr attr;
|
||||
result = ioctl(fd, FS_IOC_FSGETXATTR, &attr);
|
||||
if (result == 0) {
|
||||
attr.fsx_xflags |= FS_XFLAG_EXTSIZE;
|
||||
attr.fsx_extsize = file_opts->extent_size_hint;
|
||||
result = ioctl(fd, FS_IOC_FSSETXATTR, &attr);
|
||||
}
|
||||
if (result < 0 && file_opts->has_extent_size_hint &&
|
||||
file_opts->extent_size_hint)
|
||||
{
|
||||
warn_report("Failed to set extent size hint: %s",
|
||||
strerror(errno));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Resize and potentially preallocate the file to the desired
|
||||
* final size */
|
||||
@@ -2410,6 +2440,8 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
|
||||
{
|
||||
BlockdevCreateOptions options;
|
||||
int64_t total_size = 0;
|
||||
int64_t extent_size_hint = 0;
|
||||
bool has_extent_size_hint = false;
|
||||
bool nocow = false;
|
||||
PreallocMode prealloc;
|
||||
char *buf = NULL;
|
||||
@@ -2421,6 +2453,11 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
|
||||
/* Read out options */
|
||||
total_size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0),
|
||||
BDRV_SECTOR_SIZE);
|
||||
if (qemu_opt_get(opts, BLOCK_OPT_EXTENT_SIZE_HINT)) {
|
||||
has_extent_size_hint = true;
|
||||
extent_size_hint =
|
||||
qemu_opt_get_size_del(opts, BLOCK_OPT_EXTENT_SIZE_HINT, -1);
|
||||
}
|
||||
nocow = qemu_opt_get_bool(opts, BLOCK_OPT_NOCOW, false);
|
||||
buf = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC);
|
||||
prealloc = qapi_enum_parse(&PreallocMode_lookup, buf,
|
||||
@@ -2440,6 +2477,8 @@ static int coroutine_fn raw_co_create_opts(BlockDriver *drv,
|
||||
.preallocation = prealloc,
|
||||
.has_nocow = true,
|
||||
.nocow = nocow,
|
||||
.has_extent_size_hint = has_extent_size_hint,
|
||||
.extent_size_hint = extent_size_hint,
|
||||
},
|
||||
};
|
||||
return raw_co_create(&options, errp);
|
||||
@@ -2930,6 +2969,11 @@ static QemuOptsList raw_create_opts = {
|
||||
#endif
|
||||
", full)"
|
||||
},
|
||||
{
|
||||
.name = BLOCK_OPT_EXTENT_SIZE_HINT,
|
||||
.type = QEMU_OPT_SIZE,
|
||||
.help = "Extent size hint for the image file, 0 to disable"
|
||||
},
|
||||
{ /* end of list */ }
|
||||
}
|
||||
};
|
||||
|
||||
+19
-1
@@ -938,10 +938,11 @@ static int coroutine_fn qcow_co_create_opts(BlockDriver *drv,
|
||||
{
|
||||
BlockdevCreateOptions *create_options = NULL;
|
||||
BlockDriverState *bs = NULL;
|
||||
QDict *qdict;
|
||||
QDict *qdict = NULL;
|
||||
Visitor *v;
|
||||
const char *val;
|
||||
int ret;
|
||||
char *backing_fmt;
|
||||
|
||||
static const QDictRenames opt_renames[] = {
|
||||
{ BLOCK_OPT_BACKING_FILE, "backing-file" },
|
||||
@@ -949,6 +950,17 @@ static int coroutine_fn qcow_co_create_opts(BlockDriver *drv,
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
/*
|
||||
* We can't actually store a backing format, but can check that
|
||||
* the user's request made sense.
|
||||
*/
|
||||
backing_fmt = qemu_opt_get_del(opts, BLOCK_OPT_BACKING_FMT);
|
||||
if (backing_fmt && !bdrv_find_format(backing_fmt)) {
|
||||
error_setg(errp, "unrecognized backing format '%s'", backing_fmt);
|
||||
ret = -EINVAL;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Parse options and convert legacy syntax */
|
||||
qdict = qemu_opts_to_qdict_filtered(opts, NULL, &qcow_create_opts, true);
|
||||
|
||||
@@ -1012,6 +1024,7 @@ static int coroutine_fn qcow_co_create_opts(BlockDriver *drv,
|
||||
|
||||
ret = 0;
|
||||
fail:
|
||||
g_free(backing_fmt);
|
||||
qobject_unref(qdict);
|
||||
bdrv_unref(bs);
|
||||
qapi_free_BlockdevCreateOptions(create_options);
|
||||
@@ -1146,6 +1159,11 @@ static QemuOptsList qcow_create_opts = {
|
||||
.type = QEMU_OPT_STRING,
|
||||
.help = "File name of a base image"
|
||||
},
|
||||
{
|
||||
.name = BLOCK_OPT_BACKING_FMT,
|
||||
.type = QEMU_OPT_STRING,
|
||||
.help = "Format of the backing image",
|
||||
},
|
||||
{
|
||||
.name = BLOCK_OPT_ENCRYPT,
|
||||
.type = QEMU_OPT_BOOL,
|
||||
|
||||
+6
-1
@@ -3627,7 +3627,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options, Error **errp)
|
||||
}
|
||||
|
||||
ret = bdrv_change_backing_file(blk_bs(blk), qcow2_opts->backing_file,
|
||||
backing_format);
|
||||
backing_format, false);
|
||||
if (ret < 0) {
|
||||
error_setg_errno(errp, -ret, "Could not assign backing file '%s' "
|
||||
"with format '%s'", qcow2_opts->backing_file,
|
||||
@@ -5511,6 +5511,11 @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts,
|
||||
}
|
||||
|
||||
if (backing_file || backing_format) {
|
||||
if (g_strcmp0(backing_file, s->image_backing_file) ||
|
||||
g_strcmp0(backing_format, s->image_backing_format)) {
|
||||
warn_report("Deprecated use of amend to alter the backing file; "
|
||||
"use qemu-img rebase instead");
|
||||
}
|
||||
ret = qcow2_change_backing_file(bs,
|
||||
backing_file ?: s->image_backing_file,
|
||||
backing_format ?: s->image_backing_format);
|
||||
|
||||
+16
-2
@@ -2151,13 +2151,21 @@ static int coroutine_fn sd_co_create_opts(BlockDriver *drv,
|
||||
Error **errp)
|
||||
{
|
||||
BlockdevCreateOptions *create_options = NULL;
|
||||
QDict *qdict, *location_qdict;
|
||||
QDict *qdict = NULL, *location_qdict;
|
||||
Visitor *v;
|
||||
char *redundancy;
|
||||
char *redundancy = NULL;
|
||||
Error *local_err = NULL;
|
||||
int ret;
|
||||
char *backing_fmt = NULL;
|
||||
|
||||
redundancy = qemu_opt_get_del(opts, BLOCK_OPT_REDUNDANCY);
|
||||
backing_fmt = qemu_opt_get_del(opts, BLOCK_OPT_BACKING_FMT);
|
||||
|
||||
if (backing_fmt && strcmp(backing_fmt, "sheepdog") != 0) {
|
||||
error_setg(errp, "backing_file must be a sheepdog image");
|
||||
ret = -EINVAL;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
qdict = qemu_opts_to_qdict(opts, NULL);
|
||||
qdict_put_str(qdict, "driver", "sheepdog");
|
||||
@@ -2220,6 +2228,7 @@ fail:
|
||||
qapi_free_BlockdevCreateOptions(create_options);
|
||||
qobject_unref(qdict);
|
||||
g_free(redundancy);
|
||||
g_free(backing_fmt);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -3177,6 +3186,11 @@ static QemuOptsList sd_create_opts = {
|
||||
.type = QEMU_OPT_STRING,
|
||||
.help = "File name of a base image"
|
||||
},
|
||||
{
|
||||
.name = BLOCK_OPT_BACKING_FMT,
|
||||
.type = QEMU_OPT_STRING,
|
||||
.help = "Must be 'sheepdog' if present",
|
||||
},
|
||||
{
|
||||
.name = BLOCK_OPT_PREALLOC,
|
||||
.type = QEMU_OPT_STRING,
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ static int stream_prepare(Job *job)
|
||||
}
|
||||
}
|
||||
bdrv_set_backing_hd(bs, base, &local_err);
|
||||
ret = bdrv_change_backing_file(bs, base_id, base_fmt);
|
||||
ret = bdrv_change_backing_file(bs, base_id, base_fmt, false);
|
||||
if (local_err) {
|
||||
error_report_err(local_err);
|
||||
return -EPERM;
|
||||
|
||||
@@ -2633,6 +2633,14 @@ static int coroutine_fn vmdk_co_create_opts(BlockDriver *drv,
|
||||
bool zeroed_grain;
|
||||
bool compat6;
|
||||
VMDKCreateOptsData data;
|
||||
char *backing_fmt = NULL;
|
||||
|
||||
backing_fmt = qemu_opt_get_del(opts, BLOCK_OPT_BACKING_FMT);
|
||||
if (backing_fmt && strcmp(backing_fmt, "vmdk") != 0) {
|
||||
error_setg(errp, "backing_file must be a vmdk image");
|
||||
ret = -EINVAL;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (filename_decompose(filename, path, prefix, postfix, PATH_MAX, errp)) {
|
||||
ret = -EINVAL;
|
||||
@@ -2691,6 +2699,7 @@ static int coroutine_fn vmdk_co_create_opts(BlockDriver *drv,
|
||||
vmdk_co_create_opts_cb, &data, errp);
|
||||
|
||||
exit:
|
||||
g_free(backing_fmt);
|
||||
g_free(adapter_type);
|
||||
g_free(backing_file);
|
||||
g_free(hw_version);
|
||||
@@ -3026,6 +3035,11 @@ static QemuOptsList vmdk_create_opts = {
|
||||
.type = QEMU_OPT_STRING,
|
||||
.help = "File name of a base image"
|
||||
},
|
||||
{
|
||||
.name = BLOCK_OPT_BACKING_FMT,
|
||||
.type = QEMU_OPT_STRING,
|
||||
.help = "Must be 'vmdk' if present",
|
||||
},
|
||||
{
|
||||
.name = BLOCK_OPT_COMPAT6,
|
||||
.type = QEMU_OPT_BOOL,
|
||||
|
||||
+2
-1
@@ -3416,7 +3416,8 @@ void qmp_change_backing_file(const char *device,
|
||||
}
|
||||
|
||||
ret = bdrv_change_backing_file(image_bs, backing_file,
|
||||
image_bs->drv ? image_bs->drv->format_name : "");
|
||||
image_bs->drv ? image_bs->drv->format_name : "",
|
||||
false);
|
||||
|
||||
if (ret < 0) {
|
||||
error_setg_errno(errp, -ret, "Could not change backing file to '%s'",
|
||||
|
||||
@@ -427,13 +427,37 @@ kernel in 2018, and has also been dropped from glibc.
|
||||
Related binaries
|
||||
----------------
|
||||
|
||||
``qemu-img convert -n -o`` (since 4.2.0)
|
||||
''''''''''''''''''''''''''''''''''''''''
|
||||
qemu-img amend to adjust backing file (since 5.1)
|
||||
'''''''''''''''''''''''''''''''''''''''''''''''''
|
||||
|
||||
All options specified in ``-o`` are image creation options, so
|
||||
they have no effect when used with ``-n`` to skip image creation.
|
||||
Silently ignored options can be confusing, so this combination of
|
||||
options will be made an error in future versions.
|
||||
The use of ``qemu-img amend`` to modify the name or format of a qcow2
|
||||
backing image is deprecated; this functionality was never fully
|
||||
documented or tested, and interferes with other amend operations that
|
||||
need access to the original backing image (such as deciding whether a
|
||||
v3 zero cluster may be left unallocated when converting to a v2
|
||||
image). Rather, any changes to the backing chain should be performed
|
||||
with ``qemu-img rebase -u`` either before or after the remaining
|
||||
changes being performed by amend, as appropriate.
|
||||
|
||||
qemu-img backing file without format (since 5.1)
|
||||
''''''''''''''''''''''''''''''''''''''''''''''''
|
||||
|
||||
The use of ``qemu-img create``, ``qemu-img rebase``, or ``qemu-img
|
||||
convert`` to create or modify an image that depends on a backing file
|
||||
now recommends that an explicit backing format be provided. This is
|
||||
for safety: if QEMU probes a different format than what you thought,
|
||||
the data presented to the guest will be corrupt; similarly, presenting
|
||||
a raw image to a guest allows a potential security exploit if a future
|
||||
probe sees a non-raw image based on guest writes.
|
||||
|
||||
To avoid the warning message, or even future refusal to create an
|
||||
unsafe image, you must pass ``-o backing_fmt=`` (or the shorthand
|
||||
``-F`` during create) to specify the intended backing format. You may
|
||||
use ``qemu-img rebase -u`` to retroactively add a backing format to an
|
||||
existing image. However, be aware that there are already potential
|
||||
security risks to blindly using ``qemu-img info`` to probe the format
|
||||
of an untrusted backing image, when deciding what format to add into
|
||||
an existing image.
|
||||
|
||||
Backwards compatibility
|
||||
-----------------------
|
||||
@@ -540,8 +564,8 @@ spec you can use the ``-cpu rv64gcsu,priv_spec=v1.10.0`` command line argument.
|
||||
Related binaries
|
||||
----------------
|
||||
|
||||
``qemu-nbd --partition`` (removed in 5.0.0)
|
||||
'''''''''''''''''''''''''''''''''''''''''''
|
||||
``qemu-nbd --partition`` (removed in 5.0)
|
||||
'''''''''''''''''''''''''''''''''''''''''
|
||||
|
||||
The ``qemu-nbd --partition $digit`` code (also spelled ``-P``)
|
||||
could only handle MBR partitions, and never correctly handled logical
|
||||
@@ -557,6 +581,24 @@ can be rewritten as::
|
||||
|
||||
qemu-nbd -t --image-opts driver=raw,offset=1M,size=100M,file.driver=qcow2,file.file.driver=file,file.file.filename=file.qcow2
|
||||
|
||||
``qemu-img convert -n -o`` (removed in 5.1)
|
||||
'''''''''''''''''''''''''''''''''''''''''''
|
||||
|
||||
All options specified in ``-o`` are image creation options, so
|
||||
they are now rejected when used with ``-n`` to skip image creation.
|
||||
|
||||
|
||||
``qemu-img create -b bad file $size`` (removed in 5.1)
|
||||
''''''''''''''''''''''''''''''''''''''''''''''''''''''
|
||||
|
||||
When creating an image with a backing file that could not be opened,
|
||||
``qemu-img create`` used to issue a warning about the failure but
|
||||
proceed with the image creation if an explicit size was provided.
|
||||
However, as the ``-u`` option exists for this purpose, it is safer to
|
||||
enforce that any failure to open the backing image (including if the
|
||||
backing file is missing or an incorrect format was specified) is an
|
||||
error when ``-u`` is not used.
|
||||
|
||||
Command line options
|
||||
--------------------
|
||||
|
||||
|
||||
@@ -258,6 +258,10 @@ Command description:
|
||||
Amends the image format specific *OPTIONS* for the image file
|
||||
*FILENAME*. Not all file formats support this operation.
|
||||
|
||||
The set of options that can be amended are dependent on the image
|
||||
format, but note that amending the backing chain relationship should
|
||||
instead be performed with ``qemu-img rebase``.
|
||||
|
||||
--force allows some unsafe operations. Currently for -f luks, it allows to
|
||||
erase the last encryption key, and to overwrite an active encryption key.
|
||||
|
||||
|
||||
@@ -405,8 +405,8 @@ void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr);
|
||||
void bdrv_refresh_limits(BlockDriverState *bs, Error **errp);
|
||||
int bdrv_commit(BlockDriverState *bs);
|
||||
int bdrv_make_empty(BdrvChild *c, Error **errp);
|
||||
int bdrv_change_backing_file(BlockDriverState *bs,
|
||||
const char *backing_file, const char *backing_fmt);
|
||||
int bdrv_change_backing_file(BlockDriverState *bs, const char *backing_file,
|
||||
const char *backing_fmt, bool warn);
|
||||
void bdrv_register(BlockDriver *bdrv);
|
||||
int bdrv_drop_intermediate(BlockDriverState *top, BlockDriverState *base,
|
||||
const char *backing_file_str);
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
#define BLOCK_OPT_ADAPTER_TYPE "adapter_type"
|
||||
#define BLOCK_OPT_REDUNDANCY "redundancy"
|
||||
#define BLOCK_OPT_NOCOW "nocow"
|
||||
#define BLOCK_OPT_EXTENT_SIZE_HINT "extent_size_hint"
|
||||
#define BLOCK_OPT_OBJECT_SIZE "object_size"
|
||||
#define BLOCK_OPT_REFCOUNT_BITS "refcount_bits"
|
||||
#define BLOCK_OPT_DATA_FILE "data_file"
|
||||
|
||||
@@ -4185,14 +4185,17 @@
|
||||
# falloc (if defined CONFIG_POSIX_FALLOCATE),
|
||||
# full (if defined CONFIG_POSIX))
|
||||
# @nocow: Turn off copy-on-write (valid only on btrfs; default: off)
|
||||
# @extent-size-hint: Extent size hint to add to the image file; 0 for not
|
||||
# adding an extent size hint (default: 1 MB, since 5.1)
|
||||
#
|
||||
# Since: 2.12
|
||||
##
|
||||
{ 'struct': 'BlockdevCreateOptionsFile',
|
||||
'data': { 'filename': 'str',
|
||||
'size': 'size',
|
||||
'*preallocation': 'PreallocMode',
|
||||
'*nocow': 'bool' } }
|
||||
'data': { 'filename': 'str',
|
||||
'size': 'size',
|
||||
'*preallocation': 'PreallocMode',
|
||||
'*nocow': 'bool',
|
||||
'*extent-size-hint': 'size'} }
|
||||
|
||||
##
|
||||
# @BlockdevCreateOptionsGluster:
|
||||
|
||||
+12
-8
@@ -2364,8 +2364,8 @@ static int img_convert(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (skip_create && options) {
|
||||
warn_report("-o has no effect when skipping image creation");
|
||||
warn_report("This will become an error in future QEMU versions.");
|
||||
error_report("-o has no effect when skipping image creation");
|
||||
goto fail_getopt;
|
||||
}
|
||||
|
||||
if (s.has_zero_init && !skip_create) {
|
||||
@@ -2517,6 +2517,13 @@ static int img_convert(int argc, char **argv)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (out_baseimg_param) {
|
||||
if (!qemu_opt_get(opts, BLOCK_OPT_BACKING_FMT)) {
|
||||
warn_report("Deprecated use of backing file without explicit "
|
||||
"backing format");
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if compression is supported */
|
||||
if (s.compressed) {
|
||||
bool encryption =
|
||||
@@ -3210,12 +3217,9 @@ static int img_map(int argc, char **argv)
|
||||
curr.start = start_offset;
|
||||
while (curr.start + curr.length < length) {
|
||||
int64_t offset = curr.start + curr.length;
|
||||
int64_t n;
|
||||
int64_t n = length - offset;
|
||||
|
||||
/* Probe up to 1 GiB at a time. */
|
||||
n = MIN(1 * GiB, length - offset);
|
||||
ret = get_block_status(bs, offset, n, &next);
|
||||
|
||||
if (ret < 0) {
|
||||
error_report("Could not read file metadata: %s", strerror(-ret));
|
||||
goto out;
|
||||
@@ -3800,9 +3804,9 @@ static int img_rebase(int argc, char **argv)
|
||||
* doesn't change when we switch the backing file.
|
||||
*/
|
||||
if (out_baseimg && *out_baseimg) {
|
||||
ret = bdrv_change_backing_file(bs, out_baseimg, out_basefmt);
|
||||
ret = bdrv_change_backing_file(bs, out_baseimg, out_basefmt, true);
|
||||
} else {
|
||||
ret = bdrv_change_backing_file(bs, NULL, NULL);
|
||||
ret = bdrv_change_backing_file(bs, NULL, NULL, false);
|
||||
}
|
||||
|
||||
if (ret == -ENOSPC) {
|
||||
|
||||
@@ -66,7 +66,7 @@ echo "Creating test image with backing file"
|
||||
echo
|
||||
|
||||
TEST_IMG=$TEST_IMG_SAVE
|
||||
_make_test_img -b "$TEST_IMG.base" 6G
|
||||
_make_test_img -b "$TEST_IMG.base" -F $IMGFMT 6G
|
||||
|
||||
echo "Filling test image"
|
||||
echo
|
||||
|
||||
@@ -269,7 +269,7 @@ wrote 65536/65536 bytes at offset 4295032832
|
||||
No errors were found on the image.
|
||||
Creating test image with backing file
|
||||
|
||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=6442450944 backing_file=TEST_DIR/t.IMGFMT.base
|
||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=6442450944 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=IMGFMT
|
||||
Filling test image
|
||||
|
||||
=== IO: pattern 1
|
||||
|
||||
@@ -66,7 +66,7 @@ echo "Creating test image with backing file"
|
||||
echo
|
||||
|
||||
TEST_IMG="$TEST_IMG_SAVE.orig"
|
||||
_make_test_img -b "$TEST_IMG_SAVE.base" 6G
|
||||
_make_test_img -b "$TEST_IMG_SAVE.base" -F $IMGFMT 6G
|
||||
|
||||
echo "Filling test image"
|
||||
echo
|
||||
|
||||
@@ -269,7 +269,7 @@ wrote 65536/65536 bytes at offset 4295032832
|
||||
No errors were found on the image.
|
||||
Creating test image with backing file
|
||||
|
||||
Formatting 'TEST_DIR/t.IMGFMT.orig', fmt=IMGFMT size=6442450944 backing_file=TEST_DIR/t.IMGFMT.base
|
||||
Formatting 'TEST_DIR/t.IMGFMT.orig', fmt=IMGFMT size=6442450944 backing_file=TEST_DIR/t.IMGFMT.base backing_fmt=IMGFMT
|
||||
Filling test image
|
||||
|
||||
=== IO: pattern 1
|
||||
|
||||
@@ -74,7 +74,7 @@ echo "Creating test image with backing file"
|
||||
echo
|
||||
|
||||
TEST_IMG="$TEST_IMG_SAVE.orig"
|
||||
_make_test_img -b "$TEST_IMG_SAVE.base" 6G
|
||||
_make_test_img -b "$TEST_IMG_SAVE.base" -F $IMGFMT 6G
|
||||
|
||||
echo "Filling test image"
|
||||
echo
|
||||
@@ -98,7 +98,8 @@ for backing_option in "-B " "-o backing_file="; do
|
||||
echo
|
||||
echo Testing conversion with $backing_option"$TEST_IMG.base" | _filter_testdir | _filter_imgfmt
|
||||
echo
|
||||
$QEMU_IMG convert -f $IMGFMT -O $IMGFMT $backing_option"$TEST_IMG.base" "$TEST_IMG.orig" "$TEST_IMG"
|
||||
$QEMU_IMG convert -f $IMGFMT -O $IMGFMT $backing_option"$TEST_IMG.base" \
|
||||
-o backing_fmt=$IMGFMT "$TEST_IMG.orig" "$TEST_IMG"
|
||||
|
||||
echo "Checking if backing clusters are allocated when they shouldn't"
|
||||
echo
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user