Signed-off-by: Katerina Koukiou <kkouk...@redhat.com> --- data/org.libvirt.Connect.xml | 6 ++++++ src/connect.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+)
diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 6b6758f..c62d107 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -183,6 +183,12 @@ value="See https://libvirt.org/html/libvirt-libvirt-host.html#virNodeGetInfo"/> <arg name="info" type="(stuuuuuu)" direction="out"/> </method> + <method name="NodeGetMemoryParameters"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-host.html#virNodeGetMemoryParameters"/> + <arg name="flags" type="u" direction="in"/> + <arg name="memoryParameters" type="a{sv}" direction="out"/> + </method> <signal name="DomainEvent"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectDomainEventCallback"/> diff --git a/src/connect.c b/src/connect.c index 367d5ae..f2c6d45 100644 --- a/src/connect.c +++ b/src/connect.c @@ -929,6 +929,43 @@ virtDBusConnectNodeGetInfo(GVariant *inArgs G_GNUC_UNUSED, info.cores, info.threads); } +static void +virtDBusConnectNodeGetMemoryParameters(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_auto(virtDBusUtilTypedParams) params = { 0 }; + guint flags; + gint ret; + GVariant *grecords; + + g_variant_get(inArgs, "(u)", &flags); + + if (!virtDBusConnectOpen(connect, error)) + return; + + ret = virNodeGetMemoryParameters(connect->connection, NULL, + ¶ms.nparams, flags); + if (ret < 0) + return virtDBusUtilSetLastVirtError(error); + if (params.nparams != 0) { + params.params = g_new0(virTypedParameter, params.nparams); + if (virNodeGetMemoryParameters(connect->connection, params.params, + ¶ms.nparams, flags) < 0) { + return virtDBusUtilSetLastVirtError(error); + } + } + + grecords = virtDBusUtilTypedParamsToGVariant(params.params, params.nparams); + + *outArgs = g_variant_new_tuple(&grecords, 1); +} + static virtDBusGDBusPropertyTable virtDBusConnectPropertyTable[] = { { "Encrypted", virtDBusConnectGetEncrypted, NULL }, { "Hostname", virtDBusConnectGetHostname, NULL }, @@ -963,6 +1000,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "NodeGetCPUStats", virtDBusConnectNodeGetCPUStats }, { "NodeGetFreeMemory", virtDBusConnectNodeGetFreeMemory }, { "NodeGetInfo", virtDBusConnectNodeGetInfo }, + { "NodeGetMemoryParameters", virtDBusConnectNodeGetMemoryParameters }, { 0 } }; -- 2.15.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list