From nobody Sun Nov 2 11:51:55 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1509116325241125.54699233316273; Fri, 27 Oct 2017 07:58:45 -0700 (PDT) Received: from localhost ([::1]:57713 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e865i-0004ep-7W for importer@patchew.org; Fri, 27 Oct 2017 10:58:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34842) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e85YQ-0001Z0-Jl for qemu-devel@nongnu.org; Fri, 27 Oct 2017 10:24:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e85YP-0002dr-JV for qemu-devel@nongnu.org; Fri, 27 Oct 2017 10:24:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36720) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e85YP-0002cm-AO for qemu-devel@nongnu.org; Fri, 27 Oct 2017 10:24:09 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 62D8E81DF7; Fri, 27 Oct 2017 14:24:08 +0000 (UTC) Received: from localhost (ovpn-116-67.gru2.redhat.com [10.97.116.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 808FD7BAF3; Fri, 27 Oct 2017 14:24:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 62D8E81DF7 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=ehabkost@redhat.com From: Eduardo Habkost To: Peter Maydell Date: Fri, 27 Oct 2017 16:21:06 +0200 Message-Id: <20171027142107.15542-39-ehabkost@redhat.com> In-Reply-To: <20171027142107.15542-1-ehabkost@redhat.com> References: <20171027142107.15542-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 27 Oct 2017 14:24:08 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 38/39] numa: fixup parsed NumaNodeOptions earlier X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Igor Mammedov , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Igor Mammedov numa 'mem' option with suffix or without one is possible only on CLI/HMP. Instead of fixing up special suffix less CLI case deep in parse_numa_node() do it earlier right after option is parsed into NumaNodeOptions with OptVisistor so that the rest of the code would use valid values in NumaNodeOptions and won't have to reparse QemuOpts. It will help to isolate CLI/HMP parts in parse_numa() and split out parsed NumaNodeOptions processing into separate function that could be reused by QMP handler where we have only NumaNodeOptions and don't need any fixups. While at it reuse qemu_strtosz_MiB() instead of manually checking for suffixes. Signed-off-by: Igor Mammedov Message-Id: <1507801198-98182-1-git-send-email-imammedo@redhat.com> Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost --- numa.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/numa.c b/numa.c index 100a67febf..8d78d959f6 100644 --- a/numa.c +++ b/numa.c @@ -38,6 +38,7 @@ #include "hw/mem/pc-dimm.h" #include "qemu/option.h" #include "qemu/config-file.h" +#include "qemu/cutils.h" =20 QemuOptsList qemu_numa_opts =3D { .name =3D "numa", @@ -142,7 +143,7 @@ uint32_t numa_get_node(ram_addr_t addr, Error **errp) } =20 static void parse_numa_node(MachineState *ms, NumaNodeOptions *node, - QemuOpts *opts, Error **errp) + Error **errp) { uint16_t nodenr; uint16List *cpus =3D NULL; @@ -199,13 +200,7 @@ static void parse_numa_node(MachineState *ms, NumaNode= Options *node, } =20 if (node->has_mem) { - uint64_t mem_size =3D node->mem; - const char *mem_str =3D qemu_opt_get(opts, "mem"); - /* Fix up legacy suffix-less format */ - if (g_ascii_isdigit(mem_str[strlen(mem_str) - 1])) { - mem_size <<=3D 20; - } - numa_info[nodenr].node_mem =3D mem_size; + numa_info[nodenr].node_mem =3D node->mem; } if (node->has_memdev) { Object *o; @@ -275,9 +270,15 @@ static int parse_numa(void *opaque, QemuOpts *opts, Er= ror **errp) goto end; } =20 + /* Fix up legacy suffix-less format */ + if ((object->type =3D=3D NUMA_OPTIONS_TYPE_NODE) && object->u.node.has= _mem) { + const char *mem_str =3D qemu_opt_get(opts, "mem"); + qemu_strtosz_MiB(mem_str, NULL, &object->u.node.mem); + } + switch (object->type) { case NUMA_OPTIONS_TYPE_NODE: - parse_numa_node(ms, &object->u.node, opts, &err); + parse_numa_node(ms, &object->u.node, &err); if (err) { goto end; } --=20 2.13.6