[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 21/37] blockdev: Do not create BDS for empty driv
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH v2 21/37] blockdev: Do not create BDS for empty drive |
Date: |
Mon, 9 Feb 2015 12:11:21 -0500 |
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>
---
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 d0e1079..5319bb0 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -504,16 +504,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 {
@@ -521,43 +545,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 42bae32..47b0b68 100644
--- a/tests/qemu-iotests/067.out
+++ b/tests/qemu-iotests/067.out
@@ -154,17 +154,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 ===
@@ -324,17 +313,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 ===
@@ -497,17 +475,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 ===
@@ -716,16 +683,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 55f4951..8699c46 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 ===
@@ -48,7 +45,6 @@ QMP_VERSION
{"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
@@ -56,7 +52,6 @@ QMP_VERSION
{"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 ===
@@ -68,6 +63,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.1.0
- [Qemu-devel] [PATCH v2 11/37] block: Remove wr_highest_sector from BlockAcctStats, (continued)
- [Qemu-devel] [PATCH v2 11/37] block: Remove wr_highest_sector from BlockAcctStats, Max Reitz, 2015/02/09
- [Qemu-devel] [PATCH v2 17/37] block: Prepare remaining BB functions for NULL BDS, Max Reitz, 2015/02/09
- [Qemu-devel] [PATCH v2 14/37] block: Add BlockBackendRootState, Max Reitz, 2015/02/09
- [Qemu-devel] [PATCH v2 18/37] blockdev: Use BB for blockdev-backup transaction, Max Reitz, 2015/02/09
- [Qemu-devel] [PATCH v2 16/37] block: Fail requests to empty BlockBackend, Max Reitz, 2015/02/09
- [Qemu-devel] [PATCH v2 13/37] block: Move I/O status and error actions into BB, Max Reitz, 2015/02/09
- [Qemu-devel] [PATCH v2 15/37] block: Make some BB functions fall back to BBRS, Max Reitz, 2015/02/09
- [Qemu-devel] [PATCH v2 19/37] block: Add blk_insert_bs(), Max Reitz, 2015/02/09
- [Qemu-devel] [PATCH v2 21/37] blockdev: Do not create BDS for empty drive,
Max Reitz <=
- [Qemu-devel] [PATCH v2 24/37] block: Add blk_remove_bs(), Max Reitz, 2015/02/09
- [Qemu-devel] [PATCH v2 22/37] blockdev: Pull out blockdev option extraction, Max Reitz, 2015/02/09
- [Qemu-devel] [PATCH v2 34/37] blockdev: read-only-mode for blockdev-change-medium, Max Reitz, 2015/02/09
- [Qemu-devel] [PATCH v2 27/37] blockdev: Add blockdev-remove-medium, Max Reitz, 2015/02/09
- [Qemu-devel] [PATCH v2 33/37] hmp: Use blockdev-change-medium for change command, Max Reitz, 2015/02/09
- [Qemu-devel] [PATCH v2 36/37] iotests: More options for VM.add_drive(), Max Reitz, 2015/02/09
- [Qemu-devel] [PATCH v2 31/37] block: Inquire tray state before tray-moved events, Max Reitz, 2015/02/09