From nobody Fri Apr 19 08:19:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1684226027; cv=none; d=zohomail.com; s=zohoarc; b=Qhm1m8t7x9KpTT/8V587Qi0t+wRZHzL/Oe7tQvFiLtKMWq22n9TTYhbhTjRWcTU+ri78UbiehREFHoDJBnoog6feRLuC4vCkDq6gjA+KJXu95mXkIYFKCV7kSAnBKQ98sm6PbvcUhUt0pb3pN8YyU/AGAROZhQud6hLD/R3YHAc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684226027; 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=GT1a3qw/rBIjPcDmRiSEBgo2C07gdyGw9ipglNCRf3o=; b=g35LoVPRHCbEhq62htZOaJ5CTzGoq+QYLQ4BR7+SbTaYSaJAf+Ml8Q8pgOJ8vF8HyMLvsZS7iN2AxkFm46iHjShzRXFFozT7w517BAgMQMPXsGlDn/tslHUN1WIVPvaks8KvUNvSm9J9BgjP+Bmx9pdbVK0ggt3/YhAFJfbrD5Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1684226027453193.15018141132362; Tue, 16 May 2023 01:33:47 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-196-zYdOpsh5MkSsCvWcUvfLjA-1; Tue, 16 May 2023 04:33:41 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 78D0A86C60A; Tue, 16 May 2023 08:33:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6504E40C6EC4; Tue, 16 May 2023 08:33:39 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3D5E31946595; Tue, 16 May 2023 08:33:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2836D19465BB for ; Tue, 16 May 2023 08:33:23 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1AD324078906; Tue, 16 May 2023 08:33:23 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9617040C6EC4 for ; Tue, 16 May 2023 08:33:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684226026; 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=GT1a3qw/rBIjPcDmRiSEBgo2C07gdyGw9ipglNCRf3o=; b=Z4A11rueo0z6n5XUEvd5rsMXfBxjnDMrRkSlrlhlroor+zMv6LIgq1EMN8SA6drv7/EaQt D4Mb1JIWWP30+cNyf/wIWAETBIL6yh1tRKpW8O9w2Du7QIIyWLg+4hrDV2NnWiRZEfefhq JWPiCfowrY7Qj5W5s4HskjrrfD92hJk= X-MC-Unique: zYdOpsh5MkSsCvWcUvfLjA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/2] virDomainNumaDefNodeCacheParseXML: Refactor parsing of cache XML Date: Tue, 16 May 2023 10:33:19 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1684226028635100001 Content-Type: text/plain; charset="utf-8" Use virXMLProp* helpers to simplify the code. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/numa_conf.c | 60 +++++++++++--------------------------------- 1 file changed, 14 insertions(+), 46 deletions(-) diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index b21671f587..c2e3045280 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -815,68 +815,36 @@ virDomainNumaDefNodeCacheParseXML(virDomainNuma *def, for (i =3D 0; i < n; i++) { VIR_XPATH_NODE_AUTORESTORE(ctxt) virNumaCache *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 f= or NUMA node %1$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 f= or NUMA node %1$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 e= lement for NUMA node %1$d"), - cur_cell); + if (virXMLPropUInt(nodes[i], "level", 10, + VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO, + &cache->level) < 0) return -1; - } - if ((associativity =3D virNumaCacheAssociativityTypeFromString(tmp= )) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Invalid cache associativity '%1$s'"), - tmp); + if (virXMLPropEnum(nodes[i], "associativity", + virNumaCacheAssociativityTypeFromString, + VIR_XML_PROP_REQUIRED, + &cache->associativity) < 0) 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 %1$d"), - cur_cell); - } - if ((policy =3D virNumaCachePolicyTypeFromString(tmp)) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Invalid cache policy '%1$s'"), - tmp); + if (virXMLPropEnum(nodes[i], "policy", + virNumaCachePolicyTypeFromString, + VIR_XML_PROP_REQUIRED, + &cache->policy) < 0) return -1; - } - VIR_FREE(tmp); ctxt->node =3D nodes[i]; if (virDomainParseMemory("./size/@value", "./size/unit", - ctxt, &size, true, false) < 0) + ctxt, &cache->size, true, false) < 0) return -1; if (virParseScaledValue("./line/@value", "./line/unit", ctxt, &line, 1, ULLONG_MAX, true) < 0) return -1; - *cache =3D (virNumaCache){level, size, line, associativity, policy= }; + cache->line =3D line; + def->mem_nodes[cur_cell].ncaches++; } --=20 2.40.1 From nobody Fri Apr 19 08:19:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 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=1684226030; cv=none; d=zohomail.com; s=zohoarc; b=Zz7MWqdTtpP/Mn8eyYbGhpaTNoWJYC8mrhltTOJOUSdYQJ/NdjpfmleAtoQF9AuCsUwFq3GsiLwyBp3xy+Z/hKebHdAOIyLB+Rnu1spqNolaMh/3BwJTpikPb8+/BPcPq9wjhUTYxm4w4cFtQgRK9DD2279Uij1CLYiwJ7SZHRM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1684226030; 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=jaNEcaxxjLTb4S28zCES0Q1IS5S//c93OFirbH9+bVk=; b=G5OOmFbwV8XC8rrvps3v7dKm3+/I+Q6O4bQYpG6l/F/hbuyuGUzuHvS2JuAv+Gr1cikl5q53/b5FPH26VBmH6wqR/r/X5/Fl/hvqh4E0JDtF/g7pcJo/+szbWawin+nsG+UsPLNhyAXFreSh1EUuXa//mFXDGLFpl2UIFOMnViE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1684226030901872.4936448860011; Tue, 16 May 2023 01:33:50 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-541-Vd73b-vXOzG8wcegrIQCPg-1; Tue, 16 May 2023 04:33:48 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E1DD786C61F; Tue, 16 May 2023 08:33:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF531BC88; Tue, 16 May 2023 08:33:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 708ED19465BD; Tue, 16 May 2023 08:33:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0BBCA194658C for ; Tue, 16 May 2023 08:33:24 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id F18D34078906; Tue, 16 May 2023 08:33:23 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6681C40C6EC4 for ; Tue, 16 May 2023 08:33:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684226029; 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=jaNEcaxxjLTb4S28zCES0Q1IS5S//c93OFirbH9+bVk=; b=Ub3UI9hpczRXEMf+2Oy+pSQC4p/vX9NWHsfXeb+N7aQuyqye7gtNIMGloe41B4c9LZo+Vx CkeyWmFd3GKQU2tE55N5HJwUFdHAIE4Mbr4Tyn0QJ8OTyvP5IUTmTOpQd3Wf+O14PbYbfO 9V0Khgu/uBwGSQ3GYtJ7CgdeZtaFVQs= X-MC-Unique: Vd73b-vXOzG8wcegrIQCPg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/2] conf: numa: Allow formatting 'none' values for 'associativity' and 'policy' of cache Date: Tue, 16 May 2023 10:33:20 +0200 Message-Id: <1ef92cccf1f18f275215c15c95f48cf6f0923ae4.1684225967.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1684226032783100001 Content-Type: text/plain; charset="utf-8" The parser makes the values mandatory and also the qemu code implements actions for those values. The formatter skips them though. Since format+parse is used to copy the XML at startup a definition with those values can't be started. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2203709 Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/numa_conf.c | 13 ++--- .../numatune-hmat-none.x86_64-latest.args | 49 +++++++++++++++++ tests/qemuxml2argvdata/numatune-hmat-none.xml | 54 ++++++++++++++++++ tests/qemuxml2argvtest.c | 1 + .../numatune-hmat-none.x86_64-latest.xml | 55 +++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 6 files changed, 164 insertions(+), 9 deletions(-) create mode 100644 tests/qemuxml2argvdata/numatune-hmat-none.x86_64-latest= .args create mode 100644 tests/qemuxml2argvdata/numatune-hmat-none.xml create mode 100644 tests/qemuxml2xmloutdata/numatune-hmat-none.x86_64-late= st.xml diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index c2e3045280..be0c4572c5 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -1708,15 +1708,10 @@ virNumaCacheFormat(virBuffer *buf, g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); virBufferAsprintf(&attrBuf, " level=3D'%u'", cache->level); - if (cache->associativity) { - virBufferAsprintf(&attrBuf, " associativity=3D'%s'", - virNumaCacheAssociativityTypeToString(cache-= >associativity)); - } - - if (cache->policy) { - virBufferAsprintf(&attrBuf, " policy=3D'%s'", - virNumaCachePolicyTypeToString(cache->policy= )); - } + virBufferAsprintf(&attrBuf, " associativity=3D'%s'", + virNumaCacheAssociativityTypeToString(cache->ass= ociativity)); + virBufferAsprintf(&attrBuf, " policy=3D'%s'", + virNumaCachePolicyTypeToString(cache->policy)); virBufferAsprintf(&childBuf, "\n", diff --git a/tests/qemuxml2argvdata/numatune-hmat-none.x86_64-latest.args b= /tests/qemuxml2argvdata/numatune-hmat-none.x86_64-latest.args new file mode 100644 index 0000000000..d61fa1fc70 --- /dev/null +++ b/tests/qemuxml2argvdata/numatune-hmat-none.x86_64-latest.args @@ -0,0 +1,49 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest/.local/share \ +XDG_CACHE_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest/.cache \ +XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3DQEMUGuest,debug-threads=3Don \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/va= r/lib/libvirt/qemu/domain--1-QEMUGuest/master-key.aes"}' \ +-machine pc,usb=3Doff,dump-guest-core=3Doff,hmat=3Don,acpi=3Don \ +-accel tcg \ +-cpu qemu64 \ +-m 12288 \ +-overcommit mem-lock=3Doff \ +-smp 12,sockets=3D12,cores=3D1,threads=3D1 \ +-object '{"qom-type":"memory-backend-ram","id":"ram-node0","size":21474836= 48}' \ +-numa node,nodeid=3D0,cpus=3D0-3,initiator=3D0,memdev=3Dram-node0 \ +-object '{"qom-type":"memory-backend-ram","id":"ram-node1","size":21474836= 48}' \ +-numa node,nodeid=3D1,cpus=3D4-7,initiator=3D1,memdev=3Dram-node1 \ +-object '{"qom-type":"memory-backend-ram","id":"ram-node2","size":21474836= 48}' \ +-numa node,nodeid=3D2,cpus=3D8-11,initiator=3D2,memdev=3Dram-node2 \ +-object '{"qom-type":"memory-backend-ram","id":"ram-node3","size":21474836= 48}' \ +-numa node,nodeid=3D3,initiator=3D0,memdev=3Dram-node3 \ +-object '{"qom-type":"memory-backend-ram","id":"ram-node4","size":21474836= 48}' \ +-numa node,nodeid=3D4,initiator=3D0,memdev=3Dram-node4 \ +-object '{"qom-type":"memory-backend-ram","id":"ram-node5","size":21474836= 48}' \ +-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-lb,initiator=3D0,target=3D0,hierarchy=3Dfirst-level,data-type= =3Daccess-bandwidth,bandwidth=3D208896K \ +-numa hmat-cache,node-id=3D0,size=3D10K,level=3D1,associativity=3Dnone,pol= icy=3Dnone,line=3D8 \ +-uuid c7a5fdb2-cdaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-boot strict=3Don \ +-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x3"}' \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/numatune-hmat-none.xml b/tests/qemuxml2= argvdata/numatune-hmat-none.xml new file mode 100644 index 0000000000..a848397826 --- /dev/null +++ b/tests/qemuxml2argvdata/numatune-hmat-none.xml @@ -0,0 +1,54 @@ + + QEMUGuest + c7a5fdb2-cdaf-9455-926a-d65c16db1809 + 8388608 + 8388608 + 12 + + hvm + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + destroy + restart + restart + + /usr/bin/qemu-system-x86_64 + +
+ + + + +