From patchwork Thu Jan 2 02:49:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Crosthwaite X-Patchwork-Id: 306038 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 75ECD2C00A2 for ; Thu, 2 Jan 2014 13:50:31 +1100 (EST) Received: from localhost ([::1]:43147 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VyYMe-00078o-HI for incoming@patchwork.ozlabs.org; Wed, 01 Jan 2014 21:50:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58346) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VyYMA-0006y5-1s for qemu-devel@nongnu.org; Wed, 01 Jan 2014 21:50:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VyYM3-0000UD-LW for qemu-devel@nongnu.org; Wed, 01 Jan 2014 21:49:57 -0500 Received: from mail-pd0-f171.google.com ([209.85.192.171]:33264) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VyYM3-0000U3-3A for qemu-devel@nongnu.org; Wed, 01 Jan 2014 21:49:51 -0500 Received: by mail-pd0-f171.google.com with SMTP id z10so13648124pdj.30 for ; Wed, 01 Jan 2014 18:49:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=ZF2eIDxGIBTzNO/M2SmCi9PoY8/7MlT0W8sgFyrQHTs=; b=NDDu1yQojFJ1AIFs6eECQYq6Nxnsw14E8IiEtBMBXUEoGbDNALJuMDcVLWeCxHUMyr ZY9CxwX+9yHjxMKhtSku1MDaEsEsEJabjoqZPGLWMf+bG8T4SXKoxZ2jWoA6gV49VfGA xGnHHualcSx39XYpfhJsE+7iWHknfC5IONTdMGgW9iJ9BAWptWcW+eD5kIvi4rI8yfSB 1b6iOQfNYEQpxjHsXlkYmUbrL6Kmqfz8Yz+QjxXGr7LTa99ULglbA/nAa91TExHgaIRR VA/Fv+Pzv7Gg4wxjZr4Nf7BDnmuUT9CHyARTkyEymgk26oDUtBS0JlJLcRMADPrWfF2H /BmA== X-Gm-Message-State: ALoCoQkeZDAfnuW+nCpD5JNZJz2Ng7G/JFjflvarUDGBRcgUhgftaiDAdn+9ABdA0HnbR/yRJXMh X-Received: by 10.68.236.35 with SMTP id ur3mr84688012pbc.137.1388630990272; Wed, 01 Jan 2014 18:49:50 -0800 (PST) Received: from localhost ([149.199.62.254]) by mx.google.com with ESMTPSA id q7sm97966931pbc.20.2014.01.01.18.49.48 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 01 Jan 2014 18:49:49 -0800 (PST) From: Peter Crosthwaite To: qemu-devel@nongnu.org, lcapitulino@redhat.com Date: Wed, 1 Jan 2014 18:49:17 -0800 Message-Id: <6c7ac24b90e0f03f051c0d5fac15865369889a65.1388630311.git.peter.crosthwaite@xilinx.com> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.192.171 Cc: imammedo@redhat.com, afaerber@suse.de, armbru@redhat.com, pbonzini@redhat.com Subject: [Qemu-devel] [PATCH qmp v4 5/6] qemu-option: Remove qemu_opts_create_nofail X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This is a boiler-plate _nofail variant of qemu_opts_create. Remove and use error_abort in call sites. null/0 arguments needs to be added for the id and fail_if_exists fields in affected callsites due to argument inconsistency between the normal and no_fail variants. Signed-off-by: Peter Crosthwaite Reviewed-by: Markus Armbruster --- changed since v2: Flip fail_if_exists to 0 that were missed in v2 (Markus review) changed since v1: Wrap some long lines (Markus review) Flip fail_if_exists to 0 in call sites (Markus review) Remove spurious whitespace fix (Markus review) Mention fail_if_exists in commit msg (Markus review) block/blkdebug.c | 2 +- block/blkverify.c | 2 +- block/curl.c | 2 +- block/gluster.c | 2 +- block/iscsi.c | 2 +- block/nbd.c | 3 ++- block/qcow2.c | 2 +- block/raw-posix.c | 2 +- block/raw-win32.c | 5 +++-- block/rbd.c | 2 +- block/sheepdog.c | 2 +- block/vvfat.c | 2 +- blockdev.c | 6 ++++-- hw/watchdog/watchdog.c | 3 ++- include/qemu/option.h | 1 - qdev-monitor.c | 2 +- qemu-img.c | 2 +- util/qemu-config.c | 2 +- util/qemu-option.c | 9 --------- util/qemu-sockets.c | 18 +++++++++--------- vl.c | 15 +++++++++------ 21 files changed, 42 insertions(+), 44 deletions(-) diff --git a/block/blkdebug.c b/block/blkdebug.c index 957be2c..ebc5f13 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -359,7 +359,7 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, const char *filename, *config; int ret; - opts = qemu_opts_create_nofail(&runtime_opts); + opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (error_is_set(&local_err)) { error_propagate(errp, local_err); diff --git a/block/blkverify.c b/block/blkverify.c index 3c63528..1c1637f 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -125,7 +125,7 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags, const char *filename, *raw; int ret; - opts = qemu_opts_create_nofail(&runtime_opts); + opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (error_is_set(&local_err)) { error_propagate(errp, local_err); diff --git a/block/curl.c b/block/curl.c index 5a46f97..a603936 100644 --- a/block/curl.c +++ b/block/curl.c @@ -413,7 +413,7 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags, return -EROFS; } - opts = qemu_opts_create_nofail(&runtime_opts); + opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (error_is_set(&local_err)) { qerror_report_err(local_err); diff --git a/block/gluster.c b/block/gluster.c index 877686a..563d497 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -298,7 +298,7 @@ static int qemu_gluster_open(BlockDriverState *bs, QDict *options, Error *local_err = NULL; const char *filename; - opts = qemu_opts_create_nofail(&runtime_opts); + opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (error_is_set(&local_err)) { qerror_report_err(local_err); diff --git a/block/iscsi.c b/block/iscsi.c index fa69408..02eba5d 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -1109,7 +1109,7 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags, return -EINVAL; } - opts = qemu_opts_create_nofail(&runtime_opts); + opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (error_is_set(&local_err)) { qerror_report_err(local_err); diff --git a/block/nbd.c b/block/nbd.c index 4455a13..327e913 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -205,7 +205,8 @@ static int nbd_config(BDRVNBDState *s, QDict *options, char **export) return -EINVAL; } - s->socket_opts = qemu_opts_create_nofail(&socket_optslist); + s->socket_opts = qemu_opts_create(&socket_optslist, NULL, 0, + &error_abort); qemu_opts_absorb_qdict(s->socket_opts, options, &local_err); if (error_is_set(&local_err)) { diff --git a/block/qcow2.c b/block/qcow2.c index f29aa88..8ec9db1 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -669,7 +669,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, } /* Enable lazy_refcounts according to image and command line options */ - opts = qemu_opts_create_nofail(&qcow2_runtime_opts); + opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (error_is_set(&local_err)) { error_propagate(errp, local_err); diff --git a/block/raw-posix.c b/block/raw-posix.c index 10c6b34..0676037 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -287,7 +287,7 @@ static int raw_open_common(BlockDriverState *bs, QDict *options, int fd, ret; struct stat st; - opts = qemu_opts_create_nofail(&raw_runtime_opts); + opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (error_is_set(&local_err)) { error_propagate(errp, local_err); diff --git a/block/raw-win32.c b/block/raw-win32.c index 2bad5a3..ce314fd 100644 --- a/block/raw-win32.c +++ b/block/raw-win32.c @@ -248,7 +248,7 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags, s->type = FTYPE_FILE; - opts = qemu_opts_create_nofail(&raw_runtime_opts); + opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (error_is_set(&local_err)) { error_propagate(errp, local_err); @@ -550,7 +550,8 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags, Error *local_err = NULL; const char *filename; - QemuOpts *opts = qemu_opts_create_nofail(&raw_runtime_opts); + QemuOpts *opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, + &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (error_is_set(&local_err)) { error_propagate(errp, local_err); diff --git a/block/rbd.c b/block/rbd.c index 4a1ea5b..f453f04 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -461,7 +461,7 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict *options, int flags, const char *filename; int r; - opts = qemu_opts_create_nofail(&runtime_opts); + opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (error_is_set(&local_err)) { qerror_report_err(local_err); diff --git a/block/sheepdog.c b/block/sheepdog.c index d1c812d..5ce0658 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -1383,7 +1383,7 @@ static int sd_open(BlockDriverState *bs, QDict *options, int flags, s->bs = bs; - opts = qemu_opts_create_nofail(&runtime_opts); + opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (error_is_set(&local_err)) { qerror_report_err(local_err); diff --git a/block/vvfat.c b/block/vvfat.c index 1abb8ad..664941c 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -1083,7 +1083,7 @@ DLOG(if (stderr == NULL) { setbuf(stderr, NULL); }) - opts = qemu_opts_create_nofail(&runtime_opts); + opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (error_is_set(&local_err)) { qerror_report_err(local_err); diff --git a/blockdev.c b/blockdev.c index 6a85961..1cb6f4c 100644 --- a/blockdev.c +++ b/blockdev.c @@ -682,7 +682,8 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type) bs_opts = qdict_new(); qemu_opts_to_qdict(all_opts, bs_opts); - legacy_opts = qemu_opts_create_nofail(&qemu_legacy_drive_opts); + legacy_opts = qemu_opts_create(&qemu_legacy_drive_opts, NULL, 0, + &error_abort); qemu_opts_absorb_qdict(legacy_opts, bs_opts, &local_err); if (error_is_set(&local_err)) { qerror_report_err(local_err); @@ -853,7 +854,8 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type) if (type == IF_VIRTIO) { QemuOpts *devopts; - devopts = qemu_opts_create_nofail(qemu_find_opts("device")); + devopts = qemu_opts_create(qemu_find_opts("device"), NULL, 0, + &error_abort); if (arch_type == QEMU_ARCH_S390X) { qemu_opt_set(devopts, "driver", "virtio-blk-s390"); } else { diff --git a/hw/watchdog/watchdog.c b/hw/watchdog/watchdog.c index 387962e..f28161b 100644 --- a/hw/watchdog/watchdog.c +++ b/hw/watchdog/watchdog.c @@ -66,7 +66,8 @@ int select_watchdog(const char *p) QLIST_FOREACH(model, &watchdog_list, entry) { if (strcasecmp(model->wdt_name, p) == 0) { /* add the device */ - opts = qemu_opts_create_nofail(qemu_find_opts("device")); + opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0, + &error_abort); qemu_opt_set(opts, "driver", p); return 0; } diff --git a/include/qemu/option.h b/include/qemu/option.h index 5c0c6dd..3ea871a 100644 --- a/include/qemu/option.h +++ b/include/qemu/option.h @@ -136,7 +136,6 @@ int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque, QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id); QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id, int fail_if_exists, Error **errp); -QemuOpts *qemu_opts_create_nofail(QemuOptsList *list); void qemu_opts_reset(QemuOptsList *list); void qemu_opts_loc_restore(QemuOpts *opts); int qemu_opts_set(QemuOptsList *list, const char *id, diff --git a/qdev-monitor.c b/qdev-monitor.c index dc37a43..6280771 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -730,7 +730,7 @@ int qemu_global_option(const char *str) return -1; } - opts = qemu_opts_create_nofail(&qemu_global_opts); + opts = qemu_opts_create(&qemu_global_opts, NULL, 0, &error_abort); qemu_opt_set(opts, "driver", driver); qemu_opt_set(opts, "property", property); qemu_opt_set(opts, "value", str+offset+1); diff --git a/qemu-img.c b/qemu-img.c index a4b3931..c989850 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2564,7 +2564,7 @@ static int img_resize(int argc, char **argv) } /* Parse size */ - param = qemu_opts_create_nofail(&resize_options); + param = qemu_opts_create(&resize_options, NULL, 0, &error_abort); if (qemu_opt_set(param, BLOCK_OPT_SIZE, size)) { /* Error message already printed when size parsing fails */ ret = -1; diff --git a/util/qemu-config.c b/util/qemu-config.c index 04da942..7973659 100644 --- a/util/qemu-config.c +++ b/util/qemu-config.c @@ -311,7 +311,7 @@ int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname) error_free(local_err); goto out; } - opts = qemu_opts_create_nofail(list); + opts = qemu_opts_create(list, NULL, 0, &error_abort); continue; } if (sscanf(line, " %63s = \"%1023[^\"]\"", arg, value) == 2) { diff --git a/util/qemu-option.c b/util/qemu-option.c index efcb5dc..668e5d9 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -791,15 +791,6 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id, return opts; } -QemuOpts *qemu_opts_create_nofail(QemuOptsList *list) -{ - QemuOpts *opts; - Error *errp = NULL; - opts = qemu_opts_create(list, NULL, 0, &errp); - assert_no_error(errp); - return opts; -} - void qemu_opts_reset(QemuOptsList *list) { QemuOpts *opts, *next_opts; diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 6b97dc1..8818d7c 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -578,7 +578,7 @@ int inet_listen(const char *str, char *ostr, int olen, addr = inet_parse(str, errp); if (addr != NULL) { - opts = qemu_opts_create_nofail(&socket_optslist); + opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort); inet_addr_to_opts(opts, addr); qapi_free_InetSocketAddress(addr); sock = inet_listen_opts(opts, port_offset, errp); @@ -617,7 +617,7 @@ int inet_connect(const char *str, Error **errp) addr = inet_parse(str, errp); if (addr != NULL) { - opts = qemu_opts_create_nofail(&socket_optslist); + opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort); inet_addr_to_opts(opts, addr); qapi_free_InetSocketAddress(addr); sock = inet_connect_opts(opts, errp, NULL, NULL); @@ -651,7 +651,7 @@ int inet_nonblocking_connect(const char *str, addr = inet_parse(str, errp); if (addr != NULL) { - opts = qemu_opts_create_nofail(&socket_optslist); + opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort); inet_addr_to_opts(opts, addr); qapi_free_InetSocketAddress(addr); sock = inet_connect_opts(opts, errp, callback, opaque); @@ -794,7 +794,7 @@ int unix_listen(const char *str, char *ostr, int olen, Error **errp) char *path, *optstr; int sock, len; - opts = qemu_opts_create_nofail(&socket_optslist); + opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort); optstr = strchr(str, ','); if (optstr) { @@ -822,7 +822,7 @@ int unix_connect(const char *path, Error **errp) QemuOpts *opts; int sock; - opts = qemu_opts_create_nofail(&socket_optslist); + opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort); qemu_opt_set(opts, "path", path); sock = unix_connect_opts(opts, errp, NULL, NULL); qemu_opts_del(opts); @@ -839,7 +839,7 @@ int unix_nonblocking_connect(const char *path, g_assert(callback != NULL); - opts = qemu_opts_create_nofail(&socket_optslist); + opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort); qemu_opt_set(opts, "path", path); sock = unix_connect_opts(opts, errp, callback, opaque); qemu_opts_del(opts); @@ -889,7 +889,7 @@ int socket_connect(SocketAddress *addr, Error **errp, QemuOpts *opts; int fd; - opts = qemu_opts_create_nofail(&socket_optslist); + opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort); switch (addr->kind) { case SOCKET_ADDRESS_KIND_INET: inet_addr_to_opts(opts, addr->inet); @@ -921,7 +921,7 @@ int socket_listen(SocketAddress *addr, Error **errp) QemuOpts *opts; int fd; - opts = qemu_opts_create_nofail(&socket_optslist); + opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort); switch (addr->kind) { case SOCKET_ADDRESS_KIND_INET: inet_addr_to_opts(opts, addr->inet); @@ -949,7 +949,7 @@ int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp) QemuOpts *opts; int fd; - opts = qemu_opts_create_nofail(&socket_optslist); + opts = qemu_opts_create(&socket_optslist, NULL, 0, &error_abort); switch (remote->kind) { case SOCKET_ADDRESS_KIND_INET: qemu_opt_set(opts, "host", remote->inet->host); diff --git a/vl.c b/vl.c index 7511e70..2082c23 100644 --- a/vl.c +++ b/vl.c @@ -545,7 +545,7 @@ QemuOpts *qemu_get_machine_opts(void) assert(list); opts = qemu_opts_find(list, NULL); if (!opts) { - opts = qemu_opts_create_nofail(list); + opts = qemu_opts_create(list, NULL, 0, &error_abort); } return opts; } @@ -2254,7 +2254,8 @@ static int balloon_parse(const char *arg) return -1; } else { /* create empty opts */ - opts = qemu_opts_create_nofail(qemu_find_opts("device")); + opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0, + &error_abort); } qemu_opt_set(opts, "driver", "virtio-balloon"); return 0; @@ -2514,14 +2515,14 @@ static int virtcon_parse(const char *devname) exit(1); } - bus_opts = qemu_opts_create_nofail(device); + bus_opts = qemu_opts_create(device, NULL, 0, &error_abort); if (arch_type == QEMU_ARCH_S390X) { qemu_opt_set(bus_opts, "driver", "virtio-serial-s390"); } else { qemu_opt_set(bus_opts, "driver", "virtio-serial-pci"); } - dev_opts = qemu_opts_create_nofail(device); + dev_opts = qemu_opts_create(device, NULL, 0, &error_abort); qemu_opt_set(dev_opts, "driver", "virtconsole"); snprintf(label, sizeof(label), "virtcon%d", index); @@ -3380,7 +3381,8 @@ int main(int argc, char **argv, char **envp) qemu_opt_set_bool(fsdev, "readonly", qemu_opt_get_bool(opts, "readonly", 0)); - device = qemu_opts_create_nofail(qemu_find_opts("device")); + device = qemu_opts_create(qemu_find_opts("device"), NULL, 0, + &error_abort); qemu_opt_set(device, "driver", "virtio-9p-pci"); qemu_opt_set(device, "fsdev", qemu_opt_get(opts, "mount_tag")); @@ -3400,7 +3402,8 @@ int main(int argc, char **argv, char **envp) } qemu_opt_set(fsdev, "fsdriver", "synth"); - device = qemu_opts_create_nofail(qemu_find_opts("device")); + device = qemu_opts_create(qemu_find_opts("device"), NULL, 0, + &error_abort); qemu_opt_set(device, "driver", "virtio-9p-pci"); qemu_opt_set(device, "fsdev", "v_synth"); qemu_opt_set(device, "mount_tag", "v_synth");