Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
data/org.libvirt.Connect.xml | 5 +++++
src/connect.c | 24 ++++++++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index 0dcc6e8..f0a7738 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -180,6 +180,11 @@
<arg name="flags" type="u" direction="in"/>
<arg name="cpuStats" type="a{st}"
direction="out"/>
</method>
+ <method name="NodeGetFreeMemory">
+ <annotation name="org.gtk.GDBus.DocString"
+ value="See
https://libvirt.org/html/libvirt-libvirt-host.html#virNodeGetFreeMemory&q...
+ <arg name="freemem" type="t" 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 80b5c67..60fcaa5 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -921,6 +921,29 @@ virtDBusConnectNodeGetCPUStats(GVariant *inArgs,
*outArgs = g_variant_new_tuple(&gret, 1);
}
+static void
+virtDBusConnectNodeGetFreeMemory(GVariant *inArgs G_GNUC_UNUSED,
+ 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;
+ guint64 freemem;
+
+ if (!virtDBusConnectOpen(connect, error))
+ return;
+
+ freemem = virNodeGetFreeMemory(connect->connection);
+ if (freemem == 0)
+ return virtDBusUtilSetLastVirtError(error);
+
+ *outArgs = g_variant_new("(t)", freemem);
+}
+
static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = {
{ "Encrypted", virtDBusConnectGetEncrypted, NULL },
{ "Hostname", virtDBusConnectGetHostname, NULL },
@@ -954,6 +977,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = {
{ "NetworkLookupByUUID", virtDBusConnectNetworkLookupByUUID },
{ "NodeGetCellsFreeMemory", virtDBusConnectNodeGetCellsFreeMemory },
{ "NodeGetCPUStats", virtDBusConnectNodeGetCPUStats },
+ { "NodeGetFreeMemory", virtDBusConnectNodeGetFreeMemory },
{ 0 }
};
--
2.15.0