From patchwork Thu Nov 1 09:12:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Wang X-Patchwork-Id: 196108 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 95DBD2C0388 for ; Thu, 1 Nov 2012 20:39:27 +1100 (EST) Received: from localhost ([::1]:50698 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTqqL-0000LH-LT for incoming@patchwork.ozlabs.org; Thu, 01 Nov 2012 05:13:41 -0400 Received: from eggs.gnu.org ([208.118.235.92]:52268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTqpl-0007Z5-4q for qemu-devel@nongnu.org; Thu, 01 Nov 2012 05:13:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TTqph-0000Yq-Ca for qemu-devel@nongnu.org; Thu, 01 Nov 2012 05:13:05 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:56709) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTqpf-0000WK-Uk for qemu-devel@nongnu.org; Thu, 01 Nov 2012 05:13:01 -0400 Received: by mail-pa0-f45.google.com with SMTP id fb10so1545080pad.4 for ; Thu, 01 Nov 2012 02:12:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=8ssvmxwF99ui3sLGZtcW1EzxnUAQk/97+O8cyU781uE=; b=NsYxjf+BLD0GWzXoawiDP8Ao0JqIFQfexURvrnVMnPc9nJd/Me2He9kWsaOOexoNm3 TlmuzAeLnpE+t2vxvNZh6FKx+xTbeeO9f3BPFpiUekHJl3zVpeV6LejuTzZbeIiLpGcH c4J2lzaQdTACwt/RO9TFDcEBtXLHCbTb3okn78983Mk/H+A2X3bqXT3nmx0HTt1+InDB Gy98onReF80BAEuRTrkyfn1BHZ+ntI8jO0CaMOnkwpEyfZRpUOuA9/VTNIJWVb71N796 O4sLzKVhC0DA4GSAbA2sS3LGLb0x6MGEeQNWBT0719ThaHhjQ9Tiz/eV3YZwTp/mK3fR 17QQ== Received: by 10.66.87.132 with SMTP id ay4mr79237045pab.67.1351761177243; Thu, 01 Nov 2012 02:12:57 -0700 (PDT) Received: from localhost.localdomain ([202.108.130.138]) by mx.google.com with ESMTPS id o11sm3751238pby.8.2012.11.01.02.12.54 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 01 Nov 2012 02:12:56 -0700 (PDT) From: Dong Xu Wang To: qemu-devel@nongnu.org Date: Thu, 1 Nov 2012 17:12:25 +0800 Message-Id: <1351761150-20705-6-git-send-email-wdongxu@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1351761150-20705-1-git-send-email-wdongxu@linux.vnet.ibm.com> References: <1351761150-20705-1-git-send-email-wdongxu@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.220.45 Cc: kwolf@redhat.com, Dong Xu Wang Subject: [Qemu-devel] [PATCH V5 05/10] use 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 We will use qemu_opts_create_nofail function, it can make code more readable. Signed-off-by: Dong Xu Wang --- blockdev.c | 2 +- hw/watchdog.c | 2 +- qemu-config.c | 4 ++-- qemu-img.c | 2 +- qemu-sockets.c | 16 ++++++++-------- vl.c | 12 +++++------- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/blockdev.c b/blockdev.c index a068a4b..d3e22b0 100644 --- a/blockdev.c +++ b/blockdev.c @@ -562,7 +562,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) break; case IF_VIRTIO: /* add virtio block device */ - opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0, NULL); + opts = qemu_opts_create_nofail(qemu_find_opts("device")); if (arch_type == QEMU_ARCH_S390X) { qemu_opt_set(opts, "driver", "virtio-blk-s390"); } else { diff --git a/hw/watchdog.c b/hw/watchdog.c index b52aced..5c82c17 100644 --- a/hw/watchdog.c +++ b/hw/watchdog.c @@ -66,7 +66,7 @@ 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(qemu_find_opts("device"), NULL, 0, NULL); + opts = qemu_opts_create_nofail(qemu_find_opts("device")); qemu_opt_set(opts, "driver", p); return 0; } diff --git a/qemu-config.c b/qemu-config.c index e854fff..43c7c07 100644 --- a/qemu-config.c +++ b/qemu-config.c @@ -791,7 +791,7 @@ int qemu_global_option(const char *str) return -1; } - opts = qemu_opts_create(&qemu_global_opts, NULL, 0, NULL); + opts = qemu_opts_create_nofail(&qemu_global_opts); qemu_opt_set(opts, "driver", driver); qemu_opt_set(opts, "property", property); qemu_opt_set(opts, "value", str+offset+1); @@ -878,7 +878,7 @@ int qemu_config_parse(FILE *fp, QemuOptsList **lists, const char *fname) error_free(local_err); goto out; } - opts = qemu_opts_create(list, NULL, 0, NULL); + opts = qemu_opts_create_nofail(list); continue; } if (sscanf(line, " %63s = \"%1023[^\"]\"", arg, value) == 2) { diff --git a/qemu-img.c b/qemu-img.c index b17bddd..590df1e 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -1933,7 +1933,7 @@ static int img_resize(int argc, char **argv) } /* Parse size */ - param = qemu_opts_create(&resize_options, NULL, 0, NULL); + param = qemu_opts_create_nofail(&resize_options); if (qemu_opt_set(param, BLOCK_OPT_SIZE, size)) { /* Error message already printed when size parsing fails */ ret = -1; diff --git a/qemu-sockets.c b/qemu-sockets.c index cfed9c5..0b2d465 100644 --- a/qemu-sockets.c +++ b/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(&dummy_opts, NULL, 0, NULL); + opts = qemu_opts_create_nofail(&dummy_opts); 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(&dummy_opts, NULL, 0, NULL); + opts = qemu_opts_create_nofail(&dummy_opts); 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(&dummy_opts, NULL, 0, NULL); + opts = qemu_opts_create_nofail(&dummy_opts); 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(&dummy_opts, NULL, 0, NULL); + opts = qemu_opts_create_nofail(&dummy_opts); 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(&dummy_opts, NULL, 0, NULL); + opts = qemu_opts_create_nofail(&dummy_opts); 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(&dummy_opts, NULL, 0, NULL); + opts = qemu_opts_create_nofail(&dummy_opts); qemu_opt_set(opts, "path", path); sock = unix_connect_opts(opts, errp, callback, opaque); qemu_opts_del(opts); @@ -890,7 +890,7 @@ int socket_connect(SocketAddress *addr, Error **errp, QemuOpts *opts; int fd; - opts = qemu_opts_create(&dummy_opts, NULL, 0, NULL); + opts = qemu_opts_create_nofail(&dummy_opts); 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(&dummy_opts, NULL, 0, NULL); + opts = qemu_opts_create_nofail(&dummy_opts); switch (addr->kind) { case SOCKET_ADDRESS_KIND_INET: inet_addr_to_opts(opts, addr->inet); diff --git a/vl.c b/vl.c index 5513d15..dd78583 100644 --- a/vl.c +++ b/vl.c @@ -1967,7 +1967,7 @@ static int balloon_parse(const char *arg) return -1; } else { /* create empty opts */ - opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0, NULL); + opts = qemu_opts_create_nofail(qemu_find_opts("device")); } qemu_opt_set(opts, "driver", "virtio-balloon"); return 0; @@ -2215,14 +2215,14 @@ static int virtcon_parse(const char *devname) exit(1); } - bus_opts = qemu_opts_create(device, NULL, 0, NULL); + bus_opts = qemu_opts_create_nofail(device); 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(device, NULL, 0, NULL); + dev_opts = qemu_opts_create_nofail(device); qemu_opt_set(dev_opts, "driver", "virtconsole"); snprintf(label, sizeof(label), "virtcon%d", index); @@ -3028,8 +3028,7 @@ 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(qemu_find_opts("device"), NULL, 0, - NULL); + device = qemu_opts_create_nofail(qemu_find_opts("device")); qemu_opt_set(device, "driver", "virtio-9p-pci"); qemu_opt_set(device, "fsdev", qemu_opt_get(opts, "mount_tag")); @@ -3049,8 +3048,7 @@ int main(int argc, char **argv, char **envp) } qemu_opt_set(fsdev, "fsdriver", "synth"); - device = qemu_opts_create(qemu_find_opts("device"), NULL, 0, - NULL); + device = qemu_opts_create_nofail(qemu_find_opts("device")); qemu_opt_set(device, "driver", "virtio-9p-pci"); qemu_opt_set(device, "fsdev", "v_synth"); qemu_opt_set(device, "mount_tag", "v_synth");