From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com
Subject: [Qemu-devel] [PULL 06/11] block: Specify -drive legacy option aliases in array
Date: Fri, 26 Sep 2014 20:58:52 +0200 [thread overview]
Message-ID: <1411757937-9087-7-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1411757937-9087-1-git-send-email-kwolf@redhat.com>
Instead of a series of qemu_opt_rename() calls, use an array that
contains all of the renames and call qemu_opt_rename() in a loop. This
will keep the code readable even when we add an error return to
qemu_opt_rename().
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Benoît Canet <benoit.canet@nodalink.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
blockdev.c | 39 ++++++++++++++++++++++++---------------
1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 450f95c..88f7928 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -647,28 +647,37 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type)
const char *serial;
const char *filename;
Error *local_err = NULL;
+ int i;
/* Change legacy command line options into QMP ones */
- qemu_opt_rename(all_opts, "iops", "throttling.iops-total");
- qemu_opt_rename(all_opts, "iops_rd", "throttling.iops-read");
- qemu_opt_rename(all_opts, "iops_wr", "throttling.iops-write");
+ static const struct {
+ const char *from;
+ const char *to;
+ } opt_renames[] = {
+ { "iops", "throttling.iops-total" },
+ { "iops_rd", "throttling.iops-read" },
+ { "iops_wr", "throttling.iops-write" },
- qemu_opt_rename(all_opts, "bps", "throttling.bps-total");
- qemu_opt_rename(all_opts, "bps_rd", "throttling.bps-read");
- qemu_opt_rename(all_opts, "bps_wr", "throttling.bps-write");
+ { "bps", "throttling.bps-total" },
+ { "bps_rd", "throttling.bps-read" },
+ { "bps_wr", "throttling.bps-write" },
- qemu_opt_rename(all_opts, "iops_max", "throttling.iops-total-max");
- qemu_opt_rename(all_opts, "iops_rd_max", "throttling.iops-read-max");
- qemu_opt_rename(all_opts, "iops_wr_max", "throttling.iops-write-max");
+ { "iops_max", "throttling.iops-total-max" },
+ { "iops_rd_max", "throttling.iops-read-max" },
+ { "iops_wr_max", "throttling.iops-write-max" },
- qemu_opt_rename(all_opts, "bps_max", "throttling.bps-total-max");
- qemu_opt_rename(all_opts, "bps_rd_max", "throttling.bps-read-max");
- qemu_opt_rename(all_opts, "bps_wr_max", "throttling.bps-write-max");
+ { "bps_max", "throttling.bps-total-max" },
+ { "bps_rd_max", "throttling.bps-read-max" },
+ { "bps_wr_max", "throttling.bps-write-max" },
- qemu_opt_rename(all_opts,
- "iops_size", "throttling.iops-size");
+ { "iops_size", "throttling.iops-size" },
- qemu_opt_rename(all_opts, "readonly", "read-only");
+ { "readonly", "read-only" },
+ };
+
+ for (i = 0; i < ARRAY_SIZE(opt_renames); i++) {
+ qemu_opt_rename(all_opts, opt_renames[i].from, opt_renames[i].to);
+ }
value = qemu_opt_get(all_opts, "cache");
if (value) {
--
1.8.3.1
next prev parent reply other threads:[~2014-09-26 18:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-26 18:58 [Qemu-devel] [PULL 00/11] Block patches Kevin Wolf
2014-09-26 18:58 ` [Qemu-devel] [PULL 01/11] blkdebug: show an error for invalid event names Kevin Wolf
2014-09-26 18:58 ` [Qemu-devel] [PULL 02/11] blockdev: Disentangle BlockDriverState and DriveInfo creation Kevin Wolf
2014-09-26 18:58 ` [Qemu-devel] [PULL 03/11] block: Keep DriveInfo alive until BlockDriverState dies Kevin Wolf
2014-09-26 18:58 ` [Qemu-devel] [PULL 04/11] qemu-nbd: Destroy the BlockDriverState properly Kevin Wolf
2014-09-26 18:58 ` [Qemu-devel] [PULL 05/11] block: Improve message for device name clashing with node name Kevin Wolf
2014-09-26 18:58 ` Kevin Wolf [this message]
2014-09-26 18:58 ` [Qemu-devel] [PULL 07/11] block: Catch simultaneous usage of options and their aliases Kevin Wolf
2014-09-26 18:58 ` [Qemu-devel] [PULL 08/11] docs: add blkdebug block driver documentation Kevin Wolf
2014-09-26 18:58 ` [Qemu-devel] [PULL 09/11] vpc: fix beX_to_cpu() and cpu_to_beX() confusion Kevin Wolf
2014-09-26 18:58 ` [Qemu-devel] [PULL 10/11] block: Validate node-name Kevin Wolf
2014-09-26 18:58 ` [Qemu-devel] [PULL 11/11] qemu-iotests: Fail test if explicit test case number is unknown Kevin Wolf
2014-09-29 13:03 ` [Qemu-devel] [PULL 00/11] Block patches Peter Maydell
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=1411757937-9087-7-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).