[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 22/38] blockdev: Do not create BDS for empty driv
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH v3 22/38] blockdev: Do not create BDS for empty drive |
Date: |
Wed, 3 Jun 2015 21:44:03 +0200 |
Do not use "rudimentary" BDSs for empty drives any longer (for
freshly created drives).
With this change, bdrv_close_all() has no effect on empty drives (whose
media were not changed) any longer. This breaks some test outputs, fix
them.
After a follow-up patch, empty drives will generally use a NULL BDS, not
only the freshly created drives.
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
blockdev.c | 68 ++++++++++++++++++++++++++--------------------
tests/qemu-iotests/067.out | 44 ------------------------------
tests/qemu-iotests/071.out | 2 --
tests/qemu-iotests/081.out | 1 -
tests/qemu-iotests/087.out | 6 ----
5 files changed, 38 insertions(+), 83 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 6eaed9c..8c91532 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -502,16 +502,40 @@ static BlockBackend *blockdev_init(const char *file,
QDict *bs_opts,
goto early_err;
}
+ if (snapshot) {
+ /* always use cache=unsafe with snapshot */
+ bdrv_flags &= ~BDRV_O_CACHE_MASK;
+ bdrv_flags |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH);
+ }
+
+ if (copy_on_read) {
+ bdrv_flags |= BDRV_O_COPY_ON_READ;
+ }
+
+ if (runstate_check(RUN_STATE_INMIGRATE)) {
+ bdrv_flags |= BDRV_O_INCOMING;
+ }
+
+ bdrv_flags |= ro ? 0 : BDRV_O_RDWR;
+
/* init */
if ((!file || !*file) && !has_driver_specific_opts) {
- blk = blk_new_with_bs(qemu_opts_id(opts), errp);
+ BlockBackendRootState *blk_rs;
+
+ blk = blk_new(qemu_opts_id(opts), errp);
if (!blk) {
goto early_err;
}
- bs = blk_bs(blk);
- bs->open_flags = snapshot ? BDRV_O_SNAPSHOT : 0;
- bs->read_only = ro;
+ blk_rs = blk_get_root_state(blk);
+ blk_rs->open_flags = bdrv_flags;
+ blk_rs->read_only = ro;
+ blk_rs->detect_zeroes = detect_zeroes;
+
+ if (throttle_enabled(&cfg)) {
+ blk_rs->io_limits_enabled = true;
+ blk_rs->throttle_config = cfg;
+ }
QDECREF(bs_opts);
} else {
@@ -519,43 +543,27 @@ static BlockBackend *blockdev_init(const char *file,
QDict *bs_opts,
file = NULL;
}
- if (snapshot) {
- /* always use cache=unsafe with snapshot */
- bdrv_flags &= ~BDRV_O_CACHE_MASK;
- bdrv_flags |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH);
- }
-
- if (copy_on_read) {
- bdrv_flags |= BDRV_O_COPY_ON_READ;
- }
-
- if (runstate_check(RUN_STATE_INMIGRATE)) {
- bdrv_flags |= BDRV_O_INCOMING;
- }
-
- bdrv_flags |= ro ? 0 : BDRV_O_RDWR;
-
blk = blk_new_open(qemu_opts_id(opts), file, NULL, bs_opts, bdrv_flags,
errp);
if (!blk) {
goto err_no_bs_opts;
}
bs = blk_bs(blk);
- }
- bs->detect_zeroes = detect_zeroes;
+ bs->detect_zeroes = detect_zeroes;
- blk_set_on_error(blk, on_read_error, on_write_error);
+ /* disk I/O throttling */
+ if (throttle_enabled(&cfg)) {
+ bdrv_io_limits_enable(bs);
+ bdrv_set_io_limits(bs, &cfg);
+ }
- /* disk I/O throttling */
- if (throttle_enabled(&cfg)) {
- bdrv_io_limits_enable(bs);
- bdrv_set_io_limits(bs, &cfg);
+ if (bdrv_key_required(bs)) {
+ autostart = 0;
+ }
}
- if (bdrv_key_required(bs)) {
- autostart = 0;
- }
+ blk_set_on_error(blk, on_read_error, on_write_error);
err_no_bs_opts:
qemu_opts_del(opts);
diff --git a/tests/qemu-iotests/067.out b/tests/qemu-iotests/067.out
index a692c95..aff104a 100644
--- a/tests/qemu-iotests/067.out
+++ b/tests/qemu-iotests/067.out
@@ -155,17 +155,6 @@ Testing: -drive
file=TEST_DIR/t.qcow2,format=qcow2,if=none,id=disk -device virti
},
"event": "SHUTDOWN"
}
-{
- "timestamp": {
- "seconds": TIMESTAMP,
- "microseconds": TIMESTAMP
- },
- "event": "DEVICE_TRAY_MOVED",
- "data": {
- "device": "ide1-cd0",
- "tray-open": true
- }
-}
=== -drive/device_add and device_del ===
@@ -326,17 +315,6 @@ Testing: -drive
file=TEST_DIR/t.qcow2,format=qcow2,if=none,id=disk
},
"event": "SHUTDOWN"
}
-{
- "timestamp": {
- "seconds": TIMESTAMP,
- "microseconds": TIMESTAMP
- },
- "event": "DEVICE_TRAY_MOVED",
- "data": {
- "device": "ide1-cd0",
- "tray-open": true
- }
-}
=== drive_add/device_add and device_del ===
@@ -500,17 +478,6 @@ Testing:
},
"event": "SHUTDOWN"
}
-{
- "timestamp": {
- "seconds": TIMESTAMP,
- "microseconds": TIMESTAMP
- },
- "event": "DEVICE_TRAY_MOVED",
- "data": {
- "device": "ide1-cd0",
- "tray-open": true
- }
-}
=== blockdev_add/device_add and device_del ===
@@ -721,16 +688,5 @@ Testing:
},
"event": "SHUTDOWN"
}
-{
- "timestamp": {
- "seconds": TIMESTAMP,
- "microseconds": TIMESTAMP
- },
- "event": "DEVICE_TRAY_MOVED",
- "data": {
- "device": "ide1-cd0",
- "tray-open": true
- }
-}
*** done
diff --git a/tests/qemu-iotests/071.out b/tests/qemu-iotests/071.out
index 904ce15..2b40ead 100644
--- a/tests/qemu-iotests/071.out
+++ b/tests/qemu-iotests/071.out
@@ -51,7 +51,6 @@ read failed: Input/output error
{"return": ""}
{"return": {}}
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"SHUTDOWN"}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}}
QEMU_PROG: Failed to flush the L2 table cache: Input/output error
QEMU_PROG: Failed to flush the refcount block cache: Input/output error
@@ -93,7 +92,6 @@ read failed: Input/output error
{"return": ""}
{"return": {}}
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"SHUTDOWN"}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}}
QEMU_PROG: Failed to flush the L2 table cache: Input/output error
QEMU_PROG: Failed to flush the refcount block cache: Input/output error
diff --git a/tests/qemu-iotests/081.out b/tests/qemu-iotests/081.out
index b1e4909..7063231 100644
--- a/tests/qemu-iotests/081.out
+++ b/tests/qemu-iotests/081.out
@@ -37,7 +37,6 @@ read 10485760/10485760 bytes at offset 0
{"return": ""}
{"return": {}}
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"SHUTDOWN"}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}}
== using quorum rewrite corrupted mode ==
diff --git a/tests/qemu-iotests/087.out b/tests/qemu-iotests/087.out
index 0089aa8..7d62cd5 100644
--- a/tests/qemu-iotests/087.out
+++ b/tests/qemu-iotests/087.out
@@ -9,7 +9,6 @@ QMP_VERSION
{"error": {"class": "GenericError", "desc": "'id' and/or 'node-name' need to
be specified for the root node"}}
{"return": {}}
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"SHUTDOWN"}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}}
=== Duplicate ID ===
@@ -25,7 +24,6 @@ QMP_VERSION
{"error": {"class": "GenericError", "desc": "node-name=disk3 is conflicting
with a device 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}}
=== aio=native without O_DIRECT ===
@@ -36,7 +34,6 @@ QMP_VERSION
{"error": {"class": "GenericError", "desc": "aio=native requires
cache.direct=true"}}
{"return": {}}
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"SHUTDOWN"}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}}
=== Encrypted image ===
@@ -57,7 +54,6 @@ You can use 'qemu-img convert' to convert your image to an
unencrypted one.
{"error": {"class": "GenericError", "desc": "blockdev-add doesn't support
encrypted devices"}}
{"return": {}}
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"SHUTDOWN"}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}}
Testing:
QMP_VERSION
@@ -68,7 +64,6 @@ You can use 'qemu-img convert' to convert your image to an
unencrypted one.
{"error": {"class": "GenericError", "desc": "Guest must be stopped for opening
of encrypted image"}}
{"return": {}}
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"SHUTDOWN"}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}}
=== Missing driver ===
@@ -86,6 +81,5 @@ QMP_VERSION
{"error": {"class": "GenericError", "desc": "Invalid parameter type for
'driver', expected: string"}}
{"return": {}}
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"SHUTDOWN"}
-{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event":
"DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}}
*** done
--
2.4.1
- [Qemu-devel] [PATCH v3 16/38] block: Add BlockBackendRootState, (continued)
- [Qemu-devel] [PATCH v3 16/38] block: Add BlockBackendRootState, Max Reitz, 2015/06/03
- [Qemu-devel] [PATCH v3 15/38] block: Move I/O status and error actions into BB, Max Reitz, 2015/06/03
- [Qemu-devel] [PATCH v3 17/38] block: Make some BB functions fall back to BBRS, Max Reitz, 2015/06/03
- [Qemu-devel] [PATCH v3 18/38] block: Fail requests to empty BlockBackend, Max Reitz, 2015/06/03
- [Qemu-devel] [PATCH v3 20/38] block: Add blk_insert_bs(), Max Reitz, 2015/06/03
- [Qemu-devel] [PATCH v3 19/38] block: Prepare remaining BB functions for NULL BDS, Max Reitz, 2015/06/03
- [Qemu-devel] [PATCH v3 21/38] block: Prepare for NULL BDS, Max Reitz, 2015/06/03
- [Qemu-devel] [PATCH v3 22/38] blockdev: Do not create BDS for empty drive,
Max Reitz <=
- [Qemu-devel] [PATCH v3 24/38] blockdev: Allow more options for BB-less BDS tree, Max Reitz, 2015/06/03
- [Qemu-devel] [PATCH v3 23/38] blockdev: Pull out blockdev option extraction, Max Reitz, 2015/06/03
- [Qemu-devel] [PATCH v3 26/38] blockdev: Add blockdev-open-tray, Max Reitz, 2015/06/03
- [Qemu-devel] [PATCH v3 25/38] block: Add blk_remove_bs(), Max Reitz, 2015/06/03
- [Qemu-devel] [PATCH v3 28/38] blockdev: Add blockdev-remove-medium, Max Reitz, 2015/06/03
- [Qemu-devel] [PATCH v3 29/38] blockdev: Add blockdev-insert-medium, Max Reitz, 2015/06/03