libvirt/src/conf/numa_conf.h

187 lines
6.4 KiB
C
Raw Normal View History

/*
* numa_conf.h
*
* Copyright (C) 2014-2015 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <libxml/xpath.h>
#include "internal.h"
#include "virutil.h"
#include "virbitmap.h"
#include "virbuffer.h"
#include "virenum.h"
typedef struct _virDomainNuma virDomainNuma;
typedef virDomainNuma *virDomainNumaPtr;
typedef enum {
VIR_DOMAIN_NUMATUNE_PLACEMENT_DEFAULT = 0,
VIR_DOMAIN_NUMATUNE_PLACEMENT_STATIC,
VIR_DOMAIN_NUMATUNE_PLACEMENT_AUTO,
VIR_DOMAIN_NUMATUNE_PLACEMENT_LAST
} virDomainNumatunePlacement;
VIR_ENUM_DECL(virDomainNumatunePlacement);
VIR_ENUM_DECL(virDomainNumatuneMemMode);
typedef enum {
VIR_DOMAIN_MEMORY_ACCESS_DEFAULT = 0, /* No memory access defined */
VIR_DOMAIN_MEMORY_ACCESS_SHARED, /* Memory access is set as shared */
VIR_DOMAIN_MEMORY_ACCESS_PRIVATE, /* Memory access is set as private */
VIR_DOMAIN_MEMORY_ACCESS_LAST,
} virDomainMemoryAccess;
VIR_ENUM_DECL(virDomainMemoryAccess);
virDomainNumaPtr virDomainNumaNew(void);
void virDomainNumaFree(virDomainNumaPtr numa);
/*
* XML Parse/Format functions
*/
int virDomainNumatuneParseXML(virDomainNumaPtr numa,
bool placement_static,
xmlXPathContextPtr ctxt)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);
int virDomainNumatuneFormatXML(virBufferPtr buf, virDomainNumaPtr numatune)
ATTRIBUTE_NONNULL(1);
/*
* Getters
*/
int virDomainNumatuneGetMode(virDomainNumaPtr numatune,
int cellid,
virDomainNumatuneMemMode *mode);
virBitmapPtr virDomainNumatuneGetNodeset(virDomainNumaPtr numatune,
virBitmapPtr auto_nodeset,
int cellid);
int virDomainNumatuneMaybeGetNodeset(virDomainNumaPtr numatune,
virBitmapPtr auto_nodeset,
virBitmapPtr *retNodeset,
int cellid);
size_t virDomainNumaGetNodeCount(virDomainNumaPtr numa);
bool virDomainNumaNodeDistanceIsUsingDefaults(virDomainNumaPtr numa,
size_t node,
size_t sibling)
ATTRIBUTE_NONNULL(1);
xenconfig: add domxml conversions for xen-xl This patch converts NUMA configurations between the Xen libxl configuration file format and libvirt's XML format. XML HVM domain on a 4 node (2 cores/socket) configuration: <cpu> <numa> <cell id='0' cpus='0-1' memory='2097152' unit='KiB'> <distances> <sibling id='0' value='10'/> <sibling id='1' value='21'/> <sibling id='2' value='31'/> <sibling id='3' value='21'/> </distances> </cell> <cell id='1' cpus='2-3' memory='2097152' unit='KiB'> <distances> <sibling id='0' value='21'/> <sibling id='1' value='10'/> <sibling id='2' value='21'/> <sibling id='3' value='31'/> </distances> </cell> <cell id='2' cpus='3-4' memory='2097152' unit='KiB'> <distances> <sibling id='0' value='31'/> <sibling id='1' value='21'/> <sibling id='2' value='10'/> <sibling id='3' value='21'/> </distances> </cell> <cell id='3' cpus='5-6' memory='2097152' unit='KiB'> <distances> <sibling id='0' value='21'/> <sibling id='1' value='31'/> <sibling id='2' value='21'/> <sibling id='3' value='10'/> </distances> </cell> </numa> </cpu> Xen xl.cfg domain configuration: vnuma = [["pnode=0","size=2048","vcpus=0-1","vdistances=10,21,31,21"], ["pnode=1","size=2048","vcpus=2-3","vdistances=21,10,21,31"], ["pnode=2","size=2048","vcpus=4-5","vdistances=31,21,10,21"], ["pnode=3","size=2048","vcpus=6-7","vdistances=21,31,21,10"]] If there is no XML <distances> description amongst the <cell> data the conversion schema from xml to native will generate 10 for local and 20 for all remote instances. Signed-off-by: Wim ten Have <wim.ten.have@oracle.com> Reviewed-by: Jim Fehlig <jfehlig@suse.com> Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2017-11-02 15:47:21 +00:00
size_t virDomainNumaGetNodeDistance(virDomainNumaPtr numa,
size_t node,
size_t sibling)
ATTRIBUTE_NONNULL(1);
virBitmapPtr virDomainNumaGetNodeCpumask(virDomainNumaPtr numa,
size_t node)
ATTRIBUTE_NONNULL(1);
virDomainMemoryAccess virDomainNumaGetNodeMemoryAccessMode(virDomainNumaPtr numa,
size_t node)
ATTRIBUTE_NONNULL(1);
virTristateBool virDomainNumaGetNodeDiscard(virDomainNumaPtr numa,
size_t node)
ATTRIBUTE_NONNULL(1);
unsigned long long virDomainNumaGetNodeMemorySize(virDomainNumaPtr numa,
size_t node)
ATTRIBUTE_NONNULL(1);
unsigned long long virDomainNumaGetMemorySize(virDomainNumaPtr numa)
ATTRIBUTE_NONNULL(1);
unsigned int
virDomainNumaGetMaxCPUID(virDomainNumaPtr numa);
/*
* Formatters
*/
char *virDomainNumatuneFormatNodeset(virDomainNumaPtr numatune,
virBitmapPtr auto_nodeset,
int cellid);
int virDomainNumatuneMaybeFormatNodeset(virDomainNumaPtr numatune,
virBitmapPtr auto_nodeset,
char **mask,
int cellid);
/*
* Setters
*/
int virDomainNumatuneSet(virDomainNumaPtr numa,
bool placement_static,
int placement,
int mode,
virBitmapPtr nodeset)
ATTRIBUTE_NONNULL(1);
xenconfig: add domxml conversions for xen-xl This patch converts NUMA configurations between the Xen libxl configuration file format and libvirt's XML format. XML HVM domain on a 4 node (2 cores/socket) configuration: <cpu> <numa> <cell id='0' cpus='0-1' memory='2097152' unit='KiB'> <distances> <sibling id='0' value='10'/> <sibling id='1' value='21'/> <sibling id='2' value='31'/> <sibling id='3' value='21'/> </distances> </cell> <cell id='1' cpus='2-3' memory='2097152' unit='KiB'> <distances> <sibling id='0' value='21'/> <sibling id='1' value='10'/> <sibling id='2' value='21'/> <sibling id='3' value='31'/> </distances> </cell> <cell id='2' cpus='3-4' memory='2097152' unit='KiB'> <distances> <sibling id='0' value='31'/> <sibling id='1' value='21'/> <sibling id='2' value='10'/> <sibling id='3' value='21'/> </distances> </cell> <cell id='3' cpus='5-6' memory='2097152' unit='KiB'> <distances> <sibling id='0' value='21'/> <sibling id='1' value='31'/> <sibling id='2' value='21'/> <sibling id='3' value='10'/> </distances> </cell> </numa> </cpu> Xen xl.cfg domain configuration: vnuma = [["pnode=0","size=2048","vcpus=0-1","vdistances=10,21,31,21"], ["pnode=1","size=2048","vcpus=2-3","vdistances=21,10,21,31"], ["pnode=2","size=2048","vcpus=4-5","vdistances=31,21,10,21"], ["pnode=3","size=2048","vcpus=6-7","vdistances=21,31,21,10"]] If there is no XML <distances> description amongst the <cell> data the conversion schema from xml to native will generate 10 for local and 20 for all remote instances. Signed-off-by: Wim ten Have <wim.ten.have@oracle.com> Reviewed-by: Jim Fehlig <jfehlig@suse.com> Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2017-11-02 15:47:21 +00:00
size_t virDomainNumaSetNodeCount(virDomainNumaPtr numa,
size_t nmem_nodes)
ATTRIBUTE_NONNULL(1);
void virDomainNumaSetNodeMemorySize(virDomainNumaPtr numa,
size_t node,
unsigned long long size)
ATTRIBUTE_NONNULL(1);
xenconfig: add domxml conversions for xen-xl This patch converts NUMA configurations between the Xen libxl configuration file format and libvirt's XML format. XML HVM domain on a 4 node (2 cores/socket) configuration: <cpu> <numa> <cell id='0' cpus='0-1' memory='2097152' unit='KiB'> <distances> <sibling id='0' value='10'/> <sibling id='1' value='21'/> <sibling id='2' value='31'/> <sibling id='3' value='21'/> </distances> </cell> <cell id='1' cpus='2-3' memory='2097152' unit='KiB'> <distances> <sibling id='0' value='21'/> <sibling id='1' value='10'/> <sibling id='2' value='21'/> <sibling id='3' value='31'/> </distances> </cell> <cell id='2' cpus='3-4' memory='2097152' unit='KiB'> <distances> <sibling id='0' value='31'/> <sibling id='1' value='21'/> <sibling id='2' value='10'/> <sibling id='3' value='21'/> </distances> </cell> <cell id='3' cpus='5-6' memory='2097152' unit='KiB'> <distances> <sibling id='0' value='21'/> <sibling id='1' value='31'/> <sibling id='2' value='21'/> <sibling id='3' value='10'/> </distances> </cell> </numa> </cpu> Xen xl.cfg domain configuration: vnuma = [["pnode=0","size=2048","vcpus=0-1","vdistances=10,21,31,21"], ["pnode=1","size=2048","vcpus=2-3","vdistances=21,10,21,31"], ["pnode=2","size=2048","vcpus=4-5","vdistances=31,21,10,21"], ["pnode=3","size=2048","vcpus=6-7","vdistances=21,31,21,10"]] If there is no XML <distances> description amongst the <cell> data the conversion schema from xml to native will generate 10 for local and 20 for all remote instances. Signed-off-by: Wim ten Have <wim.ten.have@oracle.com> Reviewed-by: Jim Fehlig <jfehlig@suse.com> Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2017-11-02 15:47:21 +00:00
int virDomainNumaSetNodeDistance(virDomainNumaPtr numa,
size_t node,
size_t sibling,
unsigned int value)
ATTRIBUTE_NONNULL(1);
size_t virDomainNumaSetNodeDistanceCount(virDomainNumaPtr numa,
size_t node,
size_t ndistances)
ATTRIBUTE_NONNULL(1);
virBitmapPtr virDomainNumaSetNodeCpumask(virDomainNumaPtr numa,
size_t node,
virBitmapPtr cpumask)
ATTRIBUTE_NONNULL(1);
/*
* Other accessors
*/
bool virDomainNumaEquals(virDomainNumaPtr n1,
virDomainNumaPtr n2);
bool virDomainNumaCheckABIStability(virDomainNumaPtr src,
virDomainNumaPtr tgt);
bool virDomainNumatuneHasPlacementAuto(virDomainNumaPtr numatune);
bool virDomainNumatuneHasPerNodeBinding(virDomainNumaPtr numatune);
int virDomainNumatuneSpecifiedMaxNode(virDomainNumaPtr numatune);
bool virDomainNumatuneNodesetIsAvailable(virDomainNumaPtr numatune,
virBitmapPtr auto_nodeset);
bool virDomainNumatuneNodeSpecified(virDomainNumaPtr numatune,
int cellid);
int virDomainNumaDefCPUParseXML(virDomainNumaPtr def, xmlXPathContextPtr ctxt);
int virDomainNumaDefCPUFormatXML(virBufferPtr buf, virDomainNumaPtr def);
unsigned int virDomainNumaGetCPUCountTotal(virDomainNumaPtr numa);