[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 34/50] blockdev: Do not create BDS for empty drive
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH 34/50] blockdev: Do not create BDS for empty drive |
Date: |
Mon, 26 Jan 2015 11:03:08 -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 | 5 ----
5 files changed, 38 insertions(+), 82 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index f82b20c..d99edbb 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 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 033cc3b..0efe971 100644
--- a/tests/qemu-iotests/087.out
+++ b/tests/qemu-iotests/087.out
@@ -14,7 +14,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 ===
@@ -25,7 +24,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 ===
@@ -37,7 +35,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
@@ -45,7 +42,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 ===
@@ -57,6 +53,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 18/50] block: Respect empty BB in bdrv_query_info(), (continued)
- [Qemu-devel] [PATCH 18/50] block: Respect empty BB in bdrv_query_info(), Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 15/50] block: Fail requests to empty BlockBackend, Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 19/50] blockdev: Use BlockBackend for blockdev-backup TA, Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 17/50] block: Respect empty BB in bdrv_lookup_bs(), Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 23/50] blockdev: Catch NULL BDS in block_set_io_throttle, Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 25/50] blockdev: Check BB validity in block-commit, Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 27/50] blockdev: Check BB validity in blockdev-backup, Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 24/50] blockdev: Check BB validity in block-stream, Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 28/50] blockdev: Check BB validity in drive-mirror, Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 29/50] blockdev: Check BB validity in find_block_job(), Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 34/50] blockdev: Do not create BDS for empty drive,
Max Reitz <=
- [Qemu-devel] [PATCH 26/50] blockdev: Check BB validity in drive-backup, Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 32/50] blockdev: Check BB validity in eject and change, Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 31/50] block: Add blk_insert_bs(), Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 33/50] blockdev: Respect NULL BDS in do_drive_del(), Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 30/50] blockdev: Check BB validity in change-backing-file, Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 37/50] block: Add blk_remove_bs(), Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 36/50] blockdev: Allow more options for BB-less BDS tree, Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 35/50] blockdev: Pull out blockdev option extraction, Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 43/50] blockdev: Implement change with basic operations, Max Reitz, 2015/01/26
- [Qemu-devel] [PATCH 44/50] block: Inquire tray state before tray-moved events, Max Reitz, 2015/01/26