From nobody Fri May 17 08:39:26 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=1618576960; cv=none; d=zohomail.com; s=zohoarc; b=cjvUIdj2x4FyBQ8xOeDtJzO+Fym/T1c8TWoJcjpo/md7C9VHpd9y0TzZdvTsIGNeIZ0Bi3cT3z9L7RlIlnKvcVI0fj2+k/r+NFIQYiZ7Fa3PRfyXSO67w5USykZdDBFobJ518tDqY3mn0n7yrQ1Mk94ZR6Wc1L9B1Pydey7FdNk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618576960; 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=rohrqy6zpiGps5EmD6ZTUC1AWtspIVo8Tvvv8WtOHG0=; b=WNFK9DIiys6blzIQaAj5Lm/6t0D08iwJF75x+c/+HcRH4LYSsyNYxMIKvjIT9bsYubYdmlSPu5smpPMIWSuH302nl9Oh3ebb00DNgbOSvUPii1oromukuiFey9KR78SmgL6uQoov3AsDMHdhCFEvw9SUhsrHC3wPn1N12mxZv+4= 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) header.from= 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 1618576960425377.5244528121475; Fri, 16 Apr 2021 05:42:40 -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-294-ro4C0AAGOpOTRsR37REZ_A-1; Fri, 16 Apr 2021 08:42:36 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 27E9F10054F6; Fri, 16 Apr 2021 12:42:32 +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 F0EA966A05; Fri, 16 Apr 2021 12:42:31 +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 BAA8B1806D15; Fri, 16 Apr 2021 12:42:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13GCgTgj024536 for ; Fri, 16 Apr 2021 08:42:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id DA5CE37DD; Fri, 16 Apr 2021 12:42:29 +0000 (UTC) Received: from carol.localdomain (unknown [10.40.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8262760C0F for ; Fri, 16 Apr 2021 12:42:26 +0000 (UTC) Received: from carol.redhat.com (carol.k8r.cz [127.0.0.1]) by carol.localdomain (Postfix) with ESMTP id 34191C21096 for ; Fri, 16 Apr 2021 14:42:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618576959; 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=rohrqy6zpiGps5EmD6ZTUC1AWtspIVo8Tvvv8WtOHG0=; b=D3zy0i7n4Dq4GhF1XqcFKXedk32aVN+UC5TStvgqCj72sGXRySrwKxDTqpLDuIq4Xkxgxq jDM8bNj8+0lIGno+l8V0UeAuBJhGUZgfqH1s6qdbAETwxzBdGZQONHnozC9VDGFASjseUi AEXrtZ5d49du1TAUxbM7FeFRxekpYSI= X-MC-Unique: ro4C0AAGOpOTRsR37REZ_A-1 From: Martin Kletzander To: libvir-list@redhat.com Subject: [libvirt PATCH 1/2] conf, docs, schema: Add support for 'restrictive' mode in numatune Date: Fri, 16 Apr 2021 14:42:24 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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.15 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" From: Luyao Zhong This allows users to restrict memory nodes without setting any specific memory policy, then 'restrictive' mode is useful. Reviewed-by: Daniel Henrique Barboza Signed-off-by: Luyao Zhong Signed-off-by: Martin Kletzander Reviewed-by: Michal Privoznik --- docs/formatdomain.rst | 7 +++- docs/schemas/domaincommon.rng | 2 + include/libvirt/libvirt-domain.h | 1 + src/conf/numa_conf.c | 9 ++++ src/qemu/qemu_command.c | 1 + src/util/virnuma.c | 3 ++ .../numatune-memnode-invalid-mode.err | 1 + .../numatune-memnode-invalid-mode.xml | 33 +++++++++++++++ .../numatune-memnode-restrictive-mode.xml | 41 +++++++++++++++++++ tests/qemuxml2argvtest.c | 1 + ...memnode-restrictive-mode.x86_64-latest.xml | 1 + tests/qemuxml2xmltest.c | 1 + 12 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/numatune-memnode-invalid-mode.err create mode 100644 tests/qemuxml2argvdata/numatune-memnode-invalid-mode.xml create mode 100644 tests/qemuxml2argvdata/numatune-memnode-restrictive-mod= e.xml create mode 120000 tests/qemuxml2xmloutdata/numatune-memnode-restrictive-m= ode.x86_64-latest.xml diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index d2344c894a77..4388ad545fe5 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -1112,8 +1112,11 @@ NUMA Node Tuning ``memory`` The optional ``memory`` element specifies how to allocate memory for the domain process on a NUMA host. It contains several optional attributes. - Attribute ``mode`` is either 'interleave', 'strict', or 'preferred', de= faults - to 'strict'. Attribute ``nodeset`` specifies the NUMA nodes, using the = same + Attribute ``mode`` is either 'interleave', 'strict', 'preferred', or + 'restrictive', defaults to 'strict'. The value 'restrictive' specifies + using system default policy and only cgroups is used to restrict the + memory nodes, and it requires setting mode to 'restrictive' in ``memnod= e`` + elements. Attribute ``nodeset`` specifies the NUMA nodes, using the same syntax as attribute ``cpuset`` of element ``vcpu``. Attribute ``placeme= nt`` ( :since:`since 0.9.12` ) can be used to indicate the memory placement mo= de for domain process, its value can be either "static" or "auto", defaults to diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 99cd87383234..20a43148b102 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1107,6 +1107,7 @@ strict preferred interleave + restrictive @@ -1139,6 +1140,7 @@ strict preferred interleave + restrictive diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 03c119fe2682..e99bfb7654c5 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -1527,6 +1527,7 @@ typedef enum { VIR_DOMAIN_NUMATUNE_MEM_STRICT =3D 0, VIR_DOMAIN_NUMATUNE_MEM_PREFERRED =3D 1, VIR_DOMAIN_NUMATUNE_MEM_INTERLEAVE =3D 2, + VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE =3D 3, =20 # ifdef VIR_ENUM_SENTINELS VIR_DOMAIN_NUMATUNE_MEM_LAST /* This constant is subject to change */ diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index e28c86284f38..932af4a18595 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -43,6 +43,7 @@ VIR_ENUM_IMPL(virDomainNumatuneMemMode, "strict", "preferred", "interleave", + "restrictive", ); =20 VIR_ENUM_IMPL(virDomainNumatunePlacement, @@ -230,6 +231,14 @@ virDomainNumatuneNodeParseXML(virDomainNuma *numa, _("Invalid mode attribute in memnode elemen= t")); goto cleanup; } + + if (numa->memory.mode =3D=3D VIR_DOMAIN_NUMATUNE_MEM_RESTRICTI= VE && + mode !=3D VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("'restrictive' mode is required in memnod= e element " + "when mode is 'restrictive' in memory ele= ment")); + goto cleanup; + } VIR_FREE(tmp); mem_node->mode =3D mode; } diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 77d8e3f38cca..6d40983ce1ea 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -175,6 +175,7 @@ VIR_ENUM_IMPL(qemuNumaPolicy, "bind", "preferred", "interleave", + "restrictive", ); =20 VIR_ENUM_DECL(qemuAudioDriver); diff --git a/src/util/virnuma.c b/src/util/virnuma.c index 0c9599003a60..31f65d890220 100644 --- a/src/util/virnuma.c +++ b/src/util/virnuma.c @@ -152,6 +152,9 @@ virNumaSetupMemoryPolicy(virDomainNumatuneMemMode mode, numa_set_interleave_mask(&mask); break; =20 + case VIR_DOMAIN_NUMATUNE_MEM_RESTRICTIVE: + break; + case VIR_DOMAIN_NUMATUNE_MEM_LAST: break; } diff --git a/tests/qemuxml2argvdata/numatune-memnode-invalid-mode.err b/tes= ts/qemuxml2argvdata/numatune-memnode-invalid-mode.err new file mode 100644 index 000000000000..180e64d1d8ff --- /dev/null +++ b/tests/qemuxml2argvdata/numatune-memnode-invalid-mode.err @@ -0,0 +1 @@ +XML error: 'restrictive' mode is required in memnode element when mode is = 'restrictive' in memory element diff --git a/tests/qemuxml2argvdata/numatune-memnode-invalid-mode.xml b/tes= ts/qemuxml2argvdata/numatune-memnode-invalid-mode.xml new file mode 100644 index 000000000000..a7c18d4d5018 --- /dev/null +++ b/tests/qemuxml2argvdata/numatune-memnode-invalid-mode.xml @@ -0,0 +1,33 @@ + + QEMUGuest + 9f4b6512-e73a-4a25-93e8-5307802821ce + 24682468 + 24682468 + 32 + + + + + + + hvm + + + + + + + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + + diff --git a/tests/qemuxml2argvdata/numatune-memnode-restrictive-mode.xml b= /tests/qemuxml2argvdata/numatune-memnode-restrictive-mode.xml new file mode 100644 index 000000000000..012c526460fe --- /dev/null +++ b/tests/qemuxml2argvdata/numatune-memnode-restrictive-mode.xml @@ -0,0 +1,41 @@ + + QEMUGuest + 9f4b6512-e73a-4a25-93e8-5307802821ce + 24682468 + 24682468 + 32 + + + + + + + hvm + + + + qemu64 + + + + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + +
+ + + + +