From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UzTcm-0002vl-MV for qemu-devel@nongnu.org; Wed, 17 Jul 2013 11:26:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UzTcl-0007iM-6x for qemu-devel@nongnu.org; Wed, 17 Jul 2013 11:26:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59490) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UzTck-0007iF-Vw for qemu-devel@nongnu.org; Wed, 17 Jul 2013 11:26:39 -0400 Message-ID: <51E6B79C.4040909@redhat.com> Date: Wed, 17 Jul 2013 17:26:20 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1374053373-30499-1-git-send-email-gaowanlong@cn.fujitsu.com> <1374053373-30499-2-git-send-email-gaowanlong@cn.fujitsu.com> <51E67368.3000003@redhat.com> <51E68D0F.4040503@redhat.com> <51E6A2D9.5040202@redhat.com> <51E6A826.4010003@redhat.com> <51E6AB34.3090908@redhat.com> <51E6ADC3.5010203@redhat.com> <51E6B73C.4060003@redhat.com> In-Reply-To: <51E6B73C.4060003@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH V5 01/12] NUMA: add NumaOptions, NumaNodeOptions and NumaMemOptions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laszlo Ersek Cc: aliguori@us.ibm.com, ehabkost@redhat.com, peter.huangpeng@huawei.com, qemu-devel@nongnu.org, bsd@redhat.com, y-goto@jp.fujitsu.com, lcapitulino@redhat.com, afaerber@suse.de, Wanlong Gao Il 17/07/2013 17:24, Laszlo Ersek ha scritto: > On 07/17/13 16:44, Paolo Bonzini wrote: >> Il 17/07/2013 16:33, Laszlo Ersek ha scritto: >>>>>>> opts-visitor can handle lists of simple scalar types. Ie. it can do >>>>>>> -numa node,nodeid=3,cpus=3-4,cpus=9-10. It can't save the parsing of >>>>>>> intervals (eg. 3-4). >>>>> >>>>> Saving the parsing of intervals is not necessary for this use case. So >>>>> if we can make it '*cpus':['int'], we should. >>>>> >>>>> But is it the opts-visitor "can handle" lists of integers, or does code >>>>> have to be written? If the latter, can you whip up a prototype? >>> No extra code needs to be written. The current use case is >>> NetdevUserOptions.{dnssearch,hostfwd,guestfwd}; see commit 094f15c5, and >>> (by Klaus Stengel) commit 63d2960b. >> >> This is to handle lists, but want about converting >> >> cpus=3-4,cpus=9-10 >> >> to >> >> 'cpus': [3,4,9,10] > > Oh, that. :) That does need extra code. Something along the lines of: > > (a), in the JSON, reuse the existing String wrapper type, and make > "cpus" an optional list of String[s]: > > { 'type': 'NumaNodeOptions', > 'data': { > '*nodeid': 'uint16', > '*cpus': ['String'] }} > > (b) in the code, traverse the StringList like net_init_slirp_configs() > or slirp_dnssearch() does. Parse each element as an interval, set bit > ranges / report errors. > > static int numa_node_parse_cpu_range(int nodeid, > const char *cpu_range) > { > /* what numa_node_parse_cpus() does in 02/12 */ > } > > static int numa_node_parse(const NumaNodeOptions *opts) > { > const StringList *cpu_range; > > /* not sure how to handle the (!opts->has_nodeid) case; let's > * assume we have a nodeid here */ > > if (opts->nodeid >= MAX_NODES) { > fprintf(stderr, > "NUMA nodeid %d reaches / exceeds maximum %d\n", > opts->nodeid, MAX_NODES); > return -1; > } > > for (cpu_range = opts->cpus; > cpu_range != NULL; > cpu_range = cpu_range->next) { > int ret; > > ret = numa_node_parse_cpu_range(opts->nodeid, > cpu_range->value->str); > if (ret < 0) { > return ret; > } > } > return 0; > } > > Did you mean something like this by prototype? Yes, though I guess Wanlong could do this by himself. A more interesting prototype is "how to add code to OptsVisitor that parses intervals when it sees ['int']", and this where you can help the most. Paolo