[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RESEND 01/50] blockdev: Allow creation of BDS trees
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH RESEND 01/50] blockdev: Allow creation of BDS trees without BB |
Date: |
Tue, 27 Jan 2015 14:45:34 -0500 |
If the "id" field is missing from the options given to blockdev-add,
just omit the BlockBackend and create the BlockDriverState tree alone.
Signed-off-by: Max Reitz <address@hidden>
---
blockdev.c | 38 +++++++++++++++++++++++++-------------
tests/qemu-iotests/087 | 20 --------------------
tests/qemu-iotests/087.out | 12 ------------
3 files changed, 25 insertions(+), 45 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 7573746..81fa7bd 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2844,17 +2844,12 @@ out:
void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
{
QmpOutputVisitor *ov = qmp_output_visitor_new();
- BlockBackend *blk;
+ BlockDriverState *bs;
+ BlockBackend *blk = NULL;
QObject *obj;
QDict *qdict;
Error *local_err = NULL;
- /* Require an ID in the top level */
- if (!options->has_id) {
- error_setg(errp, "Block device needs an ID");
- goto fail;
- }
-
/* TODO Sort it out in raw-posix and drive_new(): Reject aio=native with
* cache.direct=false instead of silently switching to aio=threads, except
* when called from drive_new().
@@ -2882,14 +2877,31 @@ void qmp_blockdev_add(BlockdevOptions *options, Error
**errp)
qdict_flatten(qdict);
- blk = blockdev_init(NULL, qdict, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- goto fail;
+ if (options->has_id) {
+ blk = blockdev_init(NULL, qdict, &local_err);
+ if (local_err) {
+ error_propagate(errp, local_err);
+ goto fail;
+ }
+
+ bs = blk_bs(blk);
+ } else {
+ int ret;
+
+ bs = NULL;
+ ret = bdrv_open(&bs, NULL, NULL, qdict, BDRV_O_RDWR | BDRV_O_CACHE_WB,
+ NULL, errp);
+ if (ret < 0) {
+ goto fail;
+ }
}
- if (bdrv_key_required(blk_bs(blk))) {
- blk_unref(blk);
+ if (bs && bdrv_key_required(bs)) {
+ if (blk) {
+ blk_unref(blk);
+ } else {
+ bdrv_unref(bs);
+ }
error_setg(errp, "blockdev-add doesn't support encrypted devices");
goto fail;
}
diff --git a/tests/qemu-iotests/087 b/tests/qemu-iotests/087
index 8694749..4b2eddc 100755
--- a/tests/qemu-iotests/087
+++ b/tests/qemu-iotests/087
@@ -54,26 +54,6 @@ size=128M
_make_test_img $size
echo
-echo === Missing ID ===
-echo
-
-run_qemu <<EOF
-{ "execute": "qmp_capabilities" }
-{ "execute": "blockdev-add",
- "arguments": {
- "options": {
- "driver": "$IMGFMT",
- "file": {
- "driver": "file",
- "filename": "$TEST_IMG"
- }
- }
- }
- }
-{ "execute": "quit" }
-EOF
-
-echo
echo === Duplicate ID ===
echo
diff --git a/tests/qemu-iotests/087.out b/tests/qemu-iotests/087.out
index 0ba2e43..681ef93 100644
--- a/tests/qemu-iotests/087.out
+++ b/tests/qemu-iotests/087.out
@@ -1,18 +1,6 @@
QA output created by 087
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
-=== Missing ID ===
-
-Testing:
-QMP_VERSION
-{"return": {}}
-{"error": {"class": "GenericError", "desc": "Block device needs an ID"}}
-{"return": {}}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"SHUTDOWN"}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"DEVICE_TRAY_MOVED", "data": {"device": "floppy0", "tray-open": true}}
-
-
=== Duplicate ID ===
Testing:
--
2.1.0
- [Qemu-devel] [PATCH RESEND 50/50] iotests: Add test for change-related QMP commands, (continued)
- [Qemu-devel] [PATCH RESEND 50/50] iotests: Add test for change-related QMP commands, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 48/50] hmp: Add read-only option to change command, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 03/50] hw/block/fdc: Implement tray status, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 17/50] block: Respect empty BB in bdrv_lookup_bs(), Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 37/50] block: Add blk_remove_bs(), Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 20/50] blockdev: Check blk_is_available() in sn-del-int-sync, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 14/50] block: Make some BB functions fall back to BBRS, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 01/50] blockdev: Allow creation of BDS trees without BB,
Max Reitz <=
- [Qemu-devel] [PATCH RESEND 22/50] blockdev: Check BB validity in drive-backup TA, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 13/50] block: Add BlockBackendRootState, Max Reitz, 2015/01/27
- [Qemu-devel] [PATCH RESEND 24/50] blockdev: Check BB validity in block-stream, Max Reitz, 2015/01/27