Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx> --- data/org.libvirt.Connect.xml | 6 ++++++ src/connect.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml index 2e65f8b..62a65ae 100644 --- a/data/org.libvirt.Connect.xml +++ b/data/org.libvirt.Connect.xml @@ -190,6 +190,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 bb9bd46..8a168f4 100644 --- a/src/connect.c +++ b/src/connect.c @@ -968,6 +968,41 @@ 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 && 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 }, @@ -1003,6 +1038,7 @@ static virtDBusGDBusMethodTable virtDBusConnectMethodTable[] = { { "NodeGetCPUStats", virtDBusConnectNodeGetCPUStats }, { "NodeGetFreeMemory", virtDBusConnectNodeGetFreeMemory }, { "NodeGetInfo", virtDBusConnectNodeGetInfo }, + { "NodeGetMemoryParameters", virtDBusConnectNodeGetMemoryParameters }, { 0 } }; -- 2.15.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list