From nobody Sat Apr 20 15:07:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593006572; cv=none; d=zohomail.com; s=zohoarc; b=loxk0+fqFqn3ZPFW2IsKL29+QpoWmWqf1WxDgN7CaojwYC8QOGXeN/OfrQukYOUx9Z3VawoK3zvjuFRRzMzuT6013RFyj5eqwQGK9y92CMSk9IG4wEfIl/oQTTKJ9BFcl+uNCL5UrNJGD2bVbZsjN5MSp1CbjcmuXxjKPQeNoJo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593006572; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=39+NeOCgVhKs7GnVwnQN+/+uakF4J9xg/gjz8g3Ias4=; b=AU1ZEYYVDa+eC4FZXi44lhmc1AkMiBFjskk5Ask6lpdbwNMKjQjbGrKaePv1IiwTPB4koC7t7VSsU8Q7D2gOEy/Hz5YOaqBI3CEhJjC2o1FI80HL3iAPvq0zJa+7u1sfCHg65xSSlswUrwjj5DPVkLikUugGaKX7bXJzbhAr0yY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1593006572550821.6956750391398; Wed, 24 Jun 2020 06:49:32 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-453-K67KBA-GMwSADw5YwOYe7g-1; Wed, 24 Jun 2020 09:49:29 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7667218FE861; Wed, 24 Jun 2020 13:49:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7428971660; Wed, 24 Jun 2020 13:49:22 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A0BAC1809547; Wed, 24 Jun 2020 13:49:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05ODnHiS015635 for ; Wed, 24 Jun 2020 09:49:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9B7EA5DA27; Wed, 24 Jun 2020 13:49:17 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D5C25D9DC for ; Wed, 24 Jun 2020 13:49:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593006571; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=39+NeOCgVhKs7GnVwnQN+/+uakF4J9xg/gjz8g3Ias4=; b=GYQQWFb59eV25zpXcgFWvr3mVggWr1xBu9/cW1BNV355JAWsKWDmN+J/SUFedPVkamc278 Dk3QntFP/P6QRzfhtmp4HAyLnAIe+4egmlwBNYAhfW4lp3zNBrsN/WjxJc3Sdte0jD+Y2r hx6iahEjA7DeUvmj0/LbSUwj8aFwR1Q= X-MC-Unique: K67KBA-GMwSADw5YwOYe7g-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 01/13] qemuxml2xmltest: Add "numatune-distance" test case Date: Wed, 24 Jun 2020 15:48:59 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This test case tests that expanding of NUMA distances work. On input we accept if only distance from A to B is specified. On the output we format the B to A distance too. Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- .../qemuxml2xmloutdata/numatune-distances.xml | 96 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 2 files changed, 97 insertions(+) create mode 100644 tests/qemuxml2xmloutdata/numatune-distances.xml diff --git a/tests/qemuxml2xmloutdata/numatune-distances.xml b/tests/qemuxm= l2xmloutdata/numatune-distances.xml new file mode 100644 index 0000000000..48f89cb015 --- /dev/null +++ b/tests/qemuxml2xmloutdata/numatune-distances.xml @@ -0,0 +1,96 @@ + + QEMUGuest + c7a5fdb2-cdaf-9455-926a-d65c16db1809 + 8388608 + 8388608 + 12 + + hvm + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + destroy + restart + restart + + /usr/bin/qemu-system-x86_64 + +
+ + + + + +
+ + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 5a124853b4..d203c97e36 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1104,6 +1104,7 @@ mymain(void) DO_TEST("numatune-auto-prefer", NONE); DO_TEST("numatune-memnode", QEMU_CAPS_NUMA, QEMU_CAPS_OBJECT_MEMORY_FI= LE); DO_TEST("numatune-memnode-no-memory", QEMU_CAPS_OBJECT_MEMORY_FILE); + DO_TEST("numatune-distances", QEMU_CAPS_NUMA, QEMU_CAPS_NUMA_DIST); =20 DO_TEST("bios-nvram", NONE); DO_TEST("bios-nvram-os-interleave", NONE); --=20 2.26.2 From nobody Sat Apr 20 15:07:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593006572; cv=none; d=zohomail.com; s=zohoarc; b=bB0iXhGPi8U6h7KJ0VJJgnLOQx3yb3AG6Zm5H4K+eHDFi1OoAnjMn/t4OBbOLWwJRpHg5eJrpXsf/09VU7E4GM3+BroRUHO7oB4BJ0lJWrWi2xBrLPHn/isE+jH4vkEFpUjT0BO1o9jxiULMB+t66rh8J2DMg1QiW6yCpMogJWs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593006572; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kIKcgoYXb3JLfc1M7uN0PyjSUO/9nON2TdvbcvpzND4=; b=ZOhaQw5bhjT+Pz4C0I9EpO3SErhFCJSX+cDG2MASySZr+Uk4xu+nfckVTZUR6HOv64mrYhtnI28JsLypF7SSLMjLVF3rQen/qwK/a7LwmLtNSPH1+ivgsUfLsvTK7jA8IOPVn+R64TnBfOTUjL6ry109Lz70Xdatuf4+zaUsJjo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1593006572653485.08195685135956; Wed, 24 Jun 2020 06:49:32 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-402-dLSIFOx8M1Kz-Wibf6g08A-1; Wed, 24 Jun 2020 09:49:28 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2EB3E804003; Wed, 24 Jun 2020 13:49:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C61165C541; Wed, 24 Jun 2020 13:49:22 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 776F61048FD; Wed, 24 Jun 2020 13:49:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05ODnII3015643 for ; Wed, 24 Jun 2020 09:49:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 78E975DA27; Wed, 24 Jun 2020 13:49:18 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE2105D9DC for ; Wed, 24 Jun 2020 13:49:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593006571; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=kIKcgoYXb3JLfc1M7uN0PyjSUO/9nON2TdvbcvpzND4=; b=CHzyRLdDAZrTwvrGrosH11dI/Zh9Obs8B1gPROstM7uO67xYQ9W+vFbvZFb+ntt06ni2Yo eBqPLWW0j8Bvh1jN+TCy+AEMaejb6610CmoFoWIrHxESZp+keFyrxhj2z+5osDCgCwkODZ KezBRHpOqGm67/eS+Z0yPaNhXMQH61U= X-MC-Unique: dLSIFOx8M1Kz-Wibf6g08A-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 02/13] conf: Move and rename virDomainParseScaledValue() Date: Wed, 24 Jun 2020 15:49:00 +0200 Message-Id: <609934c6984da0ff1ee9ae136a5d77a1341777f3.1593006346.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" There is nothing domain specific about the function, thus it should not have virDomain prefix. Also, the fact that it is a static function makes it impossible to use from other files. Move the function to virxml.c and drop the 'Domain' infix. Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 135 ++++++++++----------------------------- src/libvirt_private.syms | 1 + src/util/virxml.c | 72 +++++++++++++++++++++ src/util/virxml.h | 8 +++ 4 files changed, 114 insertions(+), 102 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index fc7fcfb0c6..65a110b16f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10808,75 +10808,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xml= opt, goto cleanup; } =20 -/** - * virDomainParseScaledValue: - * @xpath: XPath to memory amount - * @units_xpath: XPath to units attribute - * @ctxt: XPath context - * @val: scaled value is stored here - * @scale: default scale for @val - * @max: maximal @val allowed - * @required: is the value required? - * - * Parse a value located at @xpath within @ctxt, and store the - * result into @val. The value is scaled by units located at - * @units_xpath (or the 'unit' attribute under @xpath if - * @units_xpath is NULL). If units are not present, the default - * @scale is used. If @required is set, then the value must - * exist; otherwise, the value is optional. The resulting value - * is in bytes. - * - * Returns 1 on success, - * 0 if the value was not present and !@required, - * -1 on failure after issuing error. - */ -static int -virDomainParseScaledValue(const char *xpath, - const char *units_xpath, - xmlXPathContextPtr ctxt, - unsigned long long *val, - unsigned long long scale, - unsigned long long max, - bool required) -{ - unsigned long long bytes; - g_autofree char *xpath_full =3D NULL; - g_autofree char *unit =3D NULL; - g_autofree char *bytes_str =3D NULL; - - *val =3D 0; - xpath_full =3D g_strdup_printf("string(%s)", xpath); - - bytes_str =3D virXPathString(xpath_full, ctxt); - if (!bytes_str) { - if (!required) - return 0; - virReportError(VIR_ERR_XML_ERROR, - _("missing element or attribute '%s'"), - xpath); - return -1; - } - VIR_FREE(xpath_full); - - if (virStrToLong_ullp(bytes_str, NULL, 10, &bytes) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Invalid value '%s' for element or attribute '%s'= "), - bytes_str, xpath); - return -1; - } - - if (units_xpath) - xpath_full =3D g_strdup_printf("string(%s)", units_xpath); - else - xpath_full =3D g_strdup_printf("string(%s/@unit)", xpath); - unit =3D virXPathString(xpath_full, ctxt); - - if (virScaleInteger(&bytes, unit, scale, max) < 0) - return -1; - - *val =3D bytes; - return 1; -} =20 =20 /** @@ -10913,8 +10844,8 @@ virDomainParseMemory(const char *xpath, =20 max =3D virMemoryMaxValue(capped); =20 - if (virDomainParseScaledValue(xpath, units_xpath, ctxt, - &bytes, 1024, max, required) < 0) + if (virParseScaledValue(xpath, units_xpath, ctxt, + &bytes, 1024, max, required) < 0) return -1; =20 /* Yes, we really do use kibibytes for our internal sizing. */ @@ -10956,9 +10887,9 @@ virDomainParseMemoryLimit(const char *xpath, int ret; unsigned long long bytes; =20 - ret =3D virDomainParseScaledValue(xpath, units_xpath, ctxt, &bytes, 10= 24, - VIR_DOMAIN_MEMORY_PARAM_UNLIMITED << 1= 0, - false); + ret =3D virParseScaledValue(xpath, units_xpath, ctxt, &bytes, 1024, + VIR_DOMAIN_MEMORY_PARAM_UNLIMITED << 10, + false); =20 if (ret < 0) return -1; @@ -11286,9 +11217,9 @@ virDomainControllerDefParseXML(virDomainXMLOptionPt= r xmlopt, "have an address")); goto error; } - if ((rc =3D virDomainParseScaledValue("./pcihole64", NULL, - ctxt, &bytes, 1024, - 1024ULL * ULONG_MAX, false= )) < 0) + if ((rc =3D virParseScaledValue("./pcihole64", NULL, + ctxt, &bytes, 1024, + 1024ULL * ULONG_MAX, false)) < 0) goto error; =20 if (rc =3D=3D 1) @@ -11529,14 +11460,14 @@ virDomainFSDefParseXML(virDomainXMLOptionPtr xmlo= pt, def->multidevs =3D VIR_DOMAIN_FS_MULTIDEVS_DEFAULT; } =20 - if (virDomainParseScaledValue("./space_hard_limit[1]", - NULL, ctxt, &def->space_hard_limit, - 1, ULLONG_MAX, false) < 0) + if (virParseScaledValue("./space_hard_limit[1]", + NULL, ctxt, &def->space_hard_limit, + 1, ULLONG_MAX, false) < 0) goto error; =20 - if (virDomainParseScaledValue("./space_soft_limit[1]", - NULL, ctxt, &def->space_soft_limit, - 1, ULLONG_MAX, false) < 0) + if (virParseScaledValue("./space_soft_limit[1]", + NULL, ctxt, &def->space_soft_limit, + 1, ULLONG_MAX, false) < 0) goto error; =20 cur =3D node->children; @@ -15388,8 +15319,8 @@ virDomainShmemDefParseXML(virDomainXMLOptionPtr xml= opt, goto cleanup; } =20 - if (virDomainParseScaledValue("./size[1]", NULL, ctxt, - &def->size, 1, ULLONG_MAX, false) < 0) + if (virParseScaledValue("./size[1]", NULL, ctxt, + &def->size, 1, ULLONG_MAX, false) < 0) goto cleanup; =20 if ((server =3D virXPathNode("./server[1]", ctxt))) { @@ -19432,13 +19363,13 @@ virDomainFeaturesDefParse(virDomainDefPtr def, VIR_FREE(tmp); } =20 - if (virDomainParseScaledValue("./features/hpt/maxpagesize", - NULL, - ctxt, - &def->hpt_maxpagesize, - 1024, - ULLONG_MAX, - false) < 0) { + if (virParseScaledValue("./features/hpt/maxpagesize", + NULL, + ctxt, + &def->hpt_maxpagesize, + 1024, + ULLONG_MAX, + false) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Unable to parse HPT maxpagesize setting"= )); @@ -19782,13 +19713,13 @@ virDomainFeaturesDefParse(virDomainDefPtr def, } =20 if (def->features[VIR_DOMAIN_FEATURE_SMM] =3D=3D VIR_TRISTATE_SWITCH_O= N) { - int rv =3D virDomainParseScaledValue("string(./features/smm/tseg)", - "string(./features/smm/tseg/@un= it)", - ctxt, - &def->tseg_size, - 1024 * 1024, /* Defaults to meb= ibytes */ - ULLONG_MAX, - false); + int rv =3D virParseScaledValue("string(./features/smm/tseg)", + "string(./features/smm/tseg/@unit)", + ctxt, + &def->tseg_size, + 1024 * 1024, /* Defaults to mebibytes= */ + ULLONG_MAX, + false); if (rv < 0) goto error; def->tseg_specified =3D rv; @@ -20510,9 +20441,9 @@ virDomainCachetuneDefParseCache(xmlXPathContextPtr = ctxt, return -1; } =20 - if (virDomainParseScaledValue("./@size", "./@unit", - ctxt, &size, 1024, - ULLONG_MAX, true) < 0) + if (virParseScaledValue("./@size", "./@unit", + ctxt, &size, 1024, + ULLONG_MAX, true) < 0) return -1; =20 if (virResctrlAllocSetCacheSize(alloc, level, type, cache, size) < 0) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 487eea4149..9f2abc1d8d 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -3484,6 +3484,7 @@ virVsockSetGuestCid; =20 =20 # util/virxml.h +virParseScaledValue; virXMLCheckIllegalChars; virXMLChildElementCount; virXMLExtractNamespaceXML; diff --git a/src/util/virxml.c b/src/util/virxml.c index 02b59ea2f8..e9429cd4ac 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -32,6 +32,7 @@ #include "viralloc.h" #include "virfile.h" #include "virstring.h" +#include "virutil.h" =20 #define VIR_FROM_THIS VIR_FROM_XML =20 @@ -1405,3 +1406,74 @@ virXMLNamespaceRegister(xmlXPathContextPtr ctxt, =20 return 0; } + + +/** + * virParseScaledValue: + * @xpath: XPath to memory amount + * @units_xpath: XPath to units attribute + * @ctxt: XPath context + * @val: scaled value is stored here + * @scale: default scale for @val + * @max: maximal @val allowed + * @required: is the value required? + * + * Parse a value located at @xpath within @ctxt, and store the + * result into @val. The value is scaled by units located at + * @units_xpath (or the 'unit' attribute under @xpath if + * @units_xpath is NULL). If units are not present, the default + * @scale is used. If @required is set, then the value must + * exist; otherwise, the value is optional. The resulting value + * is in bytes. + * + * Returns 1 on success, + * 0 if the value was not present and !@required, + * -1 on failure after issuing error. + */ +int +virParseScaledValue(const char *xpath, + const char *units_xpath, + xmlXPathContextPtr ctxt, + unsigned long long *val, + unsigned long long scale, + unsigned long long max, + bool required) +{ + unsigned long long bytes; + g_autofree char *xpath_full =3D NULL; + g_autofree char *unit =3D NULL; + g_autofree char *bytes_str =3D NULL; + + *val =3D 0; + xpath_full =3D g_strdup_printf("string(%s)", xpath); + + bytes_str =3D virXPathString(xpath_full, ctxt); + if (!bytes_str) { + if (!required) + return 0; + virReportError(VIR_ERR_XML_ERROR, + _("missing element or attribute '%s'"), + xpath); + return -1; + } + VIR_FREE(xpath_full); + + if (virStrToLong_ullp(bytes_str, NULL, 10, &bytes) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid value '%s' for element or attribute '%s'= "), + bytes_str, xpath); + return -1; + } + + if (units_xpath) + xpath_full =3D g_strdup_printf("string(%s)", units_xpath); + else + xpath_full =3D g_strdup_printf("string(%s/@unit)", xpath); + unit =3D virXPathString(xpath_full, ctxt); + + if (virScaleInteger(&bytes, unit, scale, max) < 0) + return -1; + + *val =3D bytes; + return 1; +} diff --git a/src/util/virxml.h b/src/util/virxml.h index ed178105f6..886d1e025f 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -270,3 +270,11 @@ virXMLNamespaceFormatNS(virBufferPtr buf, int virXMLNamespaceRegister(xmlXPathContextPtr ctxt, virXMLNamespace const *ns); + +int virParseScaledValue(const char *xpath, + const char *units_xpath, + xmlXPathContextPtr ctxt, + unsigned long long *val, + unsigned long long scale, + unsigned long long max, + bool required); --=20 2.26.2 From nobody Sat Apr 20 15:07:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593006583; cv=none; d=zohomail.com; s=zohoarc; b=Lq6MtkJb2QWdK/uprlBcB+YwA44BsZPEvwR9Ui5as0wRdF+gaalW/hSx6Vrc1tqn1Tz7T17W4MJ66iujH+DZgSA1FPT3v0zwC1RifewZNUm/k04SPjCx2nlnHE8TzH7cZCA+6fJItgQ2GdqxnGEjWOv5VpOXElnZ6oYNNvwynYg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593006583; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=b+KurRtly8rxCMZgryoaiWF6J6UQuHZKRvbII911PN8=; b=LxhqYkSVbnoLwZRr6MwlJ1BW3BeUsrHNozOU6WbYWnkiPNBqQ74Pc6AJE4LvWS04Ona0MsHLhmNECLfREUvlKlW4hBX5H6nYMe50BtSPOqS30yyi9PxiZS4qrHOoSjf2J8lt3RpzPffhQjsMNL3wahP5re7abfSye/wtn6TP8XA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1593006583415867.961888715698; Wed, 24 Jun 2020 06:49:43 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-65-UEmJoVHvNRSRfoYsHUTfBA-1; Wed, 24 Jun 2020 09:49:39 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E0B8580400A; Wed, 24 Jun 2020 13:49:33 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BF04E2B47E; Wed, 24 Jun 2020 13:49:33 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8A8BE1809561; Wed, 24 Jun 2020 13:49:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05ODnJuC015650 for ; Wed, 24 Jun 2020 09:49:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 556415D9DC; Wed, 24 Jun 2020 13:49:19 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB3505DD61 for ; Wed, 24 Jun 2020 13:49:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593006582; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=b+KurRtly8rxCMZgryoaiWF6J6UQuHZKRvbII911PN8=; b=C5XAFidz5hhQEsQVDB/EAhZ64dUm58KCvsGsFUO+LKMFWP6jhIujM1IMyAKtJJ7Gl/qgXm DOfV0GmRLYmxcd84quZwahzTokt0R33eOXKKnTSIaPXTpRKoFUmXXc6+WKzNFMU7ExrSl7 8O13Cj3CED6J79ANNELcgWwR2Ts/UaI= X-MC-Unique: UEmJoVHvNRSRfoYsHUTfBA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 03/13] numa_conf: Drop CPU from name of two functions Date: Wed, 24 Jun 2020 15:49:01 +0200 Message-Id: <5e133a806e59e2696a86953db02386c8e1c2cb67.1593006346.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" There are two functions virDomainNumaDefCPUFormatXML() and virDomainNumaDefCPUParseXML() which format and parse domain's . There is nothing CPU specific about them. Drop the infix. Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- src/conf/cpu_conf.c | 2 +- src/conf/domain_conf.c | 2 +- src/conf/numa_conf.c | 8 ++++---- src/conf/numa_conf.h | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index e1b0a5653f..a1514c2e14 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -734,7 +734,7 @@ virCPUDefFormatBufFull(virBufferPtr buf, if (virCPUDefFormatBuf(&childrenBuf, def) < 0) goto cleanup; =20 - if (virDomainNumaDefCPUFormatXML(&childrenBuf, numa) < 0) + if (virDomainNumaDefFormatXML(&childrenBuf, numa) < 0) goto cleanup; =20 /* Put it all together */ diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 65a110b16f..ce75831037 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -21394,7 +21394,7 @@ virDomainDefParseXML(xmlDocPtr xml, if (virCPUDefParseXML(ctxt, "./cpu[1]", VIR_CPU_TYPE_GUEST, &def->cpu)= < 0) goto error; =20 - if (virDomainNumaDefCPUParseXML(def->numa, ctxt) < 0) + if (virDomainNumaDefParseXML(def->numa, ctxt) < 0) goto error; =20 if (virDomainNumaGetCPUCountTotal(def->numa) > virDomainDefGetVcpusMax= (def)) { diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index 21a8be2cac..2685a3e828 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -842,8 +842,8 @@ virDomainNumaDefNodeDistanceParseXML(virDomainNumaPtr d= ef, } =20 int -virDomainNumaDefCPUParseXML(virDomainNumaPtr def, - xmlXPathContextPtr ctxt) +virDomainNumaDefParseXML(virDomainNumaPtr def, + xmlXPathContextPtr ctxt) { xmlNodePtr *nodes =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt); @@ -970,8 +970,8 @@ virDomainNumaDefCPUParseXML(virDomainNumaPtr def, =20 =20 int -virDomainNumaDefCPUFormatXML(virBufferPtr buf, - virDomainNumaPtr def) +virDomainNumaDefFormatXML(virBufferPtr buf, + virDomainNumaPtr def) { virDomainMemoryAccess memAccess; virTristateBool discard; diff --git a/src/conf/numa_conf.h b/src/conf/numa_conf.h index cdf87a87e8..206dffe304 100644 --- a/src/conf/numa_conf.h +++ b/src/conf/numa_conf.h @@ -181,8 +181,8 @@ bool virDomainNumatuneNodesetIsAvailable(virDomainNumaP= tr numatune, bool virDomainNumatuneNodeSpecified(virDomainNumaPtr numatune, int cellid); =20 -int virDomainNumaDefCPUParseXML(virDomainNumaPtr def, xmlXPathContextPtr c= txt); -int virDomainNumaDefCPUFormatXML(virBufferPtr buf, virDomainNumaPtr def); +int virDomainNumaDefParseXML(virDomainNumaPtr def, xmlXPathContextPtr ctxt= ); +int virDomainNumaDefFormatXML(virBufferPtr buf, virDomainNumaPtr def); =20 unsigned int virDomainNumaGetCPUCountTotal(virDomainNumaPtr numa); =20 --=20 2.26.2 From nobody Sat Apr 20 15:07:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593006587; cv=none; d=zohomail.com; s=zohoarc; b=X1qHW5fYlQTLZ6a8cUi85Jh8QsMuYcLOlxzF4cD2kBbeC+Q8nBR9QUjtC+10lOKrhHj1JfdtNSOLhYa2PYIyBaqhBdNjyVe9b9EWHXcHqNw62HG1baKQTm++pVdpxNA/RtTtlqozuTFbOnAxc2wEQGxkuVrmKiGPwUos7cukbio= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593006587; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=N4WJhVKjaZd99Nc1UzwjNNugkNYd2W2OmIO86npzDMA=; b=IL9UMma7fxAGMQMcGqM1LVycR/6+Y1/wra8UaZKVTyHArUMTuhJuiXtWsbDhEDHYmxpGvDvrq7iihgBzjG/A7VG/rLkJrf3H3dsSbeni1vKDogcZAFjy7+r/r7BLBD9Wohb9nlBytp3qBI5o7RZuDrIFDDLLBBjnmUF3lCzOU7w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 159300658758084.1777356373417; Wed, 24 Jun 2020 06:49:47 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-455-MjfNcdE5MGKK0cTpMkUCsA-1; Wed, 24 Jun 2020 09:49:42 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 336FD8015FD; Wed, 24 Jun 2020 13:49:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1124E61984; Wed, 24 Jun 2020 13:49:36 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D2508180043A; Wed, 24 Jun 2020 13:49:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05ODnKl8015658 for ; Wed, 24 Jun 2020 09:49:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 325ED5DA27; Wed, 24 Jun 2020 13:49:20 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id A7DEE5D9DC for ; Wed, 24 Jun 2020 13:49:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593006584; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=N4WJhVKjaZd99Nc1UzwjNNugkNYd2W2OmIO86npzDMA=; b=YspQgmeuuewlLOiTsISDv9NEs25vRqasN4k3LA2QBqRVK+49wdg9pkQKeZEm27b6VT8p7z egSbyY0dIv6Bcn5X3n1u40O/Lw8QCAciykNtxBneLSZGIGQUY7lkxee2ob5wmZurWqoCs5 sOXyF4xrwqrOns+zmKr1h4k3MjIHcRM= X-MC-Unique: MjfNcdE5MGKK0cTpMkUCsA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 04/13] qemu_command: Rename qemuBuildNumaArgStr() Date: Wed, 24 Jun 2020 15:49:02 +0200 Message-Id: <4a90a7167aecce67862118c36b3752985a69efbf.1593006346.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The function doesn't just build the argument for -numa. Since the -numa can be repeated multiple times, it also puts -numa onto the cmd line. Also, the rest of the functions has 'Command' infix. Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_command.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f355ddbfd5..05e5c19118 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7122,10 +7122,10 @@ qemuBuildIOThreadCommandLine(virCommandPtr cmd, =20 =20 static int -qemuBuildNumaArgStr(virQEMUDriverConfigPtr cfg, - virDomainDefPtr def, - virCommandPtr cmd, - qemuDomainObjPrivatePtr priv) +qemuBuildNumaCommandLine(virQEMUDriverConfigPtr cfg, + virDomainDefPtr def, + virCommandPtr cmd, + qemuDomainObjPrivatePtr priv) { size_t i, j; virQEMUCapsPtr qemuCaps =3D priv->qemuCaps; @@ -9725,7 +9725,7 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, return NULL; =20 if (virDomainNumaGetNodeCount(def->numa) && - qemuBuildNumaArgStr(cfg, def, cmd, priv) < 0) + qemuBuildNumaCommandLine(cfg, def, cmd, priv) < 0) return NULL; =20 if (qemuBuildMemoryDeviceCommandLine(cmd, cfg, def, priv) < 0) --=20 2.26.2 From nobody Sat Apr 20 15:07:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593006588; cv=none; d=zohomail.com; s=zohoarc; b=mUFwcvjdstIhMI/rj810T3nWD6LJhZC88d086T4mRe3Po6mWeSckymaOqiQSCJChWJzvu/tcX+3zmiPpCLMQGZnHOshnuA6575rThuxSGGhmUINhyE+G2cC8v+j9g3GB+ofbEiYUvKGkkO0DPlknwadsMFaeHP58F0A2HOe0SBQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593006588; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xHz5u8Ea86Jg/Nsaj7kMakq7iu7Ogdx/t055JbT+Lu0=; b=lz4w33/uBVuTJNsKFpAEDxmq2Jwk+ag0fXLkq0ohYyLtW089J1hJwvKM8oW9Rjlv2fbhF6n9T87QC3srxplzo89stqCrhl0p4ApdQm9sLLzY1O6eYnIrsTyixAS46oGZBgd8+4XZQX1JnJKq66DMeFrHu4kOuYtEtJq6fFs21Ag= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 159300658854986.29994815962937; Wed, 24 Jun 2020 06:49:48 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-439-iAMTpnHaNm-GHJv9KkBIRw-1; Wed, 24 Jun 2020 09:49:45 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 74958107ACF9; Wed, 24 Jun 2020 13:49:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5442160C80; Wed, 24 Jun 2020 13:49:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 24C3787542; Wed, 24 Jun 2020 13:49:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05ODnLOQ015668 for ; Wed, 24 Jun 2020 09:49:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0F4B95DA27; Wed, 24 Jun 2020 13:49:21 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 848955D9DC for ; Wed, 24 Jun 2020 13:49:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593006587; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=xHz5u8Ea86Jg/Nsaj7kMakq7iu7Ogdx/t055JbT+Lu0=; b=Sw+JnXpbFXJYFO3vQ090P1oA+epz68XSi0d6bAf0vU6OYCL+eDWyuHi5kSmeNdFh3bN52R Vzde4Lm5Ujkct8ncC2LhGaMhCAepbjaRLWZp79y+lLuw36Zj/1mb0Nm5neYQQpFwchWcTM qIqqhuD1FQeHGUPRXEvX/hT5dc4vjmg= X-MC-Unique: iAMTpnHaNm-GHJv9KkBIRw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 05/13] qemuBuildMachineCommandLine: Drop needless check Date: Wed, 24 Jun 2020 15:49:03 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The machine can not be NULL at this point - qemuDomainDefPostParse() makes sure it isn't. Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_command.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 05e5c19118..c5b0ee231e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6722,13 +6722,6 @@ qemuBuildMachineCommandLine(virCommandPtr cmd, g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t i; =20 - /* This should *never* be NULL, since we always provide - * a machine in the capabilities data for QEMU. So this - * check is just here as a safety in case the unexpected - * happens */ - if (!def->os.machine) - return 0; - virCommandAddArg(cmd, "-machine"); virBufferAdd(&buf, def->os.machine, -1); =20 --=20 2.26.2 From nobody Sat Apr 20 15:07:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593006608; cv=none; d=zohomail.com; s=zohoarc; b=Pf0IWgJjn40pGy0L1QnZobKpdqTbKXHuZ8HPFaom89UnYaBAWhGlYf5BDINdTgr2jyskFSZtRnAxbwuMY0Q0KEvB1jej/lxDXut9x6sm89xbmONkEo8nWLeGXuu3uslDFr/x7Ek+akgLDkTZ4SfR8D26TyouYyOSUjC5xaezADg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593006608; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hQXGQqEhODQl5utG6S/Ov4Cui0sa9iYb7MOmYu4h0jg=; b=Ef1gkcxpwWXHXOL7e8Ca6MGSYxqWV751XdoWlnwGudkljlFSaVldMDb/pXIGkaDOdrcwA7qnLC4m5eorHOlObpRkCluy38CRN3q9HPImA1UXnyv4peMWxo1bHtj+F0dkjmSxglH7MnQGiYxpPWqwIdyQ1M5m3IkZrCZiH0Am0ZM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1593006608475681.0626351611774; Wed, 24 Jun 2020 06:50:08 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-264-vAovKqomNiWz_ogF6D9tIA-1; Wed, 24 Jun 2020 09:49:48 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C014FEC1A4; Wed, 24 Jun 2020 13:49:40 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9AAFF1001B2B; Wed, 24 Jun 2020 13:49:40 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5B6541806B0B; Wed, 24 Jun 2020 13:49:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05ODnLI3015678 for ; Wed, 24 Jun 2020 09:49:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id DF9E35DA27; Wed, 24 Jun 2020 13:49:21 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 616AC5D9DC for ; Wed, 24 Jun 2020 13:49:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593006607; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=hQXGQqEhODQl5utG6S/Ov4Cui0sa9iYb7MOmYu4h0jg=; b=Cai0qBycu9+K4HlWW9AXSbdoI2au0/hrUxgbFzVyh2/kGqMP08h/XvD6mPOitEXEfvjyZg mKTiO+v4EWsEUB+o/cNBpzvkuVcLv4EoeJuR2C9P8mr5qlBWiRELtIxd7bDxCxPKlvgvd6 YI1eCVl8J9FTblaUyAPUCzSiK3kYGmA= X-MC-Unique: vAovKqomNiWz_ogF6D9tIA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 06/13] numa_conf: Make virDomainNumaSetNodeCpumask() return void Date: Wed, 24 Jun 2020 15:49:04 +0200 Message-Id: <9291da29dc684d1a020faa96b5f4924797b8f0fa.1593006346.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" There is only one caller of virDomainNumaSetNodeCpumask() which checks for the return value but because the function will return NULL iff the @cpumask was NULL in the first place. But in that place @cpumask can't be NULL because it was just allocated by virBitmapParse(). Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- src/conf/numa_conf.c | 4 +--- src/conf/numa_conf.h | 6 +++--- src/libxl/xen_xl.c | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index 2685a3e828..7b9084456e 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -1317,14 +1317,12 @@ virDomainNumaGetNodeCpumask(virDomainNumaPtr numa, } =20 =20 -virBitmapPtr +void virDomainNumaSetNodeCpumask(virDomainNumaPtr numa, size_t node, virBitmapPtr cpumask) { numa->mem_nodes[node].cpumask =3D cpumask; - - return numa->mem_nodes[node].cpumask; } =20 =20 diff --git a/src/conf/numa_conf.h b/src/conf/numa_conf.h index 206dffe304..25e896826b 100644 --- a/src/conf/numa_conf.h +++ b/src/conf/numa_conf.h @@ -155,9 +155,9 @@ size_t virDomainNumaSetNodeDistanceCount(virDomainNumaP= tr numa, size_t ndistances) ATTRIBUTE_NONNULL(1); =20 -virBitmapPtr virDomainNumaSetNodeCpumask(virDomainNumaPtr numa, - size_t node, - virBitmapPtr cpumask) +void virDomainNumaSetNodeCpumask(virDomainNumaPtr numa, + size_t node, + virBitmapPtr cpumask) ATTRIBUTE_NONNULL(1); =20 /* diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index d40c2e1d8e..1c1279e1cb 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -508,10 +508,10 @@ xenParseXLVnuma(virConfPtr conf, goto cleanup; } =20 - if ((virBitmapParse(vtoken, &cpumask, VIR_DOMAIN_C= PUMASK_LEN) < 0) || - (virDomainNumaSetNodeCpumask(numa, vnodeCnt, c= pumask) =3D=3D NULL)) + if (virBitmapParse(vtoken, &cpumask, VIR_DOMAIN_CP= UMASK_LEN) < 0) goto cleanup; =20 + virDomainNumaSetNodeCpumask(numa, vnodeCnt, cpumas= k); vcpus +=3D virBitmapCountBits(cpumask); =20 } else if (STRPREFIX(str, "vdistances")) { --=20 2.26.2 From nobody Sat Apr 20 15:07:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593006583; cv=none; d=zohomail.com; s=zohoarc; b=cDodm6/ndWeDnhdccjFygJWm7YKxaWTSF7WA0Pq5rZSrPJw+kpAaKLdICASqRoO6IDM4zLQM9Ee1ll/oBjsbenQgPrkfieisxVZy5QHMiCY4F1wcpsue1ieZbryn+ipM2rrCP5FvPZl4ygsGfOdfn3sz4pZNSbT6zQx8mFgOdT8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593006583; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uDYEMVC1HI8o/ZZ1tYRBpic1EiUVXITS8Wv2E2+Q+BA=; b=A+XhnZmDrzjhEddHeGIIe4p9zSATwkrIRY99bdbZJD56U5uTbszDf8Jgt7m/6aa9rlkOn9ADqguJQ9UEQq0Fr0oxDBiam4jTWk6XjNbY4LMbzD0neAlrnb2/AfJ9tUZNgIVz06MTW3+/XhcvQ/7FPfZf50nuEWwOW0xa8ZdVxoI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1593006583317727.0130265873121; Wed, 24 Jun 2020 06:49:43 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-30-BztQteffPoCmF5waFbkpbg-1; Wed, 24 Jun 2020 09:49:39 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E913280400C; Wed, 24 Jun 2020 13:49:33 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C3E3A1001B2B; Wed, 24 Jun 2020 13:49:33 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 936961809563; Wed, 24 Jun 2020 13:49:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05ODnMK5015683 for ; Wed, 24 Jun 2020 09:49:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id E5E7D5DA27; Wed, 24 Jun 2020 13:49:22 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E16A5D9DC for ; Wed, 24 Jun 2020 13:49:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593006581; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=uDYEMVC1HI8o/ZZ1tYRBpic1EiUVXITS8Wv2E2+Q+BA=; b=iBZiRMraO6v2NRefYOgtROjrMZFZ84SSNiG0LMgHqnFWEdRpVNEYdaWYvVKPt3rseB96dZ tTux3KE9TAqjOLFGhJjBUIy8a/eKJUTya0HohWm1c40TQdNiILUnHbKkqRga+cSFZeN56T +8jhhcwcMdV0yZYLp7CnLs12hbnbiHo= X-MC-Unique: BztQteffPoCmF5waFbkpbg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 07/13] Allow NUMA nodes without vCPUs Date: Wed, 24 Jun 2020 15:49:05 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" QEMU allows creating NUMA nodes that have memory only. These are somehow important for HMAT. With check done in qemuValidateDomainDef() for QEMU 2.7 or newer, we can be sure that the vCPUs are fully assigned to NUMA nodes in domain XML. Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- docs/formatdomain.html.in | 2 + docs/schemas/cputypes.rng | 8 ++- src/conf/numa_conf.c | 59 ++++++++++--------- src/libxl/xen_xl.c | 10 ++-- src/qemu/qemu_command.c | 26 ++++---- src/qemu/qemu_validate.c | 22 +++---- tests/qemuxml2argvdata/numatune-no-vcpu.args | 33 +++++++++++ tests/qemuxml2argvdata/numatune-no-vcpu.xml | 42 +++++++++++++ tests/qemuxml2argvtest.c | 1 + tests/qemuxml2xmloutdata/numatune-no-vcpu.xml | 1 + tests/qemuxml2xmltest.c | 1 + 11 files changed, 149 insertions(+), 56 deletions(-) create mode 100644 tests/qemuxml2argvdata/numatune-no-vcpu.args create mode 100644 tests/qemuxml2argvdata/numatune-no-vcpu.xml create mode 120000 tests/qemuxml2xmloutdata/numatune-no-vcpu.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index bd662727d3..07dcca57f5 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1840,6 +1840,8 @@ consistent across qemu and libvirt versions. memory specifies the node memory in kibibytes (i.e. blocks of 1024 bytes). + Since 6.6.0 the cpus attri= bute + is optional and if omitted a CPU-less NUMA node is created. Since 1.2.11 one can use an additional = unit attribu= te to define units in which memory is specified. diff --git a/docs/schemas/cputypes.rng b/docs/schemas/cputypes.rng index e2744acad3..a1682a1003 100644 --- a/docs/schemas/cputypes.rng +++ b/docs/schemas/cputypes.rng @@ -115,9 +115,11 @@ - - - + + + + + diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index 7b9084456e..7cf62ce7da 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -889,32 +889,28 @@ virDomainNumaDefParseXML(virDomainNumaPtr def, } VIR_FREE(tmp); =20 - if (def->mem_nodes[cur_cell].cpumask) { + if (def->mem_nodes[cur_cell].mem) { virReportError(VIR_ERR_XML_ERROR, _("Duplicate NUMA cell info for cell id '%u'"), cur_cell); goto cleanup; } =20 - if (!(tmp =3D virXMLPropString(nodes[i], "cpus"))) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Missing 'cpus' attribute in NUMA cell")); - goto cleanup; - } + if ((tmp =3D virXMLPropString(nodes[i], "cpus"))) { + g_autoptr(virBitmap) cpumask =3D NULL; =20 - if (virBitmapParse(tmp, &def->mem_nodes[cur_cell].cpumask, - VIR_DOMAIN_CPUMASK_LEN) < 0) - goto cleanup; + if (virBitmapParse(tmp, &cpumask, VIR_DOMAIN_CPUMASK_LEN) < 0) + goto cleanup; =20 - if (virBitmapIsAllClear(def->mem_nodes[cur_cell].cpumask)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("NUMA cell %d has no vCPUs assigned"), cur_cel= l); - goto cleanup; + if (!virBitmapIsAllClear(cpumask)) + def->mem_nodes[cur_cell].cpumask =3D g_steal_pointer(&cpum= ask); + VIR_FREE(tmp); } - VIR_FREE(tmp); =20 for (j =3D 0; j < n; j++) { - if (j =3D=3D cur_cell || !def->mem_nodes[j].cpumask) + if (j =3D=3D cur_cell || + !def->mem_nodes[j].cpumask || + !def->mem_nodes[cur_cell].cpumask) continue; =20 if (virBitmapOverlaps(def->mem_nodes[j].cpumask, @@ -975,7 +971,6 @@ virDomainNumaDefFormatXML(virBufferPtr buf, { virDomainMemoryAccess memAccess; virTristateBool discard; - char *cpustr; size_t ncells =3D virDomainNumaGetNodeCount(def); size_t i; =20 @@ -985,17 +980,22 @@ virDomainNumaDefFormatXML(virBufferPtr buf, virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, 2); for (i =3D 0; i < ncells; i++) { + virBitmapPtr cpumask =3D virDomainNumaGetNodeCpumask(def, i); int ndistances; =20 memAccess =3D virDomainNumaGetNodeMemoryAccessMode(def, i); discard =3D virDomainNumaGetNodeDiscard(def, i); =20 - if (!(cpustr =3D virBitmapFormat(virDomainNumaGetNodeCpumask(def, = i)))) - return -1; - virBufferAddLit(buf, "\n"); } - - VIR_FREE(cpustr); } virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); @@ -1047,8 +1045,12 @@ virDomainNumaGetCPUCountTotal(virDomainNumaPtr numa) size_t i; unsigned int ret =3D 0; =20 - for (i =3D 0; i < numa->nmem_nodes; i++) - ret +=3D virBitmapCountBits(virDomainNumaGetNodeCpumask(numa, i)); + for (i =3D 0; i < numa->nmem_nodes; i++) { + virBitmapPtr cpumask =3D virDomainNumaGetNodeCpumask(numa, i); + + if (cpumask) + ret +=3D virBitmapCountBits(cpumask); + } =20 return ret; } @@ -1060,11 +1062,14 @@ virDomainNumaGetMaxCPUID(virDomainNumaPtr numa) unsigned int ret =3D 0; =20 for (i =3D 0; i < numa->nmem_nodes; i++) { + virBitmapPtr cpumask =3D virDomainNumaGetNodeCpumask(numa, i); int bit; =20 - bit =3D virBitmapLastSetBit(virDomainNumaGetNodeCpumask(numa, i)); - if (bit > ret) - ret =3D bit; + if (cpumask) { + bit =3D virBitmapLastSetBit(cpumask); + if (bit > ret) + ret =3D bit; + } } =20 return ret; diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index 1c1279e1cb..b99ddd150b 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -1444,19 +1444,21 @@ xenFormatXLVnuma(virConfValuePtr list, { int ret =3D -1; size_t i; - virBuffer buf =3D VIR_BUFFER_INITIALIZER; virConfValuePtr numaVnode, tmp; - + virBitmapPtr cpumask =3D virDomainNumaGetNodeCpumask(numa, node); size_t nodeSize =3D virDomainNumaGetNodeMemorySize(numa, node) / 1024; - char *nodeVcpus =3D virBitmapFormat(virDomainNumaGetNodeCpumask(numa, = node)); + g_autofree char *nodeVcpus =3D NULL; =20 - if (VIR_ALLOC(numaVnode) < 0) + if (!cpumask || + VIR_ALLOC(numaVnode) < 0) goto cleanup; =20 numaVnode->type =3D VIR_CONF_LIST; numaVnode->list =3D NULL; =20 + nodeVcpus =3D virBitmapFormat(cpumask); + /* pnode */ virBufferAsprintf(&buf, "pnode=3D%zu", node); xenFormatXLVnode(numaVnode, &buf); diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c5b0ee231e..628ff970bd 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7123,8 +7123,6 @@ qemuBuildNumaCommandLine(virQEMUDriverConfigPtr cfg, size_t i, j; virQEMUCapsPtr qemuCaps =3D priv->qemuCaps; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; - char *cpumask =3D NULL; - char *tmpmask =3D NULL; char *next =3D NULL; virBufferPtr nodeBackends =3D NULL; bool needBackend =3D false; @@ -7169,9 +7167,7 @@ qemuBuildNumaCommandLine(virQEMUDriverConfigPtr cfg, goto cleanup; =20 for (i =3D 0; i < ncells; i++) { - VIR_FREE(cpumask); - if (!(cpumask =3D virBitmapFormat(virDomainNumaGetNodeCpumask(def-= >numa, i)))) - goto cleanup; + virBitmapPtr cpumask =3D virDomainNumaGetNodeCpumask(def->numa, i); =20 if (needBackend) { virCommandAddArg(cmd, "-object"); @@ -7181,11 +7177,19 @@ qemuBuildNumaCommandLine(virQEMUDriverConfigPtr cfg, virCommandAddArg(cmd, "-numa"); virBufferAsprintf(&buf, "node,nodeid=3D%zu", i); =20 - for (tmpmask =3D cpumask; tmpmask; tmpmask =3D next) { - if ((next =3D strchr(tmpmask, ','))) - *(next++) =3D '\0'; - virBufferAddLit(&buf, ",cpus=3D"); - virBufferAdd(&buf, tmpmask, -1); + if (cpumask) { + g_autofree char *cpumaskStr =3D NULL; + char *tmpmask; + + if (!(cpumaskStr =3D virBitmapFormat(cpumask))) + goto cleanup; + + for (tmpmask =3D cpumaskStr; tmpmask; tmpmask =3D next) { + if ((next =3D strchr(tmpmask, ','))) + *(next++) =3D '\0'; + virBufferAddLit(&buf, ",cpus=3D"); + virBufferAdd(&buf, tmpmask, -1); + } } =20 if (needBackend) @@ -7216,8 +7220,6 @@ qemuBuildNumaCommandLine(virQEMUDriverConfigPtr cfg, ret =3D 0; =20 cleanup: - VIR_FREE(cpumask); - if (nodeBackends) { for (i =3D 0; i < ncells; i++) virBufferFreeAndReset(&nodeBackends[i]); diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 5082a29dc7..53a03c1e0b 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -654,7 +654,7 @@ qemuValidateDomainDefNuma(const virDomainDef *def, } =20 for (i =3D 0; i < ncells; i++) { - g_autofree char * cpumask =3D NULL; + virBitmapPtr cpumask =3D virDomainNumaGetNodeCpumask(def->numa, i); =20 if (!hasMemoryCap && virDomainNumaGetNodeMemoryAccessMode(def->numa, i)) { @@ -664,17 +664,19 @@ qemuValidateDomainDefNuma(const virDomainDef *def, return -1; } =20 - if (!(cpumask =3D virBitmapFormat(virDomainNumaGetNodeCpumask(def-= >numa, i)))) - return -1; + if (cpumask) { + g_autofree char * cpumaskStr =3D NULL; + if (!(cpumaskStr =3D virBitmapFormat(cpumask))) + return -1; =20 - if (strchr(cpumask, ',') && - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_NUMA)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("disjoint NUMA cpu ranges are not supported " - "with this QEMU")); - return -1; + if (strchr(cpumaskStr, ',') && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_NUMA)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("disjoint NUMA cpu ranges are not support= ed " + "with this QEMU")); + return -1; + } } - } =20 if (virDomainNumaNodesDistancesAreBeingSet(def->numa) && diff --git a/tests/qemuxml2argvdata/numatune-no-vcpu.args b/tests/qemuxml2a= rgvdata/numatune-no-vcpu.args new file mode 100644 index 0000000000..a1f1ee044e --- /dev/null +++ b/tests/qemuxml2argvdata/numatune-no-vcpu.args @@ -0,0 +1,33 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-QEMUGuest \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-QEMUGuest/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-QEMUGuest/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-x86_64 \ +-name QEMUGuest \ +-S \ +-machine pc,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff \ +-m 12288 \ +-realtime mlock=3Doff \ +-smp 12,sockets=3D12,cores=3D1,threads=3D1 \ +-numa node,nodeid=3D0,cpus=3D0-3,mem=3D2048 \ +-numa node,nodeid=3D1,cpus=3D4-7,mem=3D2048 \ +-numa node,nodeid=3D2,cpus=3D8-11,mem=3D2048 \ +-numa node,nodeid=3D3,mem=3D2048 \ +-numa node,nodeid=3D4,mem=3D2048 \ +-numa node,nodeid=3D5,mem=3D2048 \ +-uuid c7a5fdb2-cdaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-QEMUGuest/monit= or.sock,\ +server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-usb \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 diff --git a/tests/qemuxml2argvdata/numatune-no-vcpu.xml b/tests/qemuxml2ar= gvdata/numatune-no-vcpu.xml new file mode 100644 index 0000000000..f25a07d7ed --- /dev/null +++ b/tests/qemuxml2argvdata/numatune-no-vcpu.xml @@ -0,0 +1,42 @@ + + QEMUGuest + c7a5fdb2-cdaf-9455-926a-d65c16db1809 + 12582912 + 12582912 + 12 + + hvm + + + + + + + + + + + + + + + + + + + destroy + restart + restart + + /usr/bin/qemu-system-x86_64 + +
+ + + + + +
+ + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 1195f9c982..98d9a7b5b2 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1912,6 +1912,7 @@ mymain(void) DO_TEST_PARSE_ERROR("numatune-memnode-no-memory", NONE); =20 DO_TEST("numatune-distances", QEMU_CAPS_NUMA, QEMU_CAPS_NUMA_DIST); + DO_TEST("numatune-no-vcpu", NONE); =20 DO_TEST("numatune-auto-nodeset-invalid", NONE); DO_TEST("numatune-auto-prefer", QEMU_CAPS_OBJECT_MEMORY_RAM, diff --git a/tests/qemuxml2xmloutdata/numatune-no-vcpu.xml b/tests/qemuxml2= xmloutdata/numatune-no-vcpu.xml new file mode 120000 index 0000000000..f213032685 --- /dev/null +++ b/tests/qemuxml2xmloutdata/numatune-no-vcpu.xml @@ -0,0 +1 @@ +../qemuxml2argvdata/numatune-no-vcpu.xml \ No newline at end of file diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index d203c97e36..376c427415 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1105,6 +1105,7 @@ mymain(void) DO_TEST("numatune-memnode", QEMU_CAPS_NUMA, QEMU_CAPS_OBJECT_MEMORY_FI= LE); DO_TEST("numatune-memnode-no-memory", QEMU_CAPS_OBJECT_MEMORY_FILE); DO_TEST("numatune-distances", QEMU_CAPS_NUMA, QEMU_CAPS_NUMA_DIST); + DO_TEST("numatune-no-vcpu", QEMU_CAPS_NUMA); =20 DO_TEST("bios-nvram", NONE); DO_TEST("bios-nvram-os-interleave", NONE); --=20 2.26.2 From nobody Sat Apr 20 15:07:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593006588; cv=none; d=zohomail.com; s=zohoarc; b=UBOoHKmYjQ8znEhq+XymlTjz421VkbyoNjbiamPL8jdUIAnuZfX7gb3OvcL54F1sdOh7mc9Mpmxgt4/heIWDBeLt+tsS4EaH0mHFwrGDoT8h9ajBKIW6Oh50VQjHhAMR3kytD+rzsv3nimgEqzcVm9HJDaD63CCIungRi+VmO+A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593006588; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6uy63+z+Wc87TyEwSBzADSd76RV/DwibGXJFuhiAdcs=; b=eg+nTzAMBP8ghtO8SlYZ14EpYA4Z+WPQc3dMcCYVyicSEoc5pjsse22gqR2dgS5EF1XHEFPjsRiuKQNFpTCoAHxyY8wZ5f2hW1ny4maMNB5hCWbtJlfDKC4YkIJVVw8mwKU4mxek/DMsp1MP7oD6wwrx0OUa9iSs4nOXtc82oo4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 159300658807782.79356183972129; Wed, 24 Jun 2020 06:49:48 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-13-3yoVvSxgMg6CSkoKGKmdEw-1; Wed, 24 Jun 2020 09:49:43 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 78C671005512; Wed, 24 Jun 2020 13:49:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 58D725C240; Wed, 24 Jun 2020 13:49:37 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2D3351CA6; Wed, 24 Jun 2020 13:49:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05ODnNuT015690 for ; Wed, 24 Jun 2020 09:49:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id C46375DA27; Wed, 24 Jun 2020 13:49:23 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 447E45D9DC for ; Wed, 24 Jun 2020 13:49:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593006586; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=6uy63+z+Wc87TyEwSBzADSd76RV/DwibGXJFuhiAdcs=; b=a5ext/Y9lHckJmNOa8ANxuWqYqvavR7XMfBb/phT8h8NCkb4KRNsbuoN6RGCISChxJLV6R /cVzTIehrO2JEf2hS2lTTnoyBYSlS033wnG8nOIZiX7/1eH1bYc/db+Zu/986Eezgnu6G/ JCJo47lOgDcouN5eVhRupMj/lBZE91I= X-MC-Unique: 3yoVvSxgMg6CSkoKGKmdEw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 08/13] conf: Parse and format HMAT Date: Wed, 24 Jun 2020 15:49:06 +0200 Message-Id: <98bea11bf69a7736b3e5ca9ac7444570a8381da8.1593006346.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" To cite ACPI specification: Heterogeneous Memory Attribute Table describes the memory attributes, such as memory side cache attributes and bandwidth and latency details, related to the System Physical Address (SPA) Memory Ranges. The software is expected to use this information as hint for optimization. According to our upstream discussion [1] this is exposed under as under NUMA and or under numa/latencies. 1: https://www.redhat.com/archives/libvir-list/2020-January/msg00422.html Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- docs/formatdomain.html.in | 88 ++++++ docs/schemas/cputypes.rng | 110 ++++++- src/conf/numa_conf.c | 350 ++++++++++++++++++++- src/conf/numa_conf.h | 33 ++ src/libvirt_private.syms | 6 + tests/qemuxml2argvdata/numatune-hmat.xml | 52 +++ tests/qemuxml2xmloutdata/numatune-hmat.xml | 1 + tests/qemuxml2xmltest.c | 1 + 8 files changed, 625 insertions(+), 16 deletions(-) create mode 100644 tests/qemuxml2argvdata/numatune-hmat.xml create mode 120000 tests/qemuxml2xmloutdata/numatune-hmat.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 07dcca57f5..78b2d2828d 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -1931,6 +1931,94 @@ using 10 for local and 20 for remote distances.

=20 +

Heterogeneous Memory Attribute Table

+ +
+...
+<cpu>
+  ...
+  <numa>
+    <cell id=3D'0' cpus=3D'0-3' memory=3D'512000' unit=3D'KiB' discard=
=3D'yes'/>
+    <cell id=3D'1' cpus=3D'4-7' memory=3D'512000' unit=3D'KiB' memAcces=
s=3D'shared'/>
+    <cell id=3D'3' cpus=3D'0-3' memory=3D'2097152' unit=3D'KiB'>
+      <cache level=3D'1' associativity=3D'direct' policy=3D'writeback'&=
gt;
+        <size value=3D'10' unit=3D'KiB'/>
+        <line value=3D'8' unit=3D'B'/>
+      </cache>
+    </cell>
+    <latencies>
+      <latency initiator=3D'0' target=3D'0' type=3D'access' value=3D'5'=
/>
+      <latency initiator=3D'0' target=3D'0' cache=3D'1' type=3D'access'=
 value=3D'10'/>
+      <bandwidth initiator=3D'0' target=3D'0' type=3D'access' value=3D'=
204800' unit=3D'KiB'/>
+    </latencies>
+  </numa>
+  ...
+</cpu>
+...
+ +

+ Since 6.5.0 the cell eleme= nt can + have cache child element which describes memory side ca= che + for memory proximity domains. The cache element has + level attribute describing the cache level and thus the + element can be repeated multiple times to describe different levels = of + the cache. +

+ +

+ The cache element then has associativity + attribute (accepted values are none, direct and + full) describing the cache associativity, and + policy attribute (accepted values are none, + writeback and writethrough) describing cac= he + write associativity. The element has two mandatory child elements th= en: + size and line which describe cache size and + cache line size. Both elements accept two attributes: value + and unit which set the value of corresponding cache + attribute. +

+ +

+ The NUMA description has optional latencies element that + describes the normalized memory read/write latency, read/write bandw= idth + between Initiator Proximity Domains (Processor or I/O) and Target + Proximity Domains (Memory). +

+ +

+ The latencies element can have zero or more + latency child elements to describe latency between two + memory nodes and zero or more bandwidth child elements = to + describe bandwidth between two memory nodes. Both these have the + following mandatory attributes: +

+ +
+
initiator
+
Refers to the source NUMA node
+ +
target
+
Refers to the target NUMA node
+ +
type
+
The type of the access. Accepted values: access, + read, write
+ +
value
+
The actual value. For latency this is delay in nanoseconds, for + bandwidth this value is in kibibytes per second. Use additional + unit attribute to change the units.
+
+ +

+ To describe latency from one NUMA node to a cache of another NUMA no= de + the latency element has optional cache + attribute which in combination with target attribute cr= eates + full reference to distant NUMA node's cache level. For instance, + target=3D'0' cache=3D'1' refers to the first level cach= e of NUMA + node 0. +

+

Events configuration

=20

diff --git a/docs/schemas/cputypes.rng b/docs/schemas/cputypes.rng index a1682a1003..70c455cfa9 100644 --- a/docs/schemas/cputypes.rng +++ b/docs/schemas/cputypes.rng @@ -102,9 +102,14 @@ =20 - - - + + + + + + + + =20 @@ -148,6 +153,9 @@ + + + =20 @@ -162,6 +170,102 @@ =20 + + + + + + + + none + direct + full + + + + + none + writeback + writethrough + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + access + read + write + + + + + + + + + + + + + + + + + + + access + read + write + + + + + + + + + + + + + + diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index 7cf62ce7da..f510dfebce 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -59,9 +59,37 @@ VIR_ENUM_IMPL(virDomainMemoryAccess, "private", ); =20 +VIR_ENUM_IMPL(virDomainCacheAssociativity, + VIR_DOMAIN_CACHE_ASSOCIATIVITY_LAST, + "none", + "direct", + "full", +); + +VIR_ENUM_IMPL(virDomainCachePolicy, + VIR_DOMAIN_CACHE_POLICY_LAST, + "none", + "writeback", + "writethrough", +); + +VIR_ENUM_IMPL(virDomainMemoryLatency, + VIR_DOMAIN_MEMORY_LATENCY_LAST, + "none", + "access", + "read", + "write" +); + typedef struct _virDomainNumaDistance virDomainNumaDistance; typedef virDomainNumaDistance *virDomainNumaDistancePtr; =20 +typedef struct _virDomainNumaCache virDomainNumaCache; +typedef virDomainNumaCache *virDomainNumaCachePtr; + +typedef struct _virDomainNumaLatency virDomainNumaLatency; +typedef virDomainNumaLatency *virDomainNumaLatencyPtr; + typedef struct _virDomainNumaNode virDomainNumaNode; typedef virDomainNumaNode *virDomainNumaNodePtr; =20 @@ -86,9 +114,30 @@ struct _virDomainNuma { unsigned int cellid; } *distances; /* remote node distances */ size_t ndistances; + + struct _virDomainNumaCache { + unsigned int level; /* cache level */ + unsigned int size; /* cache size */ + unsigned int line; /* line size, !!! in bytes !!! */ + virDomainCacheAssociativity associativity; /* cache associativ= ity */ + virDomainCachePolicy policy; /* cache policy */ + } *caches; + size_t ncaches; } *mem_nodes; /* guest node configuration */ size_t nmem_nodes; =20 + struct _virDomainNumaLatency { + virDomainNumaLatencyType type; /* whether structure describes lat= ency + or bandwidth */ + unsigned int initiator; /* the initiator NUMA node */ + unsigned int target; /* the target NUMA node */ + unsigned int cache; /* the target cache on @target; if 0 then = the + memory on @target */ + virDomainMemoryLatency accessType; /* what type of access is defi= ned */ + unsigned long value; /* value itself */ + } *latencies; + size_t nlatencies; + /* Future NUMA tuning related stuff should go here. */ }; =20 @@ -368,9 +417,13 @@ virDomainNumaFree(virDomainNumaPtr numa) =20 if (numa->mem_nodes[i].ndistances > 0) VIR_FREE(numa->mem_nodes[i].distances); + + VIR_FREE(numa->mem_nodes[i].caches); } VIR_FREE(numa->mem_nodes); =20 + VIR_FREE(numa->latencies); + VIR_FREE(numa); } =20 @@ -841,12 +894,102 @@ virDomainNumaDefNodeDistanceParseXML(virDomainNumaPt= r def, return ret; } =20 + +static int +virDomainNumaDefNodeCacheParseXML(virDomainNumaPtr def, + xmlXPathContextPtr ctxt, + unsigned int cur_cell) +{ + g_autofree xmlNodePtr *nodes =3D NULL; + int n; + size_t i; + + if ((n =3D virXPathNodeSet("./cache", ctxt, &nodes)) < 0) + return -1; + + def->mem_nodes[cur_cell].caches =3D g_new0(virDomainNumaCache, n); + + for (i =3D 0; i < n; i++) { + VIR_XPATH_NODE_AUTORESTORE(ctxt); + virDomainNumaCachePtr cache =3D &def->mem_nodes[cur_cell].caches[i= ]; + g_autofree char *tmp =3D NULL; + unsigned int level; + int associativity; + int policy; + unsigned long long size; + unsigned long long line; + + if (!(tmp =3D virXMLPropString(nodes[i], "level"))) { + virReportError(VIR_ERR_XML_ERROR, + _("Missing 'level' attribute in cache " + "element for NUMA node %d"), + cur_cell); + return -1; + } + + if (virStrToLong_uip(tmp, NULL, 10, &level) < 0 || + level =3D=3D 0) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid 'level' attribute in cache " + "element for NUMA node %d"), + cur_cell); + return -1; + } + VIR_FREE(tmp); + + if (!(tmp =3D virXMLPropString(nodes[i], "associativity"))) { + virReportError(VIR_ERR_XML_ERROR, + _("Missing 'associativity' attribute in cache " + "element for NUMA node %d"), + cur_cell); + return -1; + } + + if ((associativity =3D virDomainCacheAssociativityTypeFromString(t= mp)) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid cache associativity '%s'"), + tmp); + return -1; + } + VIR_FREE(tmp); + + if (!(tmp =3D virXMLPropString(nodes[i], "policy"))) { + virReportError(VIR_ERR_XML_ERROR, + _("Missing 'policy' attribute in cache " + "element for NUMA node %d"), + cur_cell); + } + + if ((policy =3D virDomainCachePolicyTypeFromString(tmp)) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid cache policy '%s'"), + tmp); + return -1; + } + VIR_FREE(tmp); + + ctxt->node =3D nodes[i]; + if (virDomainParseMemory("./size/@value", "./size/unit", + ctxt, &size, true, false) < 0) + return -1; + + if (virParseScaledValue("./line/@value", "./line/unit", + ctxt, &line, 1, ULLONG_MAX, true) < 0) + return -1; + + *cache =3D (virDomainNumaCache){level, size, line, associativity, = policy}; + def->mem_nodes[cur_cell].ncaches++; + } + + return 0; +} + + int virDomainNumaDefParseXML(virDomainNumaPtr def, xmlXPathContextPtr ctxt) { xmlNodePtr *nodes =3D NULL; - VIR_XPATH_NODE_AUTORESTORE(ctxt); char *tmp =3D NULL; int n; size_t i, j; @@ -867,6 +1010,7 @@ virDomainNumaDefParseXML(virDomainNumaPtr def, def->nmem_nodes =3D n; =20 for (i =3D 0; i < n; i++) { + VIR_XPATH_NODE_AUTORESTORE(ctxt); int rc; unsigned int cur_cell =3D i; =20 @@ -953,7 +1097,109 @@ virDomainNumaDefParseXML(virDomainNumaPtr def, =20 /* Parse NUMA distances info */ if (virDomainNumaDefNodeDistanceParseXML(def, ctxt, cur_cell) < 0) + goto cleanup; + + /* Parse cache info */ + if (virDomainNumaDefNodeCacheParseXML(def, ctxt, cur_cell) < 0) + goto cleanup; + } + + VIR_FREE(nodes); + if ((n =3D virXPathNodeSet("./cpu/numa[1]/latencies[1]/latency|" + "./cpu/numa[1]/latencies[1]/bandwidth", ctxt,= &nodes)) < 0) + goto cleanup; + + def->latencies =3D g_new0(virDomainNumaLatency, n); + for (i =3D 0; i < n; i++) { + virDomainNumaLatencyType type; + unsigned int initiator; + unsigned int target; + unsigned int cache =3D 0; + int accessType; + unsigned long long value; + + if (virXMLNodeNameEqual(nodes[i], "latency")) { + type =3D VIR_DOMAIN_NUMA_LATENCY_TYPE_LATENCY; + + if (!(tmp =3D virXMLPropString(nodes[i], "value"))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Missing 'value' attribute in NUMA latenc= ies")); goto cleanup; + } + + if (virStrToLong_ullp(tmp, NULL, 10, &value) < 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Invalid 'value' attribute in NUMA latenc= ies")); + goto cleanup; + } + VIR_FREE(tmp); + } else if (virXMLNodeNameEqual(nodes[i], "bandwidth")) { + VIR_XPATH_NODE_AUTORESTORE(ctxt); + type =3D VIR_DOMAIN_NUMA_LATENCY_TYPE_BANDWIDTH; + + ctxt->node =3D nodes[i]; + + if (virDomainParseMemory("./@value", "./@unit", ctxt, &value, = true, false) < 0) + goto cleanup; + } else { + /* Ignore yet unknown child elements. */ + continue; + } + + if (!(tmp =3D virXMLPropString(nodes[i], "initiator"))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Missing 'initiator' attribute in NUMA latenc= ies")); + goto cleanup; + } + + if (virStrToLong_uip(tmp, NULL, 10, &initiator) < 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Invalid 'initiator' attribute in NUMA latenc= ies")); + goto cleanup; + } + VIR_FREE(tmp); + + if (!(tmp =3D virXMLPropString(nodes[i], "target"))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Missing 'target' attribute in NUMA latencies= ")); + goto cleanup; + } + + if (virStrToLong_uip(tmp, NULL, 10, &target) < 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Invalid 'target' attribute in NUMA latencies= ")); + goto cleanup; + } + VIR_FREE(tmp); + + + /* cache attribute is optional */ + if ((tmp =3D virXMLPropString(nodes[i], "cache"))) { + if (virStrToLong_uip(tmp, NULL, 10, &cache) < 0 || + cache =3D=3D 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Invalid 'cache' attribute in NUMA latenc= ies")); + goto cleanup; + } + } + VIR_FREE(tmp); + + if (!(tmp =3D virXMLPropString(nodes[i], "type"))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Missing 'type' attribute in NUMA latencies")= ); + goto cleanup; + } + + if ((accessType =3D virDomainMemoryLatencyTypeFromString(tmp)) <= =3D 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Invalid 'type' attribute in NUMA latencies")= ); + goto cleanup; + } + VIR_FREE(tmp); + + def->latencies[i] =3D (virDomainNumaLatency) {type, initiator, tar= get, + cache, accessType, val= ue}; + def->nlatencies++; } =20 ret =3D 0; @@ -982,6 +1228,7 @@ virDomainNumaDefFormatXML(virBufferPtr buf, for (i =3D 0; i < ncells; i++) { virBitmapPtr cpumask =3D virDomainNumaGetNodeCpumask(def, i); int ndistances; + size_t ncaches; =20 memAccess =3D virDomainNumaGetNodeMemoryAccessMode(def, i); discard =3D virDomainNumaGetNodeDiscard(def, i); @@ -1008,30 +1255,107 @@ virDomainNumaDefFormatXML(virBufferPtr buf, virTristateBoolTypeToString(discard)); =20 ndistances =3D def->mem_nodes[i].ndistances; - if (ndistances =3D=3D 0) { + ncaches =3D def->mem_nodes[i].ncaches; + if (ndistances =3D=3D 0 && ncaches =3D=3D 0) { virBufferAddLit(buf, "/>\n"); } else { size_t j; - virDomainNumaDistancePtr distances =3D def->mem_nodes[i].dista= nces; =20 virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); - virBufferAddLit(buf, "\n"); - virBufferAdjustIndent(buf, 2); - for (j =3D 0; j < ndistances; j++) { - if (distances[j].value) { - virBufferAddLit(buf, "\n"); + + if (ndistances) { + virDomainNumaDistancePtr distances =3D def->mem_nodes[i].d= istances; + + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + for (j =3D 0; j < ndistances; j++) { + if (distances[j].value) { + virBufferAddLit(buf, "\n"); + } } + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } + + for (j =3D 0; j < ncaches; j++) { + virDomainNumaCachePtr cache =3D &def->mem_nodes[i].caches[= j]; + + virBufferAsprintf(buf, "level= ); + if (cache->associativity) { + virBufferAsprintf(buf, " associativity=3D'%s'", + virDomainCacheAssociativityTypeToStr= ing(cache->associativity)); + } + + if (cache->policy) { + virBufferAsprintf(buf, " policy=3D'%s'", + virDomainCachePolicyTypeToString(cac= he->policy)); + } + virBufferAddLit(buf, ">\n"); + + virBufferAdjustIndent(buf, 2); + virBufferAsprintf(buf, + "\n", + cache->size); + + if (cache->line) { + virBufferAsprintf(buf, + "\n", + cache->line); + } + + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); } - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); } } + + if (def->nlatencies) { + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); + } + + for (i =3D 0; i < def->nlatencies; i++) { + virDomainNumaLatencyPtr l =3D &def->latencies[i]; + + switch (l->type) { + case VIR_DOMAIN_NUMA_LATENCY_TYPE_LATENCY: + virBufferAddLit(buf, "initiator, l->target); + + if (l->cache > 0) { + virBufferAsprintf(buf, + " cache=3D'%u'", + l->cache); + } + + virBufferAsprintf(buf, + " type=3D'%s' value=3D'%lu'", + virDomainMemoryLatencyTypeToString(l->accessType= ), + l->value); + + if (l->type =3D=3D VIR_DOMAIN_NUMA_LATENCY_TYPE_BANDWIDTH) + virBufferAddLit(buf, " unit=3D'KiB'"); + virBufferAddLit(buf, "/>\n"); + } + + if (def->nlatencies) { + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } + virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); =20 diff --git a/src/conf/numa_conf.h b/src/conf/numa_conf.h index 25e896826b..a7dc3190d3 100644 --- a/src/conf/numa_conf.h +++ b/src/conf/numa_conf.h @@ -51,6 +51,39 @@ typedef enum { } virDomainMemoryAccess; VIR_ENUM_DECL(virDomainMemoryAccess); =20 +typedef enum { + VIR_DOMAIN_CACHE_ASSOCIATIVITY_NONE, /* No associativity */ + VIR_DOMAIN_CACHE_ASSOCIATIVITY_DIRECT, /* Direct mapped cache */ + VIR_DOMAIN_CACHE_ASSOCIATIVITY_FULL, /* Fully associative cache */ + + VIR_DOMAIN_CACHE_ASSOCIATIVITY_LAST +} virDomainCacheAssociativity; +VIR_ENUM_DECL(virDomainCacheAssociativity); + +typedef enum { + VIR_DOMAIN_CACHE_POLICY_NONE, /* No policy */ + VIR_DOMAIN_CACHE_POLICY_WRITEBACK, /* Write-back policy */ + VIR_DOMAIN_CACHE_POLICY_WRITETHROUGH, /* Write-through policy */ + + VIR_DOMAIN_CACHE_POLICY_LAST +} virDomainCachePolicy; +VIR_ENUM_DECL(virDomainCachePolicy); + +typedef enum { + VIR_DOMAIN_NUMA_LATENCY_TYPE_LATENCY, + VIR_DOMAIN_NUMA_LATENCY_TYPE_BANDWIDTH, +} virDomainNumaLatencyType; + +typedef enum { + VIR_DOMAIN_MEMORY_LATENCY_NONE =3D 0, /* No memory latency defined */ + VIR_DOMAIN_MEMORY_LATENCY_ACCESS, /* Access latency */ + VIR_DOMAIN_MEMORY_LATENCY_READ, /* Read latency */ + VIR_DOMAIN_MEMORY_LATENCY_WRITE, /* Write latency */ + + VIR_DOMAIN_MEMORY_LATENCY_LAST +} virDomainMemoryLatency; +VIR_ENUM_DECL(virDomainMemoryLatency); + =20 virDomainNumaPtr virDomainNumaNew(void); void virDomainNumaFree(virDomainNumaPtr numa); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 9f2abc1d8d..65fe1c7f47 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -830,8 +830,14 @@ virNodeDeviceDeleteVport; virNodeDeviceGetParentName; =20 # conf/numa_conf.h +virDomainCacheAssociativityTypeFromString; +virDomainCacheAssociativityTypeToString; +virDomainCachePolicyTypeFromString; +virDomainCachePolicyTypeToString; virDomainMemoryAccessTypeFromString; virDomainMemoryAccessTypeToString; +virDomainMemoryLatencyTypeFromString; +virDomainMemoryLatencyTypeToString; virDomainNumaCheckABIStability; virDomainNumaEquals; virDomainNumaFillCPUsInNode; diff --git a/tests/qemuxml2argvdata/numatune-hmat.xml b/tests/qemuxml2argvd= ata/numatune-hmat.xml new file mode 100644 index 0000000000..b20ca0e439 --- /dev/null +++ b/tests/qemuxml2argvdata/numatune-hmat.xml @@ -0,0 +1,52 @@ + + QEMUGuest + c7a5fdb2-cdaf-9455-926a-d65c16db1809 + 8388608 + 8388608 + 12 + + hvm + + + + + + + + + + + + + + + + + + + + + + + + + + + + + destroy + restart + restart + + /usr/bin/qemu-system-x86_64 + +

+ + + + + +
+ + + diff --git a/tests/qemuxml2xmloutdata/numatune-hmat.xml b/tests/qemuxml2xml= outdata/numatune-hmat.xml new file mode 120000 index 0000000000..6903a80ab1 --- /dev/null +++ b/tests/qemuxml2xmloutdata/numatune-hmat.xml @@ -0,0 +1 @@ +../qemuxml2argvdata/numatune-hmat.xml \ No newline at end of file diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 376c427415..103ce155a4 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -1106,6 +1106,7 @@ mymain(void) DO_TEST("numatune-memnode-no-memory", QEMU_CAPS_OBJECT_MEMORY_FILE); DO_TEST("numatune-distances", QEMU_CAPS_NUMA, QEMU_CAPS_NUMA_DIST); DO_TEST("numatune-no-vcpu", QEMU_CAPS_NUMA); + DO_TEST("numatune-hmat", NONE); =20 DO_TEST("bios-nvram", NONE); DO_TEST("bios-nvram-os-interleave", NONE); --=20 2.26.2 From nobody Sat Apr 20 15:07:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593006585; cv=none; d=zohomail.com; s=zohoarc; b=VYEqyrhaElff4S9pcHXBGG1WYB1eRyOIdFWoVqBFbwVpFmOVkSlkcQU+N4luxJmXCqBQ3LPPagr7tn5vfa/L4RVc9JjAMGhyhTOgge0qZMNHWkJfuH0aG/fod4jVolbfawulMlO3fILGOkXRrxLH7a7EAIOZptte1UXVUoXVzJQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593006585; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=w8YW0+8B6mctUVxKFSge+1aCQxnA5CE3PAHJqFcnq/Q=; b=idm38BWVUW3Y6l138tA39nnTF4SzE2MJpTDs+I54BpneGPAsJt62F50eaLpom21GZi2cXxKS4TZzsJd9WWzJye7gxiBhe6cJjiGY8mnKWMuM/R4n1HBoA2KLwYoYBw5Zu34PLTK6nMVprHJ+QVTNrlJaZ3095hxDnxRhsiAlgLY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 159300658518979.45128363128549; Wed, 24 Jun 2020 06:49:45 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-425-Np-eI3iKNFe7gd8uSapsww-1; Wed, 24 Jun 2020 09:49:41 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2E361EC1A9; Wed, 24 Jun 2020 13:49:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0E09517D04; Wed, 24 Jun 2020 13:49:36 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D54F0104918; Wed, 24 Jun 2020 13:49:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05ODnOuc015703 for ; Wed, 24 Jun 2020 09:49:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id A11905DAA0; Wed, 24 Jun 2020 13:49:24 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 228BE5D9DC for ; Wed, 24 Jun 2020 13:49:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593006583; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=w8YW0+8B6mctUVxKFSge+1aCQxnA5CE3PAHJqFcnq/Q=; b=HRSPj2nP61CGP+lhcK2RPFcuQFKWp1G413dsh98H9m86I+0QLg8wsJqNUUJEvmmztsvbye 8jhv6LjTBnonH74OrJqazB7GZMo0yoN7MYfV42OMz7shbD8Kf65M3hNszvS6PWdpjtsFS7 X7sErZzXn79WAPWH4OpzSgvMvl2AIEs= X-MC-Unique: Np-eI3iKNFe7gd8uSapsww-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 09/13] conf: Validate NUMA HMAT configuration Date: Wed, 24 Jun 2020 15:49:07 +0200 Message-Id: <57be78b6c05e118caa87a3b3d64596ce448fb71f.1593006346.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" There are several restrictions, for instance @initiator and @target have to refer to existing NUMA nodes (daa), @cache has to refer to a defined cache level and so on. Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 3 ++ src/conf/numa_conf.c | 99 ++++++++++++++++++++++++++++++++++++++++++ src/conf/numa_conf.h | 1 + 3 files changed, 103 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ce75831037..0d73968221 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7321,6 +7321,9 @@ virDomainDefValidateInternal(const virDomainDef *def, if (virDomainDefCputuneValidate(def) < 0) return -1; =20 + if (virDomainNumaDefValidate(def->numa) < 0) + return -1; + return 0; } =20 diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index f510dfebce..bf8442eada 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -1363,6 +1363,105 @@ virDomainNumaDefFormatXML(virBufferPtr buf, } =20 =20 +int +virDomainNumaDefValidate(const virDomainNuma *def) +{ + size_t i; + size_t j; + + if (!def) + return 0; + + for (i =3D 0; i < def->nmem_nodes; i++) { + const virDomainNumaNode *node =3D &def->mem_nodes[i]; + g_autoptr(virBitmap) levelsSeen =3D virBitmapNewEmpty(); + + for (j =3D 0; j < node->ncaches; j++) { + const virDomainNumaCache *cache =3D &node->caches[j]; + + /* Relax this if there's ever fourth layer of cache */ + if (cache->level > 3) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Ain't nobody heard of that much cache le= vel")); + return -1; + } + + if (virBitmapIsBitSet(levelsSeen, cache->level)) { + virReportError(VIR_ERR_XML_ERROR, + _("Cache level '%u' already defined"), + cache->level); + return -1; + } + + if (virBitmapSetBitExpand(levelsSeen, cache->level)) + return -1; + } + } + + for (i =3D 0; i < def->nlatencies; i++) { + const virDomainNumaLatency *l =3D &def->latencies[i]; + + if (l->initiator >=3D def->nmem_nodes) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("'initiator' refers to a non-existent NUMA no= de")); + return -1; + } + + if (l->target >=3D def->nmem_nodes) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("'target' refers to a non-existent NUMA node"= )); + return -1; + } + + if (!def->mem_nodes[l->initiator].cpumask) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("NUMA nodes without CPUs can't be initiator")= ); + return -1; + } + + if (l->cache > 0) { + for (j =3D 0; j < def->mem_nodes[l->target].ncaches; j++) { + const virDomainNumaCache *cache =3D def->mem_nodes[l->targ= et].caches; + + if (l->cache =3D=3D cache->level) + break; + } + + if (j =3D=3D def->mem_nodes[l->target].ncaches) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("'cache' refers to a non-existent NUMA no= de cache")); + return -1; + } + } + + for (j =3D 0; j < i; j++) { + virDomainNumaLatencyPtr ll =3D &def->latencies[j]; + + if (l->type =3D=3D ll->type && + l->initiator =3D=3D ll->initiator && + l->target =3D=3D ll->target && + l->cache =3D=3D ll->cache && + l->accessType =3D=3D ll->accessType) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Duplicate info for NUMA latencies")); + return -1; + } + + + if (l->initiator !=3D l->target && + l->initiator =3D=3D ll->target && + l->target =3D=3D ll->initiator) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Link already defined")); + return -1; + } + } + } + + return 0; +} + + unsigned int virDomainNumaGetCPUCountTotal(virDomainNumaPtr numa) { diff --git a/src/conf/numa_conf.h b/src/conf/numa_conf.h index a7dc3190d3..6d6e9de551 100644 --- a/src/conf/numa_conf.h +++ b/src/conf/numa_conf.h @@ -216,6 +216,7 @@ bool virDomainNumatuneNodeSpecified(virDomainNumaPtr nu= matune, =20 int virDomainNumaDefParseXML(virDomainNumaPtr def, xmlXPathContextPtr ctxt= ); int virDomainNumaDefFormatXML(virBufferPtr buf, virDomainNumaPtr def); +int virDomainNumaDefValidate(const virDomainNuma *def); =20 unsigned int virDomainNumaGetCPUCountTotal(virDomainNumaPtr numa); =20 --=20 2.26.2 From nobody Sat Apr 20 15:07:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593006664; cv=none; d=zohomail.com; s=zohoarc; b=MgLuh5gDGYAfpFbVb8APOURh0AR8vOKPntG6SdPmWkYiXUkis5svntCCE+t/x66C8L+z8uLcf4pTrVUCCz3tgYPFdZz/4gZJ8j8OyCEF/LHqe0A0YqS0iPzstNfBP1cm48x7/RUp8Ji889afabXtUOPLNZ8C7WsMCTYY8lnuzgw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593006664; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eLamU5CsJyLLsel5nHr2gf578eXGqGLWvrVsWGuk/BM=; b=fE96Iv9Rwc6pMbHi56tMBYUSVAfCkW9qpQCuKxLKXIeOYJrgImUMtoh4moGhT8aQxIEPni28J5m/gOaw/vp6gJgn8VugLF5TSZ5KZuZMYINEHeRFL4OKxyB36S3s/+/xdjDAfO0QmuGdvxFbnbkZ1t7/fj6bIj946ATM1tUSj+8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1593006664426104.79638422159519; Wed, 24 Jun 2020 06:51:04 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-92-CyTddmpDPDG2n-dx1_-x9Q-1; Wed, 24 Jun 2020 09:49:45 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5B333107B277; Wed, 24 Jun 2020 13:49:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3E56879305; Wed, 24 Jun 2020 13:49:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 0E00C1809563; Wed, 24 Jun 2020 13:49:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05ODnPtb015713 for ; Wed, 24 Jun 2020 09:49:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7DCB25DA27; Wed, 24 Jun 2020 13:49:25 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id F37665D9DC for ; Wed, 24 Jun 2020 13:49:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593006663; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=eLamU5CsJyLLsel5nHr2gf578eXGqGLWvrVsWGuk/BM=; b=WinBL3rkIIYx77I7TLPK21KWsltqKxSeWqKPC5U1dwlVeI3+ROmaeadqgU+Xmny0VCoDsm vbaPdhKHH0jGqV7Z86Uh3qFqKOuEjWiVTimMtzXOI+D5ZfVmYBCb7vX7/OHGgUAFfjHc+b Qt0r+DKcJyjLUBU7hmwlhxWnHkBpA2Q= X-MC-Unique: CyTddmpDPDG2n-dx1_-x9Q-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 10/13] numa: expose HMAT APIs Date: Wed, 24 Jun 2020 15:49:08 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" These APIs will be used by QEMU driver when building the command line. Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- src/conf/numa_conf.c | 139 +++++++++++++++++++++++++++++++++++++++ src/conf/numa_conf.h | 28 ++++++++ src/libvirt_private.syms | 6 ++ 3 files changed, 173 insertions(+) diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index bf8442eada..b35e5040fc 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -1829,3 +1829,142 @@ virDomainNumaFillCPUsInNode(virDomainNumaPtr numa, =20 return 0; } + + +bool +virDomainNumaHasHMAT(const virDomainNuma *numa) +{ + size_t i; + + if (!numa) + return false; + + if (numa->nlatencies) + return true; + + for (i =3D 0; i < numa->nmem_nodes; i++) { + if (numa->mem_nodes[i].ncaches) + return true; + } + + return false; +} + + +size_t +virDomainNumaGetNodeCacheCount(const virDomainNuma *numa, + size_t node) +{ + if (!numa || node >=3D numa->nmem_nodes) + return 0; + + return numa->mem_nodes[node].ncaches; +} + + +int +virDomainNumaGetNodeCache(const virDomainNuma *numa, + size_t node, + size_t cache, + unsigned int *level, + unsigned int *size, + unsigned int *line, + virDomainCacheAssociativity *associativity, + virDomainCachePolicy *policy) +{ + const virDomainNumaNode *cell; + + if (!numa || node >=3D numa->nmem_nodes) + return -1; + + cell =3D &numa->mem_nodes[node]; + + if (cache >=3D cell->ncaches) + return -1; + + *level =3D cell->caches[cache].level; + *size =3D cell->caches[cache].size; + *line =3D cell->caches[cache].line; + *associativity =3D cell->caches[cache].associativity; + *policy =3D cell->caches[cache].policy; + return 0; +} + + +ssize_t +virDomainNumaGetNodeInitiator(const virDomainNuma *numa, + size_t node) +{ + size_t i; + unsigned int maxBandwidth =3D 0; + ssize_t candidateBandwidth =3D -1; + unsigned int minLatency =3D UINT_MAX; + ssize_t candidateLatency =3D -1; + + if (!numa || node >=3D numa->nmem_nodes) + return -1; + + for (i =3D 0; i < numa->nlatencies; i++) { + const virDomainNumaLatency *l =3D &numa->latencies[i]; + + if (l->target !=3D node) + continue; + + switch (l->type) { + case VIR_DOMAIN_NUMA_LATENCY_TYPE_LATENCY: + if (l->value < minLatency) { + minLatency =3D l->value; + candidateLatency =3D l->initiator; + } + break; + + case VIR_DOMAIN_NUMA_LATENCY_TYPE_BANDWIDTH: + if (l->value > maxBandwidth) { + maxBandwidth =3D l->value; + candidateBandwidth =3D l->initiator; + } + break; + } + } + + if (candidateLatency >=3D 0) + return candidateLatency; + + return candidateBandwidth; +} + + +size_t +virDomainNumaGetLatenciesCount(const virDomainNuma *numa) +{ + if (!numa) + return 0; + + return numa->nlatencies; +} + + +int +virDomainNumaGetLatency(const virDomainNuma *numa, + size_t i, + virDomainNumaLatencyType *type, + unsigned int *initiator, + unsigned int *target, + unsigned int *cache, + virDomainMemoryLatency *accessType, + unsigned long *value) +{ + const virDomainNumaLatency *l; + + if (!numa || i >=3D numa->nlatencies) + return -1; + + l =3D &numa->latencies[i]; + *type =3D l->type; + *initiator =3D l->initiator; + *target =3D l->target; + *cache =3D l->cache; + *accessType =3D l->accessType; + *value =3D l->value; + return 0; +} diff --git a/src/conf/numa_conf.h b/src/conf/numa_conf.h index 6d6e9de551..b150fe4037 100644 --- a/src/conf/numa_conf.h +++ b/src/conf/numa_conf.h @@ -222,3 +222,31 @@ unsigned int virDomainNumaGetCPUCountTotal(virDomainNu= maPtr numa); =20 int virDomainNumaFillCPUsInNode(virDomainNumaPtr numa, size_t node, unsigned int maxCpus); + +bool virDomainNumaHasHMAT(const virDomainNuma *numa); + +size_t virDomainNumaGetNodeCacheCount(const virDomainNuma *numa, + size_t node); + +int virDomainNumaGetNodeCache(const virDomainNuma *numa, + size_t node, + size_t cache, + unsigned int *level, + unsigned int *size, + unsigned int *line, + virDomainCacheAssociativity *associativity, + virDomainCachePolicy *policy); + +ssize_t virDomainNumaGetNodeInitiator(const virDomainNuma *numa, + size_t node); + +size_t virDomainNumaGetLatenciesCount(const virDomainNuma *numa); + +int virDomainNumaGetLatency(const virDomainNuma *numa, + size_t i, + virDomainNumaLatencyType *type, + unsigned int *initiator, + unsigned int *target, + unsigned int *cache, + virDomainMemoryLatency *accessType, + unsigned long *value); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 65fe1c7f47..41e61e9b4d 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -843,14 +843,20 @@ virDomainNumaEquals; virDomainNumaFillCPUsInNode; virDomainNumaFree; virDomainNumaGetCPUCountTotal; +virDomainNumaGetLatenciesCount; +virDomainNumaGetLatency; virDomainNumaGetMaxCPUID; virDomainNumaGetMemorySize; +virDomainNumaGetNodeCache; +virDomainNumaGetNodeCacheCount; virDomainNumaGetNodeCount; virDomainNumaGetNodeCpumask; virDomainNumaGetNodeDiscard; virDomainNumaGetNodeDistance; +virDomainNumaGetNodeInitiator; virDomainNumaGetNodeMemoryAccessMode; virDomainNumaGetNodeMemorySize; +virDomainNumaHasHMAT; virDomainNumaNew; virDomainNumaNodeDistanceIsUsingDefaults; virDomainNumaNodesDistancesAreBeingSet; --=20 2.26.2 From nobody Sat Apr 20 15:07:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593006597; cv=none; d=zohomail.com; s=zohoarc; b=ODRcaE3qi3q+yTTJ64IAk7r5IQVEZStDzJZqUVN9rgS8Dbr4MUARU0fObUI1ky9a/eWJUl0x2D6HCg10bnus2rQfeYdvtR+N3MaXUQjOZvoPJO+GtM5mXLyDM5gCDI7XTVRECvl3UMptU6xkfnerTwgW48ShDgt8K4bjPUMX4Z8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593006597; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DwGRMRHWhDjAhhnuk9FCKlFzK4tcVDXwK4ui05jQZKc=; b=A3Cny3nH3yBKauO3Bzh0RMD+6ln78nBNKRBrQTyK1sJMZWQA6P3HtDdhCpPTxEzNbWOZWV8gjahqwhQD+/pTdF6sJJfowKmpJSJsARPVTon/Jnbv0MqvcxlqvZefRFdGYno2B2Uq9y0HHIZpsSt+unMIiowDxDon+lVxn1PWozE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1593006597196259.6318132742082; Wed, 24 Jun 2020 06:49:57 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-510-V6OwI9AhMzaisdzacUzUKA-1; Wed, 24 Jun 2020 09:49:53 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C11F2804019; Wed, 24 Jun 2020 13:49:43 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A24B85C240; Wed, 24 Jun 2020 13:49:43 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 74A2F1805309; Wed, 24 Jun 2020 13:49:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05ODnQRK015724 for ; Wed, 24 Jun 2020 09:49:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5B1085DA27; Wed, 24 Jun 2020 13:49:26 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id D054E5D9DC for ; Wed, 24 Jun 2020 13:49:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593006596; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=DwGRMRHWhDjAhhnuk9FCKlFzK4tcVDXwK4ui05jQZKc=; b=Ls3EIaBeLDvsqM1se+eg+rH1Qun9cbdyIssQjCvyDLPq1bi8MOOi0D4yX21Ra8BBKdUczL /0uHBxZbNYYsVvU+9NMaaMYez6BjWi2D1snz3kjwVTk29l/eT2Y2P3qrfvbYLnmxtYANeA nzau5iAVKiPdni70HsH+2aDqkV8gGwM= X-MC-Unique: V6OwI9AhMzaisdzacUzUKA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 11/13] qemu: Introduce QEMU_CAPS_NUMA_HMAT capability Date: Wed, 24 Jun 2020 15:49:09 +0200 Message-Id: <2a10d965efac63e26aa67013450866e71c6a346f.1593006346.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This capability tracks whether QEMU is capable of defining HMAT ACPI table for the guest. Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml | 1 + tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml | 1 + tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml | 1 + tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml | 1 + tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml | 1 + 7 files changed, 8 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index fc502ff8e4..66a663f827 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -595,6 +595,7 @@ VIR_ENUM_IMPL(virQEMUCaps, "migration-param.xbzrle-cache-size", "intel-iommu.aw-bits", "spapr-tpm-proxy", + "numa.hmat", ); =20 =20 @@ -1522,6 +1523,7 @@ static struct virQEMUCapsStringFlags virQEMUCapsQMPSc= hemaQueries[] =3D { { "migrate-set-parameters/arg-type/max-bandwidth", QEMU_CAPS_MIGRATION= _PARAM_BANDWIDTH }, { "migrate-set-parameters/arg-type/downtime-limit", QEMU_CAPS_MIGRATIO= N_PARAM_DOWNTIME }, { "migrate-set-parameters/arg-type/xbzrle-cache-size", QEMU_CAPS_MIGRA= TION_PARAM_XBZRLE_CACHE_SIZE }, + { "set-numa-node/arg-type/+hmat-lb", QEMU_CAPS_NUMA_HMAT }, }; =20 typedef struct _virQEMUCapsObjectTypeProps virQEMUCapsObjectTypeProps; diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 0bf46d493e..7d9b2ac7db 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -575,6 +575,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for = syntax-check */ QEMU_CAPS_MIGRATION_PARAM_XBZRLE_CACHE_SIZE, /* xbzrle-cache-size fiel= d in migrate-set-parameters */ QEMU_CAPS_INTEL_IOMMU_AW_BITS, /* intel-iommu.aw-bits */ QEMU_CAPS_DEVICE_SPAPR_TPM_PROXY, /* -device spapr-tpm-proxy */ + QEMU_CAPS_NUMA_HMAT, /* -numa hmat */ =20 QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml b/tests/qemu= capabilitiesdata/caps_5.0.0.aarch64.xml index f2d691734f..9446ddc22a 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.aarch64.xml @@ -197,6 +197,7 @@ + 5000000 0 61700241 diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml b/tests/qemuca= pabilitiesdata/caps_5.0.0.ppc64.xml index f5d6e0679e..8c371a045b 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.ppc64.xml @@ -206,6 +206,7 @@ + 5000000 0 42900241 diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml b/tests/qemu= capabilitiesdata/caps_5.0.0.riscv64.xml index 3119f6deb7..15c9d54332 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.riscv64.xml @@ -193,6 +193,7 @@ + 5000000 0 0 diff --git a/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_5.0.0.x86_64.xml index da53abc857..dafca26b89 100644 --- a/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_5.0.0.x86_64.xml @@ -241,6 +241,7 @@ + 5000000 0 43100241 diff --git a/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_5.1.0.x86_64.xml index b7058ee597..bd6e83ccaf 100644 --- a/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_5.1.0.x86_64.xml @@ -241,6 +241,7 @@ + 5000050 0 43100242 --=20 2.26.2 From nobody Sat Apr 20 15:07:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593006594; cv=none; d=zohomail.com; s=zohoarc; b=X3TNkjJcnr1z5bvV7J926MMaNOFxTH0S76HA9xP8FrLylrYvOePiEgfeusYOjmWW1vZfc3AHH/2Kae+j+hJKLz/ssb6ztta0FQwVBNBqT9SwSaLOwGlNqO1J/NOxjIFyMcqHbYy/TWGMWkZ93fhNOZ4/l+Gl9VYysMQDEOn5y68= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593006594; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qmgXAnts+qY55XYCEOtPO4GR+MWWpQCzU635YFmW4zw=; b=T8u8UPqUo1TFIpSCxdJjlFL/weqFtELFLEPdQca0m8hPR6OCm6hgMUszLit8oT6WJ1EFGqqe9YaoDfCM2nPXrtUONST/J5b7z0NyJ2/Ft/NL5fAU6lhJ5WITEimsorg4aKtJLmyX3KbP+8VKYJcV64b6HvNcHha/FRfpeAvcIAQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1593006594848685.1752508953771; Wed, 24 Jun 2020 06:49:54 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-77-1jugvUbuOfmceudOxFZwlA-1; Wed, 24 Jun 2020 09:49:49 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C67DC107ACF5; Wed, 24 Jun 2020 13:49:40 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A423F2B47E; Wed, 24 Jun 2020 13:49:40 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6C57D1806B0D; Wed, 24 Jun 2020 13:49:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05ODnRdG015734 for ; Wed, 24 Jun 2020 09:49:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 384115DA27; Wed, 24 Jun 2020 13:49:27 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD1045D9DC for ; Wed, 24 Jun 2020 13:49:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593006592; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=qmgXAnts+qY55XYCEOtPO4GR+MWWpQCzU635YFmW4zw=; b=Ark0DtW50ClGbaSIzcV4s3ZwEXUHV9QbWR0gHJNJ89eg698Akwzz7XLbKjfGivFYCMZkp0 6nGRfzUI3DvXeiK1450CP5JTuKThjj0/aXLaIcVvyWiIV2Rq2dyIZOWPsMNjGwpDcA4G+Z DGaOBNby7zKPXzvdmXFncITY6LszIdU= X-MC-Unique: 1jugvUbuOfmceudOxFZwlA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 12/13] qemu: Build HMAT command line Date: Wed, 24 Jun 2020 15:49:10 +0200 Message-Id: <22d7cec7fb17765bba75cbd787af03528e8460fe.1593006346.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1786303 Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- src/conf/numa_conf.c | 7 + src/qemu/qemu_command.c | 183 ++++++++++++++++++ .../numatune-hmat.x86_64-latest.args | 53 +++++ tests/qemuxml2argvtest.c | 1 + 4 files changed, 244 insertions(+) create mode 100644 tests/qemuxml2argvdata/numatune-hmat.x86_64-latest.args diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index b35e5040fc..7fbbe0f52e 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -1904,6 +1904,13 @@ virDomainNumaGetNodeInitiator(const virDomainNuma *n= uma, if (!numa || node >=3D numa->nmem_nodes) return -1; =20 + /* A NUMA node which has at least one vCPU is initiator to itself by + * definition. */ + if (numa->mem_nodes[node].cpumask) + return node; + + /* For the rest, "NUMA node that has best performance (the lowest + * latency or largest bandwidth) to this NUMA node." */ for (i =3D 0; i < numa->nlatencies; i++) { const virDomainNumaLatency *l =3D &numa->latencies[i]; =20 diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 628ff970bd..b28c43f110 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6932,6 +6932,16 @@ qemuBuildMachineCommandLine(virCommandPtr cmd, virBufferAsprintf(&buf, ",pflash1=3D%s", priv->pflash1->nodefo= rmat); } =20 + if (virDomainNumaHasHMAT(def->numa)) { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_NUMA_HMAT)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("HMAT is not supported with this QEMU")); + return -1; + } + + virBufferAddLit(&buf, ",hmat=3Don"); + } + virCommandAddArgBuffer(cmd, &buf); =20 return 0; @@ -7114,6 +7124,134 @@ qemuBuildIOThreadCommandLine(virCommandPtr cmd, } =20 =20 +static int +qemuBuilNumaCellCache(virCommandPtr cmd, + const virDomainDef *def, + size_t cell) +{ + size_t ncaches =3D virDomainNumaGetNodeCacheCount(def->numa, cell); + size_t i; + + if (ncaches =3D=3D 0) + return 0; + + for (i =3D 0; i < ncaches; i++) { + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + unsigned int level; + unsigned int size; + unsigned int line; + virDomainCacheAssociativity associativity; + virDomainCachePolicy policy; + + if (virDomainNumaGetNodeCache(def->numa, cell, i, + &level, &size, &line, + &associativity, &policy) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to format NUMA node cache")); + return -1; + } + + virBufferAsprintf(&buf, + "hmat-cache,node-id=3D%zu,size=3D%uK,level=3D%u", + cell, size, level); + + switch (associativity) { + case VIR_DOMAIN_CACHE_ASSOCIATIVITY_NONE: + virBufferAddLit(&buf, ",associativity=3Dnone"); + break; + case VIR_DOMAIN_CACHE_ASSOCIATIVITY_DIRECT: + virBufferAddLit(&buf, ",associativity=3Ddirect"); + break; + case VIR_DOMAIN_CACHE_ASSOCIATIVITY_FULL: + virBufferAddLit(&buf, ",associativity=3Dcomplex"); + break; + case VIR_DOMAIN_CACHE_ASSOCIATIVITY_LAST: + break; + } + + switch (policy) { + case VIR_DOMAIN_CACHE_POLICY_NONE: + virBufferAddLit(&buf, ",policy=3Dnone"); + break; + case VIR_DOMAIN_CACHE_POLICY_WRITEBACK: + virBufferAddLit(&buf, ",policy=3Dwrite-back"); + break; + case VIR_DOMAIN_CACHE_POLICY_WRITETHROUGH: + virBufferAddLit(&buf, ",policy=3Dwrite-through"); + break; + case VIR_DOMAIN_CACHE_POLICY_LAST: + break; + } + + if (line > 0) + virBufferAsprintf(&buf, ",line=3D%u", line); + + virCommandAddArg(cmd, "-numa"); + virCommandAddArgBuffer(cmd, &buf); + } + + return 0; +} + + +VIR_ENUM_DECL(qemuDomainMemoryHierarchy); +VIR_ENUM_IMPL(qemuDomainMemoryHierarchy, + 4, /* Maximum level of cache */ + "memory", /* Special case, whole memory not specific cache */ + "first-level", + "second-level", + "third-level"); + +static int +qemuBuildNumaHMATCommandLine(virCommandPtr cmd, + const virDomainDef *def) +{ + size_t nlatencies; + size_t i; + + if (!def->numa) + return 0; + + nlatencies =3D virDomainNumaGetLatenciesCount(def->numa); + for (i =3D 0; i < nlatencies; i++) { + g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + virDomainNumaLatencyType type; + unsigned int initiator; + unsigned int target; + unsigned int cache; + virDomainMemoryLatency accessType; + unsigned long value; + const char *hierarchyStr; + const char *accessStr; + + if (virDomainNumaGetLatency(def->numa, i, + &type, &initiator, &target, + &cache, &accessType, &value) < 0) + return -1; + + hierarchyStr =3D qemuDomainMemoryHierarchyTypeToString(cache); + accessStr =3D virDomainMemoryLatencyTypeToString(accessType); + virBufferAsprintf(&buf, + "hmat-lb,initiator=3D%u,target=3D%u,hierarchy=3D= %s,data-type=3D%s-", + initiator, target, hierarchyStr, accessStr); + + switch (type) { + case VIR_DOMAIN_NUMA_LATENCY_TYPE_LATENCY: + virBufferAsprintf(&buf, "latency,latency=3D%lu", value); + break; + case VIR_DOMAIN_NUMA_LATENCY_TYPE_BANDWIDTH: + virBufferAsprintf(&buf, "bandwidth,bandwidth=3D%luK", value); + break; + } + + virCommandAddArg(cmd, "-numa"); + virCommandAddArgBuffer(cmd, &buf); + } + + return 0; +} + + static int qemuBuildNumaCommandLine(virQEMUDriverConfigPtr cfg, virDomainDefPtr def, @@ -7126,9 +7264,11 @@ qemuBuildNumaCommandLine(virQEMUDriverConfigPtr cfg, char *next =3D NULL; virBufferPtr nodeBackends =3D NULL; bool needBackend =3D false; + bool hmat =3D false; int rc; int ret =3D -1; size_t ncells =3D virDomainNumaGetNodeCount(def->numa); + ssize_t masterInitiator =3D -1; =20 if (!virDomainNumatuneNodesetIsAvailable(def->numa, priv->autoNodeset)) goto cleanup; @@ -7138,6 +7278,16 @@ qemuBuildNumaCommandLine(virQEMUDriverConfigPtr cfg, def->os.machine)) needBackend =3D true; =20 + if (virDomainNumaHasHMAT(def->numa)) { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_NUMA_HMAT)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("HMAT is not supported with this QEMU")); + goto cleanup; + } + needBackend =3D true; + hmat =3D true; + } + if (VIR_ALLOC_N(nodeBackends, ncells) < 0) goto cleanup; =20 @@ -7166,8 +7316,22 @@ qemuBuildNumaCommandLine(virQEMUDriverConfigPtr cfg, qemuBuildMemPathStr(def, cmd, priv) < 0) goto cleanup; =20 + for (i =3D 0; i < ncells; i++) { + if (virDomainNumaGetNodeCpumask(def->numa, i)) { + masterInitiator =3D i; + break; + } + } + + if (masterInitiator) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("At least one NUMA node has to have CPUs")); + goto cleanup; + } + for (i =3D 0; i < ncells; i++) { virBitmapPtr cpumask =3D virDomainNumaGetNodeCpumask(def->numa, i); + ssize_t initiator =3D virDomainNumaGetNodeInitiator(def->numa, i); =20 if (needBackend) { virCommandAddArg(cmd, "-object"); @@ -7192,6 +7356,13 @@ qemuBuildNumaCommandLine(virQEMUDriverConfigPtr cfg, } } =20 + if (hmat) { + if (initiator < 0) + initiator =3D masterInitiator; + + virBufferAsprintf(&buf, ",initiator=3D%zd", initiator); + } + if (needBackend) virBufferAsprintf(&buf, ",memdev=3Dram-node%zu", i); else @@ -7217,6 +7388,18 @@ qemuBuildNumaCommandLine(virQEMUDriverConfigPtr cfg, } } =20 + if (hmat) { + if (qemuBuildNumaHMATCommandLine(cmd, def) < 0) + goto cleanup; + + /* This can't be moved into any of the loops above, + * because hmat-cache can be specified only after hmat-lb. */ + for (i =3D 0; i < ncells; i++) { + if (qemuBuilNumaCellCache(cmd, def, i) < 0) + goto cleanup; + } + } + ret =3D 0; =20 cleanup: diff --git a/tests/qemuxml2argvdata/numatune-hmat.x86_64-latest.args b/test= s/qemuxml2argvdata/numatune-hmat.x86_64-latest.args new file mode 100644 index 0000000000..c52015caa8 --- /dev/null +++ b/tests/qemuxml2argvdata/numatune-hmat.x86_64-latest.args @@ -0,0 +1,53 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-QEMUGuest \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-QEMUGuest/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-QEMUGuest/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-QEMUGuest/.config \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3DQEMUGuest,debug-threads=3Don \ +-S \ +-object secret,id=3DmasterKey0,format=3Draw,\ +file=3D/tmp/lib/domain--1-QEMUGuest/master-key.aes \ +-machine pc,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff,hmat=3Don \ +-cpu qemu64 \ +-m 12288 \ +-overcommit mem-lock=3Doff \ +-smp 12,sockets=3D12,cores=3D1,threads=3D1 \ +-object memory-backend-ram,id=3Dram-node0,size=3D2147483648 \ +-numa node,nodeid=3D0,cpus=3D0-3,initiator=3D0,memdev=3Dram-node0 \ +-object memory-backend-ram,id=3Dram-node1,size=3D2147483648 \ +-numa node,nodeid=3D1,cpus=3D4-7,initiator=3D1,memdev=3Dram-node1 \ +-object memory-backend-ram,id=3Dram-node2,size=3D2147483648 \ +-numa node,nodeid=3D2,cpus=3D8-11,initiator=3D2,memdev=3Dram-node2 \ +-object memory-backend-ram,id=3Dram-node3,size=3D2147483648 \ +-numa node,nodeid=3D3,initiator=3D0,memdev=3Dram-node3 \ +-object memory-backend-ram,id=3Dram-node4,size=3D2147483648 \ +-numa node,nodeid=3D4,initiator=3D0,memdev=3Dram-node4 \ +-object memory-backend-ram,id=3Dram-node5,size=3D2147483648 \ +-numa node,nodeid=3D5,initiator=3D0,memdev=3Dram-node5 \ +-numa hmat-lb,initiator=3D0,target=3D0,hierarchy=3Dmemory,data-type=3Dacce= ss-latency,\ +latency=3D5 \ +-numa hmat-lb,initiator=3D0,target=3D0,hierarchy=3Dfirst-level,\ +data-type=3Daccess-latency,latency=3D10 \ +-numa hmat-lb,initiator=3D0,target=3D0,hierarchy=3Dmemory,data-type=3Dacce= ss-bandwidth,\ +bandwidth=3D204800K \ +-numa hmat-cache,node-id=3D0,size=3D10K,level=3D1,associativity=3Ddirect,\ +policy=3Dwrite-back,line=3D8 \ +-uuid c7a5fdb2-cdaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-boot strict=3Don \ +-device piix3-usb-uhci,id=3Dusb,bus=3Dpci.0,addr=3D0x1.0x2 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x3 \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ +resourcecontrol=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 98d9a7b5b2..3fdcd41317 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1913,6 +1913,7 @@ mymain(void) =20 DO_TEST("numatune-distances", QEMU_CAPS_NUMA, QEMU_CAPS_NUMA_DIST); DO_TEST("numatune-no-vcpu", NONE); + DO_TEST_CAPS_LATEST("numatune-hmat"); =20 DO_TEST("numatune-auto-nodeset-invalid", NONE); DO_TEST("numatune-auto-prefer", QEMU_CAPS_OBJECT_MEMORY_RAM, --=20 2.26.2 From nobody Sat Apr 20 15:07:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593006596; cv=none; d=zohomail.com; s=zohoarc; b=IAZ+1ujL1syfSyfOmBdQVsD47BjDI6MKAZTZg9BdbGKtSmJY+GhprgtuZqKjUW7jP+cIqzDdR9uiFNoN3mtW/mGpXUyD/toX4ry6fK547JDWdnzGccLJD/9m1dtUCtwl6XZbuCRL2qeygVSakafXWe/Y2liHMwTHlPIeNEJfCAc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593006596; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AwB70TOHk94Wcn9DRu8ULgsmZos9Mnvgjhf+lMHpPdI=; b=Azla+/iU6FraWBBGUeW/fg/43jyAVX7RqoArncG/tTKoi58qcOg0xfNLPf/cmUfk96S6nBLHma8+PQcuKeK2Sw6gpDN8CzPn0cRRMx+lnYtNPEELgScSKO5Yxy8bFrPQva9xTpp94Bwovej6+KIgzjc7qWg6cGUtmIl9qyureoA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1593006596921912.863032909218; Wed, 24 Jun 2020 06:49:56 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-240-paxQNuj6MSOSdteZOE4yGA-1; Wed, 24 Jun 2020 09:49:53 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 13A8B107B27A; Wed, 24 Jun 2020 13:49:46 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E87D25C240; Wed, 24 Jun 2020 13:49:45 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id BA85987543; Wed, 24 Jun 2020 13:49:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05ODnSiB015743 for ; Wed, 24 Jun 2020 09:49:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 150B05DA27; Wed, 24 Jun 2020 13:49:28 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A4FB5D9DC for ; Wed, 24 Jun 2020 13:49:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593006595; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=AwB70TOHk94Wcn9DRu8ULgsmZos9Mnvgjhf+lMHpPdI=; b=NnI5GlmOBk0va/yfmWCquz+VRj5wBhwp86D/2FqmsSMNPjnQmw1Im0ZJbR2YqSkr2YfQOf sYRlD2D+VNUqSiK7yvBpnUJFwAqRf5QjtuYMgQ4ej0bV5nSaljcUmVRyDPxpEoPE9xGCd7 xiZ0odfoPPkCbyFgddiqJV3jFqngZHE= X-MC-Unique: paxQNuj6MSOSdteZOE4yGA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 13/13] news: Document HMAT addition Date: Wed, 24 Jun 2020 15:49:11 +0200 Message-Id: <14a0099316c0efa4ec37ffc30f648e1a0e213487.1593006346.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Michal Privoznik Reviewed-by: Daniel Henrique Barboza --- NEWS.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS.rst b/NEWS.rst index 2fc43c31b9..8990cdaf61 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -47,6 +47,11 @@ v6.5.0 (unreleased) alphabetical order. Hook script in old place will be executed as first for backward compatibility. =20 + * Allow configuring of NUMA HMAT + + Libvirt allows configuring Heterogeneous Memory Attribute Table to hint + software running inside the guest on optimization. + * **Improvements** =20 * **Bug fixes** --=20 2.26.2