[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 07/13] block: Allow omitting the 'backing' option
From: |
Alberto Garcia |
Subject: |
[Qemu-devel] [PATCH v2 07/13] block: Allow omitting the 'backing' option in certain cases |
Date: |
Wed, 6 Mar 2019 20:11:07 +0200 |
Of all options of type BlockdevRef used to specify children in
BlockdevOptions, 'backing' is the only one that is optional.
For "x-blockdev-reopen" we want that if an option is omitted then it
must be reset to its default value. The default value of 'backing'
means that QEMU opens the backing file specified in the image
metadata, but this is not something that we want to support for the
reopen operation.
Because of this the 'backing' option has to be specified during
reopen, pointing to the existing backing file if we want to keep it,
or pointing to a different one (or NULL) if we want to replace it (to
be implemented in a subsequent patch).
In order to simplify things a bit and not to require that the user
passes the 'backing' option to every single block device even when
it's clearly not necessary, this patch allows omitting this option if
the block device being reopened doesn't have a backing file attached
_and_ no default backing file is specified in the image metadata.
Signed-off-by: Alberto Garcia <address@hidden>
---
block.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/block.c b/block.c
index d7fa577c18..6db8a65e61 100644
--- a/block.c
+++ b/block.c
@@ -3414,7 +3414,13 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state,
BlockReopenQueue *queue,
drv_prepared = true;
- if (drv->supports_backing && reopen_state->backing_missing) {
+ /*
+ * We must provide the 'backing' option if the BDS has a backing
+ * file or if the image file has a backing file name as part of
+ * its metadata. Otherwise the 'backing' option can be omitted.
+ */
+ if (drv->supports_backing && reopen_state->backing_missing &&
+ (backing_bs(reopen_state->bs) || reopen_state->bs->backing_file[0])) {
error_setg(errp, "backing is missing for '%s'",
reopen_state->bs->node_name);
ret = -EINVAL;
--
2.11.0
- [Qemu-devel] [PATCH v2 03/13] block: Freeze the backing chain for the duration of the mirror job, (continued)
- [Qemu-devel] [PATCH v2 03/13] block: Freeze the backing chain for the duration of the mirror job, Alberto Garcia, 2019/03/06
- [Qemu-devel] [PATCH v2 01/13] block: Allow freezing BdrvChild links, Alberto Garcia, 2019/03/06
- Re: [Qemu-devel] [PATCH v2 01/13] block: Allow freezing BdrvChild links, Vladimir Sementsov-Ogievskiy, 2019/03/12
- Re: [Qemu-devel] [PATCH v2 01/13] block: Allow freezing BdrvChild links, Alberto Garcia, 2019/03/13
- Re: [Qemu-devel] [PATCH v2 01/13] block: Allow freezing BdrvChild links, Vladimir Sementsov-Ogievskiy, 2019/03/13
- Re: [Qemu-devel] [PATCH v2 01/13] block: Allow freezing BdrvChild links, Kevin Wolf, 2019/03/13
- Re: [Qemu-devel] [PATCH v2 01/13] block: Allow freezing BdrvChild links, Alberto Garcia, 2019/03/13
- Re: [Qemu-devel] [PATCH v2 01/13] block: Allow freezing BdrvChild links, Alberto Garcia, 2019/03/13
[Qemu-devel] [PATCH v2 12/13] block: Add an 'x-blockdev-reopen' QMP command, Alberto Garcia, 2019/03/06
[Qemu-devel] [PATCH v2 02/13] block: Freeze the backing chain for the duration of the commit job, Alberto Garcia, 2019/03/06
[Qemu-devel] [PATCH v2 07/13] block: Allow omitting the 'backing' option in certain cases,
Alberto Garcia <=