From patchwork Wed Jan 16 15:24:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 213038 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 3F6122C0087 for ; Thu, 17 Jan 2013 06:40:22 +1100 (EST) Received: from localhost ([::1]:46684 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvWDf-0008Lh-4w for incoming@patchwork.ozlabs.org; Wed, 16 Jan 2013 11:52:07 -0500 Received: from eggs.gnu.org ([208.118.235.92]:48283) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvWCx-0007Xs-Dc for qemu-devel@nongnu.org; Wed, 16 Jan 2013 11:51:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TvWCw-0005wE-9G for qemu-devel@nongnu.org; Wed, 16 Jan 2013 11:51:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57698) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TvWCw-0005w0-0a for qemu-devel@nongnu.org; Wed, 16 Jan 2013 11:51:22 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0GGpJlR024745 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 16 Jan 2013 11:51:19 -0500 Received: from blackpad.lan.raisama.net (vpn1-7-107.gru2.redhat.com [10.97.7.107]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r0GGpIAH030908; Wed, 16 Jan 2013 11:51:19 -0500 Received: by blackpad.lan.raisama.net (Postfix, from userid 500) id B1E81202B60; Wed, 16 Jan 2013 13:24:14 -0200 (BRST) From: Eduardo Habkost To: qemu-devel@nongnu.org, Anthony Liguori Date: Wed, 16 Jan 2013 13:24:10 -0200 Message-Id: <1358349851-20960-8-git-send-email-ehabkost@redhat.com> In-Reply-To: <1358349851-20960-1-git-send-email-ehabkost@redhat.com> References: <1358349851-20960-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Chegu Vinod Subject: [Qemu-devel] [PATCH 7/8] vl.c: Extract -numa "cpus" parsing to separate function 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 This will make it easier to refactor that code later. Signed-off-by: Eduardo Habkost --- Changes v2: - Implemented change without creation of numa_node_add() function --- vl.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/vl.c b/vl.c index 43ce607..98cf9f0 100644 --- a/vl.c +++ b/vl.c @@ -1241,15 +1241,34 @@ char *get_boot_devices_list(uint32_t *size) return list; } +static void numa_node_parse_cpus(int nodenr, const char *cpus) +{ + char *endptr; + unsigned long long value, endvalue; + + value = strtoull(cpus, &endptr, 10); + if (*endptr == '-') { + endvalue = strtoull(endptr+1, &endptr, 10); + } else { + endvalue = value; + } + + if (!(endvalue < MAX_CPUMASK_BITS)) { + endvalue = MAX_CPUMASK_BITS - 1; + fprintf(stderr, + "A max of %d CPUs are supported in a guest\n", + MAX_CPUMASK_BITS); + } + + bitmap_set(node_cpumask[nodenr], value, endvalue-value+1); +} + static void numa_add(const char *optarg) { char option[128]; char *endptr; - unsigned long long value, endvalue; unsigned long long nodenr; - value = endvalue = 0ULL; - optarg = get_opt_name(option, 128, optarg, ','); if (*optarg == ',') { optarg++; @@ -1287,21 +1306,7 @@ static void numa_add(const char *optarg) node_mem[nodenr] = sval; } if (get_param_value(option, 128, "cpus", optarg) != 0) { - value = strtoull(option, &endptr, 10); - if (*endptr == '-') { - endvalue = strtoull(endptr+1, &endptr, 10); - } else { - endvalue = value; - } - - if (!(endvalue < MAX_CPUMASK_BITS)) { - endvalue = MAX_CPUMASK_BITS - 1; - fprintf(stderr, - "A max of %d CPUs are supported in a guest\n", - MAX_CPUMASK_BITS); - } - - bitmap_set(node_cpumask[nodenr], value, endvalue-value+1); + numa_node_parse_cpus(nodenr, option); } nb_numa_nodes++; } else {