Expose PERF_PKG_MON energy monitoring capabilities in the host
capabilities XML.
<energy>
<monitor maxMonitors='576'>
<feature name='core_energy'/>
<feature name='activity'/>
</monitor>
</energy>
Changes:
- Add virCapabilitiesFormatEnergy() to emit <energy> XML block
- Add virCapabilitiesInitEnergy() to init from PERF_PKG_MON info
- Add <energy> element and energyMonitorFeature to capability.rng
- Update qemu_driver to support VIR_RESCTRL_MONITOR_TYPE_ENERGY
- Add virCapsHostEnergy struct
Signed-off-by: Jedrzej Wasiukiewicz <[email protected]>
Signed-off-by: Christopher M. Cantalupo <[email protected]>
---
src/conf/capabilities.c | 42 +++++++++++++++++++++++++++++++++
src/conf/capabilities.h | 6 +++++
src/conf/schemas/capability.rng | 27 +++++++++++++++++++++
src/conf/virconftypes.h | 2 ++
src/qemu/qemu_driver.c | 3 +++
5 files changed, 80 insertions(+)
diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c
index 1821e36e61..e83de6d1bc 100644
--- a/src/conf/capabilities.c
+++ b/src/conf/capabilities.c
@@ -263,6 +263,8 @@ virCapsDispose(void *object)
virResctrlInfoMonFree(caps->host.memBW.monitor);
g_free(caps->host.memBW.nodes);
+ virResctrlInfoMonFree(caps->host.energy.monitor);
+
g_free(caps->host.netprefix);
g_free(caps->host.pagesSize);
virCPUDefFree(caps->host.cpu);
@@ -1057,6 +1059,26 @@ virCapabilitiesFormatMemoryBandwidth(virBuffer *buf,
}
+static int
+virCapabilitiesFormatEnergy(virBuffer *buf,
+ virCapsHostEnergy *energy)
+{
+ if (!energy->monitor)
+ return 0;
+
+ virBufferAddLit(buf, "<energy>\n");
+ virBufferAdjustIndent(buf, 2);
+
+ if (virCapabilitiesFormatResctrlMonitor(buf, energy->monitor) < 0)
+ return -1;
+
+ virBufferAdjustIndent(buf, -2);
+ virBufferAddLit(buf, "</energy>\n");
+
+ return 0;
+}
+
+
static int
virCapabilitiesFormatHostXML(virCapsHost *host,
virBuffer *buf)
@@ -1156,6 +1178,9 @@ virCapabilitiesFormatHostXML(virCapsHost *host,
if (virCapabilitiesFormatMemoryBandwidth(buf, &host->memBW) < 0)
return -1;
+ if (virCapabilitiesFormatEnergy(buf, &host->energy) < 0)
+ return -1;
+
for (i = 0; i < host->nsecModels; i++) {
virBufferAddLit(buf, "<secmodel>\n");
virBufferAdjustIndent(buf, 2);
@@ -2143,6 +2168,20 @@ virCapabilitiesInitResctrlMemory(virCaps *caps)
}
+static int
+virCapabilitiesInitEnergy(virCaps *caps)
+{
+ const char *prefix = virResctrlMonitorPrefixTypeToString(
+ VIR_RESCTRL_MONITOR_TYPE_ENERGY);
+
+ if (virResctrlInfoGetMonitorPrefix(caps->host.resctrl, prefix,
+ &caps->host.energy.monitor) < 0)
+ return -1;
+
+ return 0;
+}
+
+
int
virCapabilitiesInitCaches(virCaps *caps)
{
@@ -2294,6 +2333,9 @@ virCapabilitiesInitCaches(virCaps *caps)
&caps->host.cache.monitor) < 0)
return -1;
+ if (virCapabilitiesInitEnergy(caps) < 0)
+ return -1;
+
return 0;
}
diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
index daea835817..0482e4297a 100644
--- a/src/conf/capabilities.h
+++ b/src/conf/capabilities.h
@@ -162,6 +162,10 @@ struct _virCapsHostMemBW {
virResctrlInfoMon *monitor;
};
+struct _virCapsHostEnergy {
+ virResctrlInfoMon *monitor;
+};
+
struct _virCapsHost {
virArch arch;
size_t nfeatures;
@@ -184,6 +188,8 @@ struct _virCapsHost {
virCapsHostMemBW memBW;
+ virCapsHostEnergy energy;
+
size_t nsecModels;
virCapsHostSecModel *secModels;
diff --git a/src/conf/schemas/capability.rng b/src/conf/schemas/capability.rng
index 8ef6e9a282..6160067dc7 100644
--- a/src/conf/schemas/capability.rng
+++ b/src/conf/schemas/capability.rng
@@ -45,6 +45,9 @@
<optional>
<ref name="memory_bandwidth"/>
</optional>
+ <optional>
+ <ref name="energy"/>
+ </optional>
<zeroOrMore>
<ref name="secmodel"/>
</zeroOrMore>
@@ -333,6 +336,30 @@
</data>
</define>
+ <define name="energyMonitorFeature">
+ <choice>
+ <value>core_energy</value>
+ <value>activity</value>
+ </choice>
+ </define>
+
+ <define name="energy">
+ <element name="energy">
+ <element name="monitor">
+ <attribute name="maxMonitors">
+ <ref name="unsignedInt"/>
+ </attribute>
+ <oneOrMore>
+ <element name="feature">
+ <attribute name="name">
+ <ref name="energyMonitorFeature"/>
+ </attribute>
+ </element>
+ </oneOrMore>
+ </element>
+ </element>
+ </define>
+
<define name="guestcaps">
<element name="guest">
<ref name="ostype"/>
diff --git a/src/conf/virconftypes.h b/src/conf/virconftypes.h
index 0596791a4d..f1a200bfe2 100644
--- a/src/conf/virconftypes.h
+++ b/src/conf/virconftypes.h
@@ -52,6 +52,8 @@ typedef struct _virCapsHostMemBW virCapsHostMemBW;
typedef struct _virCapsHostMemBWNode virCapsHostMemBWNode;
+typedef struct _virCapsHostEnergy virCapsHostEnergy;
+
typedef struct _virCapsHostNUMA virCapsHostNUMA;
typedef struct _virCapsHostNUMACell virCapsHostNUMACell;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2d509cd2b9..a3d648e268 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -17086,6 +17086,9 @@ qemuDomainGetResctrlMonData(virQEMUDriver *driver,
features = caps->host.memBW.monitor->features;
break;
case VIR_RESCTRL_MONITOR_TYPE_ENERGY:
+ if (caps->host.energy.monitor)
+ features = caps->host.energy.monitor->features;
+ break;
case VIR_RESCTRL_MONITOR_TYPE_UNSUPPORT:
case VIR_RESCTRL_MONITOR_TYPE_LAST:
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
--
2.34.1
---------------------------------------------------------------------
Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial
Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 |
Kapital zakladowy 200.000 PLN.
Spolka oswiadcza, ze posiada status duzego przedsiebiorcy w rozumieniu ustawy z
dnia 8 marca 2013 r. o przeciwdzialaniu nadmiernym opoznieniom w transakcjach
handlowych.
Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i
moze zawierac informacje poufne. W razie przypadkowego otrzymania tej
wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie;
jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole
use of the intended recipient(s). If you are not the intended recipient, please
contact the sender and delete all copies; any review or distribution by others
is strictly prohibited.