From: Max Reitz <mreitz@redhat.com>
To: qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Alberto Garcia <berto@igalia.com>,
Markus Armbruster <armbru@redhat.com>,
qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>,
John Snow <jsnow@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH v5 25/38] blockdev: Allow more options for BB-less BDS tree
Date: Fri, 18 Sep 2015 17:23:00 +0200 [thread overview]
Message-ID: <1442589793-7105-26-git-send-email-mreitz@redhat.com> (raw)
In-Reply-To: <1442589793-7105-1-git-send-email-mreitz@redhat.com>
Most of the options which blockdev_init() parses for both the
BlockBackend and the root BDS are valid for just the root BDS as well
(e.g. read-only). This patch allows specifying these options even if not
creating a BlockBackend.
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
blockdev.c | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 154 insertions(+), 6 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 688ee5f..647ce0b 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -612,6 +612,65 @@ err_no_opts:
return NULL;
}
+static QemuOptsList qemu_root_bds_opts;
+
+/* Takes the ownership of bs_opts */
+static BlockDriverState *bds_tree_init(QDict *bs_opts, Error **errp)
+{
+ BlockDriverState *bs;
+ QemuOpts *opts;
+ Error *local_error = NULL;
+ ThrottleConfig cfg;
+ BlockdevDetectZeroesOptions detect_zeroes;
+ const char *throttling_group = NULL;
+ int ret;
+ int bdrv_flags = 0;
+
+ opts = qemu_opts_create(&qemu_root_bds_opts, NULL, 1, errp);
+ if (!opts) {
+ goto fail;
+ }
+
+ qemu_opts_absorb_qdict(opts, bs_opts, &local_error);
+ if (local_error) {
+ error_propagate(errp, local_error);
+ goto fail;
+ }
+
+ extract_common_blockdev_options(opts, &bdrv_flags, &cfg, &detect_zeroes,
+ &throttling_group, &local_error);
+ if (local_error) {
+ error_propagate(errp, local_error);
+ goto fail;
+ }
+
+ bs = NULL;
+ ret = bdrv_open(&bs, NULL, NULL, bs_opts, bdrv_flags, errp);
+ if (ret < 0) {
+ goto fail_no_bs_opts;
+ }
+
+ bs->detect_zeroes = detect_zeroes;
+
+ /* disk I/O throttling */
+ if (throttle_enabled(&cfg)) {
+ if (!throttling_group) {
+ throttling_group = bdrv_get_node_name(bs);
+ }
+ bdrv_io_limits_enable(bs, throttling_group);
+ bdrv_set_io_limits(bs, &cfg);
+ }
+
+fail_no_bs_opts:
+ qemu_opts_del(opts);
+ return bs;
+
+fail:
+ qemu_opts_del(opts);
+ QDECREF(bs_opts);
+ return NULL;
+}
+
static void qemu_opt_rename(QemuOpts *opts, const char *from, const char *to,
Error **errp)
{
@@ -3170,18 +3229,14 @@ void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
bs = blk_bs(blk);
} else {
- int ret;
-
if (!qdict_get_try_str(qdict, "node-name")) {
error_setg(errp, "'id' and/or 'node-name' need to be specified for "
"the root node");
goto fail;
}
- bs = NULL;
- ret = bdrv_open(&bs, NULL, NULL, qdict, BDRV_O_RDWR | BDRV_O_CACHE_WB,
- errp);
- if (ret < 0) {
+ bs = bds_tree_init(qdict, errp);
+ if (!bs) {
goto fail;
}
}
@@ -3336,6 +3391,99 @@ QemuOptsList qemu_common_drive_opts = {
},
};
+static QemuOptsList qemu_root_bds_opts = {
+ .name = "root-bds",
+ .head = QTAILQ_HEAD_INITIALIZER(qemu_common_drive_opts.head),
+ .desc = {
+ {
+ .name = "discard",
+ .type = QEMU_OPT_STRING,
+ .help = "discard operation (ignore/off, unmap/on)",
+ },{
+ .name = "cache.writeback",
+ .type = QEMU_OPT_BOOL,
+ .help = "enables writeback mode for any caches",
+ },{
+ .name = "cache.direct",
+ .type = QEMU_OPT_BOOL,
+ .help = "enables use of O_DIRECT (bypass the host page cache)",
+ },{
+ .name = "cache.no-flush",
+ .type = QEMU_OPT_BOOL,
+ .help = "ignore any flush requests for the device",
+ },{
+ .name = "aio",
+ .type = QEMU_OPT_STRING,
+ .help = "host AIO implementation (threads, native)",
+ },{
+ .name = "read-only",
+ .type = QEMU_OPT_BOOL,
+ .help = "open drive file as read-only",
+ },{
+ .name = "throttling.iops-total",
+ .type = QEMU_OPT_NUMBER,
+ .help = "limit total I/O operations per second",
+ },{
+ .name = "throttling.iops-read",
+ .type = QEMU_OPT_NUMBER,
+ .help = "limit read operations per second",
+ },{
+ .name = "throttling.iops-write",
+ .type = QEMU_OPT_NUMBER,
+ .help = "limit write operations per second",
+ },{
+ .name = "throttling.bps-total",
+ .type = QEMU_OPT_NUMBER,
+ .help = "limit total bytes per second",
+ },{
+ .name = "throttling.bps-read",
+ .type = QEMU_OPT_NUMBER,
+ .help = "limit read bytes per second",
+ },{
+ .name = "throttling.bps-write",
+ .type = QEMU_OPT_NUMBER,
+ .help = "limit write bytes per second",
+ },{
+ .name = "throttling.iops-total-max",
+ .type = QEMU_OPT_NUMBER,
+ .help = "I/O operations burst",
+ },{
+ .name = "throttling.iops-read-max",
+ .type = QEMU_OPT_NUMBER,
+ .help = "I/O operations read burst",
+ },{
+ .name = "throttling.iops-write-max",
+ .type = QEMU_OPT_NUMBER,
+ .help = "I/O operations write burst",
+ },{
+ .name = "throttling.bps-total-max",
+ .type = QEMU_OPT_NUMBER,
+ .help = "total bytes burst",
+ },{
+ .name = "throttling.bps-read-max",
+ .type = QEMU_OPT_NUMBER,
+ .help = "total bytes read burst",
+ },{
+ .name = "throttling.bps-write-max",
+ .type = QEMU_OPT_NUMBER,
+ .help = "total bytes write burst",
+ },{
+ .name = "throttling.iops-size",
+ .type = QEMU_OPT_NUMBER,
+ .help = "when limiting by iops max size of an I/O in bytes",
+ },{
+ .name = "copy-on-read",
+ .type = QEMU_OPT_BOOL,
+ .help = "copy read data from backing file into image file",
+ },{
+ .name = "detect-zeroes",
+ .type = QEMU_OPT_STRING,
+ .help = "try to optimize zero writes (off, on, unmap)",
+ },
+ { /* end of list */ }
+ },
+};
+
QemuOptsList qemu_drive_opts = {
.name = "drive",
.head = QTAILQ_HEAD_INITIALIZER(qemu_drive_opts.head),
--
2.5.2
next prev parent reply other threads:[~2015-09-18 15:24 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-18 15:22 [Qemu-devel] [PATCH v5 00/38] blockdev: BlockBackend and media Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 01/38] block: Remove host floppy support Max Reitz
2015-09-18 15:31 ` Eric Blake
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 02/38] block: Set BDRV_O_INCOMING in bdrv_fill_options() Max Reitz
2015-09-18 15:32 ` Eric Blake
2015-09-29 8:53 ` Alberto Garcia
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 03/38] blockdev: Allow creation of BDS trees without BB Max Reitz
2015-09-18 15:34 ` Eric Blake
2015-09-29 8:45 ` Alberto Garcia
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 04/38] iotests: Only create BB if necessary Max Reitz
2015-09-18 16:00 ` Eric Blake
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 05/38] block: Make bdrv_is_inserted() return a bool Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 06/38] block: Add blk_is_available() Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 07/38] block: Make bdrv_is_inserted() recursive Max Reitz
2015-09-18 16:20 ` Eric Blake
2015-09-29 9:15 ` Alberto Garcia
2015-09-30 14:32 ` Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 08/38] block/raw_bsd: Drop raw_is_inserted() Max Reitz
2015-09-18 16:20 ` Eric Blake
2015-09-29 10:47 ` Alberto Garcia
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 09/38] block: Invoke change media CB before NULLing drv Max Reitz
2015-09-18 16:22 ` Eric Blake
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 10/38] hw/block/fdc: Implement tray status Max Reitz
2015-09-18 16:24 ` Eric Blake
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 11/38] hw/usb-storage: Check whether BB is inserted Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 12/38] block: Fix BB AIOCB AioContext without BDS Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 13/38] block: Move guest_block_size into BlockBackend Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 14/38] block: Remove wr_highest_sector from BlockAcctStats Max Reitz
2015-09-18 16:59 ` Eric Blake
2015-09-21 7:57 ` Kevin Wolf
2015-09-21 15:53 ` Eric Blake
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 15/38] block: Move BlockAcctStats into BlockBackend Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 16/38] block: Move I/O status and error actions into BB Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 17/38] block: Add BlockBackendRootState Max Reitz
2015-09-22 14:17 ` Kevin Wolf
2015-09-22 15:00 ` Max Reitz
2015-09-29 11:17 ` Alberto Garcia
2015-09-29 12:30 ` Eric Blake
2015-09-29 13:12 ` Kevin Wolf
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 18/38] block: Make some BB functions fall back to BBRS Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 19/38] block: Fail requests to empty BlockBackend Max Reitz
2015-09-22 14:30 ` Kevin Wolf
2015-09-22 15:05 ` Max Reitz
2015-09-22 15:13 ` Kevin Wolf
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 20/38] block: Prepare remaining BB functions for NULL BDS Max Reitz
2015-09-22 14:35 ` Kevin Wolf
2015-09-22 15:07 ` Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 21/38] block: Add blk_insert_bs() Max Reitz
2015-09-22 14:42 ` Kevin Wolf
2015-09-22 15:20 ` Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 22/38] block: Prepare for NULL BDS Max Reitz
2015-09-18 19:42 ` Eric Blake
2015-10-07 10:43 ` Kevin Wolf
2015-10-07 15:08 ` Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 23/38] blockdev: Do not create BDS for empty drive Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 24/38] blockdev: Pull out blockdev option extraction Max Reitz
2015-09-30 11:16 ` Alberto Garcia
2015-09-18 15:23 ` Max Reitz [this message]
2015-09-18 15:23 ` [Qemu-devel] [PATCH v5 26/38] block: Add blk_remove_bs() Max Reitz
2015-09-18 15:23 ` [Qemu-devel] [PATCH v5 27/38] blockdev: Add blockdev-open-tray Max Reitz
2015-09-18 15:23 ` [Qemu-devel] [PATCH v5 28/38] blockdev: Add blockdev-close-tray Max Reitz
2015-09-18 15:23 ` [Qemu-devel] [PATCH v5 29/38] blockdev: Add blockdev-remove-medium Max Reitz
2015-09-18 15:23 ` [Qemu-devel] [PATCH v5 30/38] blockdev: Add blockdev-insert-medium Max Reitz
2015-09-18 15:23 ` [Qemu-devel] [PATCH v5 31/38] blockdev: Implement eject with basic operations Max Reitz
2015-09-18 15:23 ` [Qemu-devel] [PATCH v5 32/38] blockdev: Implement change " Max Reitz
2015-09-18 15:23 ` [Qemu-devel] [PATCH v5 33/38] block: Inquire tray state before tray-moved events Max Reitz
2015-09-18 15:23 ` [Qemu-devel] [PATCH v5 34/38] qmp: Introduce blockdev-change-medium Max Reitz
2015-09-18 15:23 ` [Qemu-devel] [PATCH v5 35/38] hmp: Use blockdev-change-medium for change command Max Reitz
2015-09-18 15:23 ` [Qemu-devel] [PATCH v5 36/38] blockdev: read-only-mode for blockdev-change-medium Max Reitz
2015-09-18 15:23 ` [Qemu-devel] [PATCH v5 37/38] hmp: Add read-only-mode option to change command Max Reitz
2015-09-18 15:23 ` [Qemu-devel] [PATCH v5 38/38] iotests: Add test for change-related QMP commands Max Reitz
2015-09-22 14:45 ` [Qemu-devel] [PATCH v5 00/38] blockdev: BlockBackend and media Kevin Wolf
2015-09-22 15:09 ` Max Reitz
2015-09-23 6:20 ` Wen Congyang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1442589793-7105-26-git-send-email-mreitz@redhat.com \
--to=mreitz@redhat.com \
--cc=armbru@redhat.com \
--cc=berto@igalia.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).