Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx> --- data/org.libvirt.Domain.xml | 6 ++++++ src/domain.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml index 41814c7..36167d8 100644 --- a/data/org.libvirt.Domain.xml +++ b/data/org.libvirt.Domain.xml @@ -71,6 +71,12 @@ value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetJobInfo"/> <arg name="jobInfo" type="(sttttttttttt)" direction="out"/> </method> + <method name="GetMemoryParameters"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetMemoryParameters"/> + <arg name="flags" type="u" direction="in"/> + <arg name="memoryParameters" type="a{sv}" direction="out"/> + </method> <method name="GetStats"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainListGetStats"/> diff --git a/src/domain.c b/src/domain.c index 9b8779b..7ab832b 100644 --- a/src/domain.c +++ b/src/domain.c @@ -458,6 +458,41 @@ virtDBusDomainGetJobInfo(GVariant *inArgs G_GNUC_UNUSED, jobInfo->fileRemaining); } +static void +virtDBusDomainGetMemoryParameters(GVariant *inArgs, + GUnixFDList *inFDs G_GNUC_UNUSED, + const gchar *objectPath, + gpointer userData, + GVariant **outArgs, + GUnixFDList **outFDs G_GNUC_UNUSED, + GError **error) +{ + virtDBusConnect *connect = userData; + g_autoptr(virDomain) domain = NULL; + g_autofree virTypedParameterPtr params = NULL; + gint nparams = 0; + guint flags; + gint ret; + GVariant *grecords; + + g_variant_get(inArgs, "(u)", &flags); + + domain = virtDBusDomainGetVirDomain(connect, objectPath, error); + if (!domain) + return; + + ret = virDomainGetMemoryParameters(domain, NULL, &nparams, flags); + if (ret == 0 && nparams != 0) { + params = g_new0(virTypedParameter, nparams); + if (virDomainGetMemoryParameters(domain, params, &nparams, flags) < 0) + return virtDBusUtilSetLastVirtError(error); + } + + grecords = virtDBusUtilTypedParamsToGVariant(params, nparams); + + *outArgs = g_variant_new_tuple(&grecords, 1); +} + G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainStatsRecordPtr, virDomainStatsRecordListFree); static void @@ -892,6 +927,7 @@ static virtDBusGDBusMethodTable virtDBusDomainMethodTable[] = { { "Destroy", virtDBusDomainDestroy }, { "DetachDevice", virtDBusDomainDetachDevice }, { "GetJobInfo", virtDBusDomainGetJobInfo }, + { "GetMemoryParameters", virtDBusDomainGetMemoryParameters }, { "GetStats", virtDBusDomainGetStats }, { "GetVcpus", virtDBusDomainGetVcpus }, { "GetXMLDesc", virtDBusDomainGetXMLDesc }, -- 2.15.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list