From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54591) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXajg-0001N0-1c for qemu-devel@nongnu.org; Fri, 26 Sep 2014 14:59:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XXaja-0002dT-Ty for qemu-devel@nongnu.org; Fri, 26 Sep 2014 14:59:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:13971) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXaja-0002cK-M9 for qemu-devel@nongnu.org; Fri, 26 Sep 2014 14:59:14 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8QIx8Fa001882 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 26 Sep 2014 14:59:09 -0400 From: Kevin Wolf Date: Fri, 26 Sep 2014 20:58:52 +0200 Message-Id: <1411757937-9087-7-git-send-email-kwolf@redhat.com> In-Reply-To: <1411757937-9087-1-git-send-email-kwolf@redhat.com> References: <1411757937-9087-1-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 06/11] block: Specify -drive legacy option aliases in array List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: 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 Reviewed-by: Beno=C3=AEt Canet Reviewed-by: Markus Armbruster --- 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, BlockInter= faceType block_default_type) const char *serial; const char *filename; Error *local_err =3D NULL; + int i; =20 /* 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[] =3D { + { "iops", "throttling.iops-total" }, + { "iops_rd", "throttling.iops-read" }, + { "iops_wr", "throttling.iops-write" }, =20 - 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" }, =20 - 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" }, =20 - 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" }, =20 - qemu_opt_rename(all_opts, - "iops_size", "throttling.iops-size"); + { "iops_size", "throttling.iops-size" }, =20 - qemu_opt_rename(all_opts, "readonly", "read-only"); + { "readonly", "read-only" }, + }; + + for (i =3D 0; i < ARRAY_SIZE(opt_renames); i++) { + qemu_opt_rename(all_opts, opt_renames[i].from, opt_renames[i].to= ); + } =20 value =3D qemu_opt_get(all_opts, "cache"); if (value) { --=20 1.8.3.1