From patchwork Wed Feb 27 15:42:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 223640 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 854452C007A for ; Thu, 28 Feb 2013 02:43:25 +1100 (EST) Received: from localhost ([::1]:56344 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAjAB-0003Fx-PK for incoming@patchwork.ozlabs.org; Wed, 27 Feb 2013 10:43:23 -0500 Received: from eggs.gnu.org ([208.118.235.92]:41498) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAj9s-0003Fn-8h for qemu-devel@nongnu.org; Wed, 27 Feb 2013 10:43:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UAj9q-0006Jt-K8 for qemu-devel@nongnu.org; Wed, 27 Feb 2013 10:43:04 -0500 Received: from e23smtp01.au.ibm.com ([202.81.31.143]:40690) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UAj9q-0006JX-30 for qemu-devel@nongnu.org; Wed, 27 Feb 2013 10:43:02 -0500 Received: from /spool/local by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 28 Feb 2013 01:37:10 +1000 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp01.au.ibm.com (202.81.31.207) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 28 Feb 2013 01:37:07 +1000 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [9.190.235.152]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 12C2D3578023 for ; Thu, 28 Feb 2013 02:42:57 +1100 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r1RFUJtP10813794 for ; Thu, 28 Feb 2013 02:30:19 +1100 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r1RFgumf023104 for ; Thu, 28 Feb 2013 02:42:56 +1100 Received: from titi.na.relay.ibm.com (sig-9-76-204-204.mts.ibm.com [9.76.204.204]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r1RFgp0w023060; Thu, 28 Feb 2013 02:42:53 +1100 From: Anthony Liguori To: Paolo Bonzini In-Reply-To: <512D1903.2070309@redhat.com> References: <1361483057-20503-1-git-send-email-ehabkost@redhat.com> <87d2vntkm7.fsf@blackfin.pond.sub.org> <20130226140559.GX8494@otherpad.lan.raisama.net> <87sj4iamx9.fsf@codemonkey.ws> <512D1903.2070309@redhat.com> User-Agent: Notmuch/0.13.2+93~ged93d79 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) Date: Wed, 27 Feb 2013 09:42:50 -0600 Message-ID: <874ngxhif9.fsf@codemonkey.ws> MIME-Version: 1.0 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13022715-1618-0000-0000-00000369A1CB X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 202.81.31.143 Cc: libvir-list@redhat.com, qemu-devel@nongnu.org, Chegu Vinod , Eduardo Habkost , Markus Armbruster Subject: Re: [Qemu-devel] [PATCH v2] vl.c: Support multiple CPU ranges on -numa option 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 Paolo Bonzini writes: > Il 26/02/2013 20:35, Anthony Liguori ha scritto: >>>> >> >>>> >> See also discussion on multi-valued keys in command line option >>>> >> arguments and config files in v1 thread. Hopefully we can reach a >>>> >> conclusion soon, and then we'll see whether this patch is what we want. >>> > >>> > Yeah, let's drop this patch by now. I am starting to be convinced that >>> > "cpus=A,cpus=B,cpus=C" is the best approach. It is not pretty, but at >>> > least it uses generic parser code instead of yet another ad-hoc >>> > parser. >> No, we cannot rely on this behavior. We had to do it to support >> backwards compat with netdev but it should not be used anywhere else. > > We chose a config format (git's) because it was a good match for > QemuOpts, and multiple-valued operations are well supported by that > config format; see git-config(1). There is no reason to consider it a > backwards-compatibility hack. There's such thing as list support in QemuOpts. The only way QemuOptsVisitor was able to implement it was to expose QemuOpts publicly via options_int.h and rely on a implementation detail. There are fixed types supported by QemuOpts. It just so happens that whenever qemu_opt_set() is called, instead of replacing the last instance, the value is either prepended or appended in order to implement a replace or set-if-unset behavior. All values are treated this way. So the above "list" would only be: { .name = "cpus", .type = QEMU_OPT_STRING } Which is indistinguishable from a straight string property. This means it's impossible to introspect because the type is context-sensitive. What's more, there is no API outside of QemuOptsVisitor that can actually work with "lists" of QemuOpts values. If we want to have list syntax, we need to introduce first class support for it. Here's a simple example of how to do this. Obviously we would want to introduce some better error checking so we can catch if someone tries to access a list with a non-list accessor. We also would need list accessor functions. But it's really not hard at all. (Only compile tested) Regards, Anthony Liguori > > Paolo From 4ee7ed36d597f0defd78baac7480ecb29e11e1c1 Mon Sep 17 00:00:00 2001 From: Anthony Liguori Date: Wed, 27 Feb 2013 09:32:09 -0600 Subject: [PATCH] qemu-opts: support lists Signed-off-by: Anthony Liguori --- include/qemu/option.h | 2 ++ util/qemu-option.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/qemu/option.h b/include/qemu/option.h index ba197cd..e4808c3 100644 --- a/include/qemu/option.h +++ b/include/qemu/option.h @@ -41,6 +41,7 @@ enum QEMUOptionParType { typedef struct QEMUOptionParameter { const char *name; enum QEMUOptionParType type; + bool list; union { uint64_t n; char* s; @@ -95,6 +96,7 @@ enum QemuOptType { typedef struct QemuOptDesc { const char *name; enum QemuOptType type; + bool list; const char *help; } QemuOptDesc; diff --git a/util/qemu-option.c b/util/qemu-option.c index 5a1d03c..6b1ae6e 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -636,6 +636,18 @@ static void opt_set(QemuOpts *opts, const char *name, const char *value, return; } + if (desc->list && strchr(value, ':')) { + gchar **tokens = g_strsplit(value, ":", 0); + int i; + for (i = 0; tokens[i]; i++) { + opt_set(opts, name, tokens[i], prepend, errp); + if (error_is_set(errp)) { + return; + } + } + g_strfreev(tokens); + } + opt = g_malloc0(sizeof(*opt)); opt->name = g_strdup(name); opt->opts = opts; -- 1.8.0