From patchwork Sun Oct 14 12:51:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Wang X-Patchwork-Id: 191359 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 2629D2C0097 for ; Mon, 15 Oct 2012 00:19:35 +1100 (EST) Received: from localhost ([::1]:60740 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TNO6P-0004K9-84 for incoming@patchwork.ozlabs.org; Sun, 14 Oct 2012 09:19:33 -0400 Received: from eggs.gnu.org ([208.118.235.92]:36134) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TNNfv-00057Y-Rc for qemu-devel@nongnu.org; Sun, 14 Oct 2012 08:52:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TNNfu-0003Yf-I1 for qemu-devel@nongnu.org; Sun, 14 Oct 2012 08:52:11 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:52257) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TNNfu-0003X4-CF for qemu-devel@nongnu.org; Sun, 14 Oct 2012 08:52:10 -0400 Received: by mail-pb0-f45.google.com with SMTP id rp2so4084857pbb.4 for ; Sun, 14 Oct 2012 05:52:09 -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=IPZ0hg5o13SOs0hwiyTGAJlEFalFqZFRrrQxfFZh56A=; b=Iz/9UOk1rJTenHKb6toqpXT6fJypmwEPRXWpEUfC1jCVNHB6Q9xOa2hIsPFFxUKFIO nlvWTleWg0ChfcWHqVRCKxtkKu7bDxesOfYsxH38MPRCXPQv5bclx5bm/bJoYCAVvwQX DWBEAu9Sw/Wy8rtu6rxGDKpcC9QS44tgbb/RqX9pC82DDbPVvrtruY3Vf5YtAUqsAqfz 64oTqIdLo+tYZTCjkAsi/uHhbgL8bMwCSHogH9cbga6HliIg1lMIe3s02EhGHBZlgqX6 hokobsWzDqnZtgmNc3VbooYOm5jMV2YtaAWzJZVdkFThHOrnjYrcuwcMQn3Vv7QKXciD /bOg== Received: by 10.68.218.226 with SMTP id pj2mr29247800pbc.33.1350219129920; Sun, 14 Oct 2012 05:52:09 -0700 (PDT) Received: from localhost.localdomain ([202.108.130.138]) by mx.google.com with ESMTPS id nt7sm7447649pbb.33.2012.10.14.05.52.06 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 14 Oct 2012 05:52:08 -0700 (PDT) From: Dong Xu Wang To: qemu-devel@nongnu.org Date: Sun, 14 Oct 2012 20:51:30 +0800 Message-Id: <1350219095-3378-6-git-send-email-wdongxu@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1350219095-3378-1-git-send-email-wdongxu@linux.vnet.ibm.com> References: <1350219095-3378-1-git-send-email-wdongxu@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: kwolf@redhat.com, Dong Xu Wang Subject: [Qemu-devel] [PATCH V3 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 +- qemu-config.c | 4 ++-- qemu-img.c | 2 +- qemu-sockets.c | 10 +++++----- vl.c | 12 +++++------- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/blockdev.c b/blockdev.c index 99828ad..1742f40 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/qemu-config.c b/qemu-config.c index cd1ec21..959a350 100644 --- a/qemu-config.c +++ b/qemu-config.c @@ -765,7 +765,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); @@ -852,7 +852,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 f17f187..f1c224e 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -1778,7 +1778,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 2b1ed2f..edee875 100644 --- a/qemu-sockets.c +++ b/qemu-sockets.c @@ -572,7 +572,7 @@ int inet_listen(const char *str, char *ostr, int olen, char *optstr; int sock = -1; - opts = qemu_opts_create(&dummy_opts, NULL, 0, NULL); + opts = qemu_opts_create_nofail(&dummy_opts); if (inet_parse(opts, str) == 0) { sock = inet_listen_opts(opts, port_offset, errp); if (sock != -1 && ostr) { @@ -609,7 +609,7 @@ int inet_connect(const char *str, Error **errp) QemuOpts *opts; int sock = -1; - opts = qemu_opts_create(&dummy_opts, NULL, 0, NULL); + opts = qemu_opts_create_nofail(&dummy_opts); if (inet_parse(opts, str) == 0) { sock = inet_connect_opts(opts, errp, NULL, NULL); } else { @@ -641,7 +641,7 @@ int inet_nonblocking_connect(const char *str, g_assert(callback != NULL); - opts = qemu_opts_create(&dummy_opts, NULL, 0, NULL); + opts = qemu_opts_create_nofail(&dummy_opts); if (inet_parse(opts, str) == 0) { sock = inet_connect_opts(opts, errp, callback, opaque); } else { @@ -737,7 +737,7 @@ int unix_listen(const char *str, char *ostr, int olen) 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) { @@ -765,7 +765,7 @@ int unix_connect(const char *path) 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); qemu_opts_del(opts); diff --git a/vl.c b/vl.c index 5b357a3..062a028 100644 --- a/vl.c +++ b/vl.c @@ -1883,7 +1883,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; @@ -2131,14 +2131,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); @@ -2944,8 +2944,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")); @@ -2965,8 +2964,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");