Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
data/org.libvirt.Connect.xml | 6 ++++++
src/connect.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index 9358040..dfb8cc3 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -173,6 +173,12 @@
<arg name="maxCells" type="i" direction="in"/>
<arg name="freeMems" type="at"
direction="out"/>
</method>
+ <method name="NodeGetCPUMap">
+ <annotation name="org.gtk.GDBus.DocString"
+ value="See
https://libvirt.org/html/libvirt-libvirt-host.html#virNodeGetCPUMap"...
+ <arg name="flags" type="u" direction="in"/>
+ <arg name="res" type="ab" direction="out"/>
+ </method>
<method name="NodeGetCPUStats">
<annotation name="org.gtk.GDBus.DocString"
value="See
https://libvirt.org/html/libvirt-libvirt-host.html#virNodeGetCPUStats&quo...
diff --git a/src/connect.c b/src/connect.c
index 7d7c7c0..64e8e53 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -887,6 +887,40 @@ virtDBusConnectNodeGetCellsFreeMemory(GVariant *inArgs,
*outArgs = g_variant_new_tuple(&res, 1);
}
+static void
+virtDBusConnectNodeGetCPUMap(GVariant *inArgs,
+ GUnixFDList *inFDs G_GNUC_UNUSED,
+ const gchar *objectPath G_GNUC_UNUSED,
+ gpointer userData,
+ GVariant **outArgs,
+ GUnixFDList **outFDs G_GNUC_UNUSED,
+ GError **error)
+{
+ virtDBusConnect *connect = userData;
+ g_autofree guchar *cpumap = NULL;
+ guint online = 0;
+ guint flags;
+ gint ret;
+ GVariant *gret;
+ GVariantBuilder builder;
+
+ g_variant_get(inArgs, "(u)", &flags);
+
+ if (!virtDBusConnectOpen(connect, error))
+ return;
+
+ ret = virNodeGetCPUMap(connect->connection, &cpumap, &online, flags);
+ if (ret < 0)
+ return virtDBusUtilSetLastVirtError(error);
+
+ g_variant_builder_init(&builder, G_VARIANT_TYPE("ab"));
+ for (gint i = 0; i < ret; i++)
+ g_variant_builder_add(&builder, "b", VIR_CPU_USED(cpumap, i));
+ gret = g_variant_builder_end(&builder);
+
+ *outArgs = g_variant_new_tuple(&gret, 1);
+}
+
static void
virtDBusConnectNodeGetCPUStats(GVariant *inArgs,
GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -1169,6 +1203,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
{ "NetworkLookupByName", virtDBusConnectNetworkLookupByName },
{ "NetworkLookupByUUID", virtDBusConnectNetworkLookupByUUID },
{ "NodeGetCellsFreeMemory", virtDBusConnectNodeGetCellsFreeMemory },
+ { "NodeGetCPUMap", virtDBusConnectNodeGetCPUMap },
{ "NodeGetCPUStats", virtDBusConnectNodeGetCPUStats },
{ "NodeGetFreeMemory", virtDBusConnectNodeGetFreeMemory },
{ "NodeGetInfo", virtDBusConnectNodeGetInfo },
--
2.15.0