Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
data/org.libvirt.Connect.xml | 7 +++++++
src/connect.c | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+)
diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index ee7bfdc..1502849 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -166,6 +166,13 @@
<arg name="uuid" type="s" direction="in"/>
<arg name="network" type="o" direction="out"/>
</method>
+ <method name="NodeGetCellsFreeMemory">
+ <annotation name="org.gtk.GDBus.DocString"
+ value="See
https://libvirt.org/html/libvirt-libvirt-host.html#virNodeGetCellsFreeMem...
+ <arg name="startCell" type="i"
direction="in"/>
+ <arg name="maxCells" type="i" direction="in"/>
+ <arg name="freeMems" type="at"
direction="out"/>
+ </method>
<signal name="DomainEvent">
<annotation name="org.gtk.GDBus.DocString"
value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectDomainEven...
diff --git a/src/connect.c b/src/connect.c
index 5e577e4..78b438e 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -842,6 +842,44 @@ virtDBusConnectNetworkLookupByUUID(GVariant *inArgs,
*outArgs = g_variant_new("(o)", path);
}
+static void
+virtDBusConnectNodeGetCellsFreeMemory(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;
+ gint startCell;
+ gint maxCells;
+ g_autofree guint64 *freeMems = NULL;
+ gint ret;
+ GVariantBuilder builder;
+ GVariant *res;
+
+ g_variant_get(inArgs, "(ii)", &startCell, &maxCells);
+
+ if (!virtDBusConnectOpen(connect, error))
+ return;
+
+ freeMems = g_new0(guint64, maxCells);
+
+ ret = virNodeGetCellsFreeMemory(connect->connection,
+ (unsigned long long *)freeMems,
+ startCell, maxCells);
+ if (ret < 0)
+ return virtDBusUtilSetLastVirtError(error);
+
+ g_variant_builder_init(&builder, G_VARIANT_TYPE("at"));
+ for (gint i = 0; i < ret; i++)
+ g_variant_builder_add(&builder, "t", freeMems[i]);
+ res = g_variant_builder_end(&builder);
+
+ *outArgs = g_variant_new_tuple(&res, 1);
+}
+
static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = {
{ "Encrypted", virtDBusConnectGetEncrypted, NULL },
{ "Hostname", virtDBusConnectGetHostname, NULL },
@@ -873,6 +911,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
{ "NetworkDefineXML", virtDBusConnectNetworkDefineXML },
{ "NetworkLookupByName", virtDBusConnectNetworkLookupByName },
{ "NetworkLookupByUUID", virtDBusConnectNetworkLookupByUUID },
+ { "NodeGetCellsFreeMemory", virtDBusConnectNodeGetCellsFreeMemory },
{ 0 }
};
--
2.15.0