From patchwork Wed Feb 8 05:41:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 6705 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 2348923EAA for ; Wed, 8 Feb 2012 05:41:49 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id DBF08A180AD for ; Wed, 8 Feb 2012 05:41:48 +0000 (UTC) Received: by iabz7 with SMTP id z7so480248iab.11 for ; Tue, 07 Feb 2012 21:41:48 -0800 (PST) Received: by 10.50.15.231 with SMTP id a7mr30623393igd.8.1328679708315; Tue, 07 Feb 2012 21:41:48 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.169.210 with SMTP id a18cs5059ibz; Tue, 7 Feb 2012 21:41:47 -0800 (PST) Received: by 10.204.152.88 with SMTP id f24mr11382242bkw.31.1328679705688; Tue, 07 Feb 2012 21:41:45 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [81.2.115.146]) by mx.google.com with ESMTPS id ho9si273253bkc.19.2012.02.07.21.41.44 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 07 Feb 2012 21:41:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) client-ip=81.2.115.146; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1Rv0Hk-00084i-Us; Wed, 08 Feb 2012 05:41:40 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Grant Likely , Anthony Liguori , Alexander Graf Subject: [PATCH 1/4] qemu-option: Add support for merged QemuOptsLists Date: Wed, 8 Feb 2012 05:41:37 +0000 Message-Id: <1328679700-31015-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1328679700-31015-1-git-send-email-peter.maydell@linaro.org> References: <1328679700-31015-1-git-send-email-peter.maydell@linaro.org> Add support for option lists which are merged together, so that "-listname foo=bar -listname bar=baz" is equivalent to "-listname foo=bar,bar=baz" rather than generating two separate lists of options. Signed-off-by: Peter Maydell --- qemu-option.c | 7 ++++++- qemu-option.h | 1 + 2 files changed, 7 insertions(+), 1 deletions(-) diff --git a/qemu-option.c b/qemu-option.c index 4626ccf..35cd609 100644 --- a/qemu-option.c +++ b/qemu-option.c @@ -741,13 +741,18 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id, int fail_if_exist } opts = qemu_opts_find(list, id); if (opts != NULL) { - if (fail_if_exists) { + if (fail_if_exists && !list->merge_lists) { qerror_report(QERR_DUPLICATE_ID, id, list->name); return NULL; } else { return opts; } } + } else if (list->merge_lists) { + opts = qemu_opts_find(list, NULL); + if (opts) { + return opts; + } } opts = g_malloc0(sizeof(*opts)); if (id) { diff --git a/qemu-option.h b/qemu-option.h index e6f61e6..3ca00c3 100644 --- a/qemu-option.h +++ b/qemu-option.h @@ -100,6 +100,7 @@ typedef struct QemuOptDesc { struct QemuOptsList { const char *name; const char *implied_opt_name; + bool merge_lists; /* Merge multiple uses of option into a single list? */ QTAILQ_HEAD(, QemuOpts) head; QemuOptDesc desc[]; };