Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
data/org.libvirt.Connect.xml | 6 ++++++
src/connect.c | 35 +++++++++++++++++++++++++++++++++++
tests/test_connect.py | 4 ++++
3 files changed, 45 insertions(+)
diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index eb4990e..b84753b 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -166,6 +166,12 @@
<arg name="uuid" type="s" direction="in"/>
<arg name="network" type="o" 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 4035853..7558b70 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -849,6 +849,40 @@ virtDBusConnectNetworkLookupByUUID(GVariant *inArgs,
*outArgs = g_variant_new("(o)", path);
}
+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,
@@ -1133,6 +1167,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
{ "NetworkDefineXML", virtDBusConnectNetworkDefineXML },
{ "NetworkLookupByName", virtDBusConnectNetworkLookupByName },
{ "NetworkLookupByUUID", virtDBusConnectNetworkLookupByUUID },
+ { "NodeGetCPUMap", virtDBusConnectNodeGetCPUMap },
{ "NodeGetCPUStats", virtDBusConnectNodeGetCPUStats },
{ "NodeGetFreeMemory", virtDBusConnectNodeGetFreeMemory },
{ "NodeGetInfo", virtDBusConnectNodeGetInfo },
diff --git a/tests/test_connect.py b/tests/test_connect.py
index f0f68b1..4ddcb52 100755
--- a/tests/test_connect.py
+++ b/tests/test_connect.py
@@ -168,6 +168,10 @@ class TestConnect(libvirttest.BaseTestClass):
info = self.connect.NodeGetInfo()
assert isinstance(info, dbus.Struct)
+ def test_connect_node_get_cpumap(self):
+ info = self.connect.NodeGetCPUMap(0)
+ assert isinstance(info, dbus.Array)
+
if __name__ == '__main__':
libvirttest.run()
--
2.15.0