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: 140060 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 12AEBB6F99 for ; Wed, 8 Feb 2012 16:41:56 +1100 (EST) Received: from localhost ([::1]:34931 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rv0Hw-0004iK-PN for incoming@patchwork.ozlabs.org; Wed, 08 Feb 2012 00:41:52 -0500 Received: from eggs.gnu.org ([140.186.70.92]:36457) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rv0Hr-0004iF-2v for qemu-devel@nongnu.org; Wed, 08 Feb 2012 00:41:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rv0Hp-00047z-Mk for qemu-devel@nongnu.org; Wed, 08 Feb 2012 00:41:47 -0500 Received: from mnementh.archaic.org.uk ([81.2.115.146]:53974) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rv0Hp-00047s-Dt for qemu-devel@nongnu.org; Wed, 08 Feb 2012 00:41:45 -0500 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 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> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 81.2.115.146 Cc: Grant Likely , Anthony Liguori , Alexander Graf , patches@linaro.org Subject: [Qemu-devel] [PATCH 1/4] qemu-option: Add support for merged QemuOptsLists 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 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[]; };