[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v13 07/14] block: Parse "backing" option to referenc
From: |
Fam Zheng |
Subject: |
[Qemu-devel] [PATCH v13 07/14] block: Parse "backing" option to reference existing BDS |
Date: |
Wed, 29 Jan 2014 13:07:34 +0800 |
Now it's safe to allow reference for backing_hd in the interface.
Signed-off-by: Fam Zheng <address@hidden>
---
block.c | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/block.c b/block.c
index 4e3b393..9d57223 100644
--- a/block.c
+++ b/block.c
@@ -1392,12 +1392,34 @@ int bdrv_open(BlockDriverState *bs, const char
*filename, QDict *options,
/* If there is a backing file, use it */
if ((flags & BDRV_O_NO_BACKING) == 0) {
QDict *backing_options;
+ const char *backing_name;
+ BlockDriverState *backing_hd;
+ backing_name = qdict_get_try_str(options, "backing");
qdict_extract_subqdict(options, &backing_options, "backing.");
- ret = bdrv_open_backing_file(bs, backing_options, &local_err);
- if (ret < 0) {
+
+ if (backing_name && qdict_size(backing_options)) {
+ error_setg(&local_err,
+ "Option \"backing\" and \"backing.*\" cannot be "
+ "used together");
+ ret = -EINVAL;
goto close_and_fail;
}
+ if (backing_name) {
+ backing_hd = bdrv_find(backing_name);
+ if (!backing_hd) {
+ error_set(&local_err, QERR_DEVICE_NOT_FOUND, backing_name);
+ ret = -ENOENT;
+ goto close_and_fail;
+ }
+ qdict_del(options, "backing");
+ bdrv_set_backing_hd(bs, backing_hd);
+ } else {
+ ret = bdrv_open_backing_file(bs, backing_options, &local_err);
+ if (ret < 0) {
+ goto close_and_fail;
+ }
+ }
}
/* Check if any unknown options were used */
--
1.8.5.3
- [Qemu-devel] [PATCH v13 00/14] Drop in_use from BlockDriverState and enable point-in-time snapshot exporting over NBD, Fam Zheng, 2014/01/29
- [Qemu-devel] [PATCH v13 01/14] block: Add BlockOpType enum, Fam Zheng, 2014/01/29
- [Qemu-devel] [PATCH v13 02/14] block: Introduce op_blockers to BlockDriverState, Fam Zheng, 2014/01/29
- [Qemu-devel] [PATCH v13 03/14] block: Replace in_use with operation blocker, Fam Zheng, 2014/01/29
- [Qemu-devel] [PATCH v13 04/14] block: Move op_blocker check from block_job_create to its caller, Fam Zheng, 2014/01/29
- [Qemu-devel] [PATCH v13 05/14] block: Add bdrv_set_backing_hd(), Fam Zheng, 2014/01/29
- [Qemu-devel] [PATCH v13 06/14] block: Add backing_blocker in BlockDriverState, Fam Zheng, 2014/01/29
- [Qemu-devel] [PATCH v13 07/14] block: Parse "backing" option to reference existing BDS,
Fam Zheng <=
- [Qemu-devel] [PATCH v13 08/14] block: Support dropping active in bdrv_drop_intermediate, Fam Zheng, 2014/01/29
- [Qemu-devel] [PATCH v13 09/14] stream: Use bdrv_drop_intermediate and drop close_unused_images, Fam Zheng, 2014/01/29
- [Qemu-devel] [PATCH v13 10/14] qmp: Add command 'blockdev-backup', Fam Zheng, 2014/01/29
- [Qemu-devel] [PATCH v13 11/14] block: Allow backup on referenced named BlockDriverState, Fam Zheng, 2014/01/29
- [Qemu-devel] [PATCH v13 12/14] block: Add blockdev-backup to transaction, Fam Zheng, 2014/01/29
- [Qemu-devel] [PATCH v13 13/14] qemu-iotests: Test blockdev-backup in 055, Fam Zheng, 2014/01/29
- [Qemu-devel] [PATCH v13 14/14] qemu-iotests: Image fleecing test case 081, Fam Zheng, 2014/01/29
- Re: [Qemu-devel] [PATCH v13 00/14] Drop in_use from BlockDriverState and enable point-in-time snapshot exporting over NBD, Ian Main, 2014/01/31