libvirt/src/conf/capabilities.h

346 lines
9.2 KiB
C
Raw Normal View History

/*
* capabilities.h: hypervisor capabilities
*
* Copyright (C) 2006-2019 Red Hat, Inc.
* Copyright (C) 2006-2008 Daniel P. Berrange
*
* 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 "internal.h"
#include "virconftypes.h"
#include "cpu_conf.h"
#include "virarch.h"
#include "virobject.h"
#include "virresctrl.h"
#include <libxml/xpath.h>
typedef enum {
VIR_CAPS_GUEST_FEATURE_TYPE_PAE = 0,
VIR_CAPS_GUEST_FEATURE_TYPE_NONPAE,
VIR_CAPS_GUEST_FEATURE_TYPE_IA64_BE,
VIR_CAPS_GUEST_FEATURE_TYPE_ACPI,
VIR_CAPS_GUEST_FEATURE_TYPE_APIC,
VIR_CAPS_GUEST_FEATURE_TYPE_CPUSELECTION,
VIR_CAPS_GUEST_FEATURE_TYPE_DEVICEBOOT,
VIR_CAPS_GUEST_FEATURE_TYPE_DISKSNAPSHOT,
VIR_CAPS_GUEST_FEATURE_TYPE_HAP,
VIR_CAPS_GUEST_FEATURE_TYPE_EXTERNAL_SNAPSHOT,
VIR_CAPS_GUEST_FEATURE_TYPE_LAST
} virCapsGuestFeatureType;
struct _virCapsGuestFeature {
bool present;
virTristateSwitch defaultOn;
virTristateBool toggle;
};
struct _virCapsGuestMachine {
char *name;
char *canonical;
unsigned int maxCpus;
bool deprecated;
};
struct _virCapsGuestDomainInfo {
char *emulator;
char *loader;
int nmachines;
virCapsGuestMachine **machines;
};
struct _virCapsGuestDomain {
int type; /* virDomainVirtType */
virCapsGuestDomainInfo info;
};
struct _virCapsGuestArch {
virArch id;
unsigned int wordsize;
virCapsGuestDomainInfo defaultInfo;
size_t ndomains;
size_t ndomains_max;
virCapsGuestDomain **domains;
};
struct _virCapsGuest {
int ostype;
virCapsGuestArch arch;
virCapsGuestFeature features[VIR_CAPS_GUEST_FEATURE_TYPE_LAST];
};
struct _virCapsHostNUMACellCPU {
unsigned int id;
unsigned int socket_id;
unsigned int die_id;
unsigned int core_id;
virBitmap *siblings;
};
struct _virCapsHostNUMACellPageInfo {
unsigned int size; /* page size in kibibytes */
unsigned long long avail; /* the size of pool */
};
struct _virCapsHostNUMACell {
int num;
int ncpus;
unsigned long long mem; /* in kibibytes */
virCapsHostNUMACellCPU *cpus;
size_t ndistances;
virNumaDistance *distances;
int npageinfo;
virCapsHostNUMACellPageInfo *pageinfo;
GArray *caches; /* virNumaCache */
};
struct _virCapsHostNUMA {
gint refs;
GPtrArray *cells;
capabilities: Expose NUMA interconnects Links between NUMA nodes can have different latencies and bandwidths. This info is newly defined in ACPI 6.2 under Heterogeneous Memory Attribute Table (HMAT) table. Linux kernel learned how to report these values under sysfs and thus we can expose them in our capabilities XML. The sysfs interface is documented in kernel's Documentation/admin-guide/mm/numaperf.rst. Long story short, two nodes can be in initiator-target relationship. A node can be initiator if it has a CPU or a device that's capable of initiating memory transfer. Therefore a node that has just memory can only be target. An initiator-target link can then have any combination of {bandwidth, latency} - {access, read, write} attribute (6 in total). However, the standard says access is applicable iff read and write values are the same. Therefore, we really have just four combinations of attributes: bandwidth-read, bandwidth-write, latency-read, latency-write. This is the combination that kernel reports anyway. Then, under /sys/system/devices/node/nodeX/acccessN/initiators we find values for those 4 attributes and also symlinks named "nodeN" which then represent initiators to nodeX. For instance: /sys/system/node/node1/access1/initiators/node0 -> ../../node0 /sys/system/node/node1/access1/initiators/read_bandwidth /sys/system/node/node1/access1/initiators/read_latency /sys/system/node/node1/access1/initiators/write_bandwidth /sys/system/node/node1/access1/initiators/write_latency This means that node0 is initiator and node1 is target and values of the interconnect can be read. In theory, there can be separate links to memory side caches too (e.g. one link from node X to node Y's main memory, another from node X to node Y's L1 cache, another one to L2 cache and so on). But sysfs does not express this relationship just yet. The "accessN" means either "access0" or "access1". The difference is that while the former expresses the best interconnect between two nodes including CPUS and I/O devices (such as GPUs and NICs), the latter includes only CPUs and thus is what we need. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1786309 Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
2021-05-17 11:36:34 +00:00
GArray *interconnects; /* virNumaInterconnect */
};
struct _virCapsHostSecModelLabel {
char *type;
char *label;
};
struct _virCapsHostSecModel {
char *model;
char *doi;
size_t nlabels;
virCapsHostSecModelLabel *labels;
};
struct _virCapsHostCacheBank {
unsigned int id;
unsigned int level; /* 1=L1, 2=L2, 3=L3, etc. */
unsigned long long size; /* B */
virCacheType type; /* Data, Instruction or Unified */
virBitmap *cpus; /* All CPUs that share this bank */
size_t ncontrols;
virResctrlInfoPerCache **controls;
};
void virCapsHostCacheBankFree(virCapsHostCacheBank *ptr);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virCapsHostCacheBank, virCapsHostCacheBankFree);
struct _virCapsHostCache {
size_t nbanks;
virCapsHostCacheBank **banks;
virResctrlInfoMon *monitor;
};
struct _virCapsHostMemBWNode {
unsigned int id;
virBitmap *cpus; /* All CPUs that belong to this node */
virResctrlInfoMemBWPerNode control;
};
struct _virCapsHostMemBW {
size_t nnodes;
virCapsHostMemBWNode **nodes;
virResctrlInfoMon *monitor;
};
struct _virCapsHost {
virArch arch;
size_t nfeatures;
size_t nfeatures_max;
char **features;
unsigned int powerMgmt; /* Bitmask of the PM capabilities.
* See enum virHostPMCapability.
*/
capabilities: use bool instead of int While preparing to add a capability for active commit, I noticed that the existing code was abusing int for boolean values. * src/conf/capabilities.h (_virCapsGuestFeature, _virCapsHost) (virCapabilitiesNew, virCapabilitiesAddGuestFeature): Improve types. * src/conf/capabilities.c (virCapabilitiesNew) (virCapabilitiesAddGuestFeature): Adjust signature. * src/bhyve/bhyve_capabilities.c (virBhyveCapsBuild): Update clients. * src/esx/esx_driver.c (esxCapsInit): Likewise. * src/libxl/libxl_conf.c (libxlMakeCapabilities): Likewise. * src/lxc/lxc_conf.c (virLXCDriverCapsInit): Likewise. * src/openvz/openvz_conf.c (openvzCapsInit): Likewise. * src/parallels/parallels_driver.c (parallelsBuildCapabilities): Likewise. * src/phyp/phyp_driver.c (phypCapsInit): Likewise. * src/qemu/qemu_capabilities.c (virQEMUCapsInit) (virQEMUCapsInitGuestFromBinary): Likewise. * src/security/virt-aa-helper.c (get_definition): Likewise. * src/test/test_driver.c (testBuildCapabilities): Likewise. * src/uml/uml_conf.c (umlCapsInit): Likewise. * src/vbox/vbox_tmpl.c (vboxCapsInit): Likewise. * src/vmware/vmware_conf.c (vmwareCapsInit): Likewise. * src/xen/xen_hypervisor.c (xenHypervisorBuildCapabilities): Likewise. * src/xenapi/xenapi_driver.c (getCapsObject): Likewise. * tests/qemucaps2xmltest.c (testGetCaps): Likewise. * tests/testutils.c (virTestGenericCapsInit): Likewise. * tests/testutilslxc.c (testLXCCapsInit): Likewise. * tests/testutilsqemu.c (testQemuCapsInit): Likewise. * tests/testutilsxen.c (testXenCapsInit): Likewise. * tests/vircaps2xmltest.c (buildVirCapabilities): Likewise. * tests/vircapstest.c (buildNUMATopology): Likewise. * tests/vmx2xmltest.c (testCapsInit): Likewise. * tests/xml2vmxtest.c (testCapsInit): Likewise. Signed-off-by: Eric Blake <eblake@redhat.com>
2014-07-14 12:56:13 +00:00
bool offlineMigrate;
bool liveMigrate;
size_t nmigrateTrans;
size_t nmigrateTrans_max;
char **migrateTrans;
virCapsHostNUMA *numa;
virResctrlInfo *resctrl;
virCapsHostCache cache;
virCapsHostMemBW memBW;
size_t nsecModels;
virCapsHostSecModel *secModels;
char *netprefix;
virCPUDef *cpu;
int nPagesSize; /* size of pagesSize array */
unsigned int *pagesSize; /* page sizes support on the system */
unsigned char host_uuid[VIR_UUID_BUFLEN];
bool iommu;
};
struct _virCapsStoragePool {
int type;
};
struct _virCaps {
virObject parent;
virCapsHost host;
size_t nguests;
size_t nguests_max;
virCapsGuest **guests;
size_t npools;
size_t npools_max;
virCapsStoragePool **pools;
};
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virCaps, virObjectUnref);
struct _virCapsDomainData {
int ostype;
int arch;
int domaintype; /* virDomainVirtType */
const char *emulator;
const char *machinetype;
};
virCaps *
virCapabilitiesNew(virArch hostarch,
capabilities: use bool instead of int While preparing to add a capability for active commit, I noticed that the existing code was abusing int for boolean values. * src/conf/capabilities.h (_virCapsGuestFeature, _virCapsHost) (virCapabilitiesNew, virCapabilitiesAddGuestFeature): Improve types. * src/conf/capabilities.c (virCapabilitiesNew) (virCapabilitiesAddGuestFeature): Adjust signature. * src/bhyve/bhyve_capabilities.c (virBhyveCapsBuild): Update clients. * src/esx/esx_driver.c (esxCapsInit): Likewise. * src/libxl/libxl_conf.c (libxlMakeCapabilities): Likewise. * src/lxc/lxc_conf.c (virLXCDriverCapsInit): Likewise. * src/openvz/openvz_conf.c (openvzCapsInit): Likewise. * src/parallels/parallels_driver.c (parallelsBuildCapabilities): Likewise. * src/phyp/phyp_driver.c (phypCapsInit): Likewise. * src/qemu/qemu_capabilities.c (virQEMUCapsInit) (virQEMUCapsInitGuestFromBinary): Likewise. * src/security/virt-aa-helper.c (get_definition): Likewise. * src/test/test_driver.c (testBuildCapabilities): Likewise. * src/uml/uml_conf.c (umlCapsInit): Likewise. * src/vbox/vbox_tmpl.c (vboxCapsInit): Likewise. * src/vmware/vmware_conf.c (vmwareCapsInit): Likewise. * src/xen/xen_hypervisor.c (xenHypervisorBuildCapabilities): Likewise. * src/xenapi/xenapi_driver.c (getCapsObject): Likewise. * tests/qemucaps2xmltest.c (testGetCaps): Likewise. * tests/testutils.c (virTestGenericCapsInit): Likewise. * tests/testutilslxc.c (testLXCCapsInit): Likewise. * tests/testutilsqemu.c (testQemuCapsInit): Likewise. * tests/testutilsxen.c (testXenCapsInit): Likewise. * tests/vircaps2xmltest.c (buildVirCapabilities): Likewise. * tests/vircapstest.c (buildNUMATopology): Likewise. * tests/vmx2xmltest.c (testCapsInit): Likewise. * tests/xml2vmxtest.c (testCapsInit): Likewise. Signed-off-by: Eric Blake <eblake@redhat.com>
2014-07-14 12:56:13 +00:00
bool offlineMigrate,
bool liveMigrate);
void
virCapabilitiesHostNUMAUnref(virCapsHostNUMA *caps);
void
virCapabilitiesHostNUMARef(virCapsHostNUMA *caps);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virCapsHostNUMA, virCapabilitiesHostNUMAUnref);
int
virCapabilitiesAddHostFeature(virCaps *caps,
const char *name);
int
virCapabilitiesAddHostMigrateTransport(virCaps *caps,
const char *name);
int
virCapabilitiesSetNetPrefix(virCaps *caps,
const char *prefix);
void
virCapabilitiesHostNUMAAddCell(virCapsHostNUMA *caps,
int num,
unsigned long long mem,
int ncpus,
virCapsHostNUMACellCPU **cpus,
int ndistances,
virNumaDistance **distances,
int npageinfo,
virCapsHostNUMACellPageInfo **pageinfo,
GArray **caches);
virCapsGuestMachine **
virCapabilitiesAllocMachines(const char *const *names,
int *nnames);
void
virCapabilitiesFreeGuest(virCapsGuest *guest);
virCapsGuest *
virCapabilitiesAddGuest(virCaps *caps,
int ostype,
virArch arch,
const char *emulator,
const char *loader,
int nmachines,
virCapsGuestMachine **machines);
virCapsGuestDomain *
virCapabilitiesAddGuestDomain(virCapsGuest *guest,
int hvtype,
const char *emulator,
const char *loader,
int nmachines,
virCapsGuestMachine **machines);
void
virCapabilitiesAddGuestFeature(virCapsGuest *guest,
virCapsGuestFeatureType feature);
void
virCapabilitiesAddGuestFeatureWithToggle(virCapsGuest *guest,
virCapsGuestFeatureType feature,
bool defaultOn,
bool toggle);
int
virCapabilitiesAddStoragePool(virCaps *caps,
int poolType);
int
virCapabilitiesHostSecModelAddBaseLabel(virCapsHostSecModel *secmodel,
const char *type,
const char *label);
virCapsDomainData *
virCapabilitiesDomainDataLookup(virCaps *caps,
int ostype,
virArch arch,
int domaintype,
const char *emulator,
const char *machinetype);
bool
virCapabilitiesDomainSupported(virCaps *caps,
int ostype,
virArch arch,
int domaintype);
void
virCapabilitiesClearHostNUMACellCPUTopology(virCapsHostNUMACellCPU *cpu,
size_t ncpus);
2009-01-30 17:12:28 +00:00
char *
virCapabilitiesFormatXML(virCaps *caps);
virBitmap *virCapabilitiesHostNUMAGetCpus(virCapsHostNUMA *caps,
virBitmap *nodemask);
int virCapabilitiesHostNUMAGetMaxNode(virCapsHostNUMA *caps);
int virCapabilitiesGetNodeInfo(virNodeInfoPtr nodeinfo);
int virCapabilitiesInitPages(virCaps *caps);
virCapsHostNUMA *virCapabilitiesHostNUMANew(void);
virCapsHostNUMA *virCapabilitiesHostNUMANewHost(void);
bool virCapsHostCacheBankEquals(virCapsHostCacheBank *a,
virCapsHostCacheBank *b);
void virCapsHostCacheBankFree(virCapsHostCacheBank *ptr);
int virCapabilitiesInitCaches(virCaps *caps);
void virCapabilitiesHostInitIOMMU(virCaps *caps);