Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx> --- data/org.libvirt.Domain.xml | 8 ++++++++ src/domain.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml index 85e2cf6..bd30ad4 100644 --- a/data/org.libvirt.Domain.xml +++ b/data/org.libvirt.Domain.xml @@ -148,6 +148,14 @@ value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainManagedSaveRemove"/> <arg name="flags" type="u" direction="in"/> </method> + <method name="MemoryPeek"> + <annotation name="org.gtk.GDBus.DocString" + value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainMemoryPeek"/> + <arg name="offset" type="t" direction="in"/> + <arg name="size" type="u" direction="in"/> + <arg name="flags" type="u" direction="in"/> + <arg name="buffer" type="ay" direction="out"/> + </method> <method name="MemoryStats"> <annotation name="org.gtk.GDBus.DocString" value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainMemoryStats"/> diff --git a/src/domain.c b/src/domain.c index c02e289..01f120d 100644 --- a/src/domain.c +++ b/src/domain.c @@ -859,6 +859,43 @@ virtDBusDomainManagedSaveRemove(GVariant *inArgs, virtDBusUtilSetLastVirtError(error); } +static void +virtDBusDomainMemoryPeek(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; + gulong offset; + guint size; + guint flags; + g_autofree guchar *buffer = NULL; + GVariantBuilder *builder; + GVariant *res; + + g_variant_get(inArgs, "(tuu)", &offset, &size, &flags); + + domain = virtDBusDomainGetVirDomain(connect, objectPath, error); + if (!domain) + return; + + buffer = g_new0(guchar, size); + if (virDomainMemoryPeek(domain, offset, size, buffer, flags) < 0) + virtDBusUtilSetLastVirtError(error); + + builder = g_variant_builder_new(G_VARIANT_TYPE("ay")); + for (unsigned int i = 0; i < size; i++) + g_variant_builder_add(builder, "y", buffer[i]); + + res = g_variant_builder_end(builder); + + *outArgs = g_variant_new_tuple(&res, 1); +} + static void virtDBusDomainMemoryStats(GVariant *inArgs, GUnixFDList *inFDs G_GNUC_UNUSED, @@ -1257,6 +1294,7 @@ static virtDBusGDBusMethodTable virtDBusDomainMethodTable[] = { { "InjectNMI", virtDBusDomainInjectNMI }, { "ManagedSave", virtDBusDomainManagedSave }, { "ManagedSaveRemove", virtDBusDomainManagedSaveRemove }, + { "MemoryPeek", virtDBusDomainMemoryPeek }, { "MemoryStats", virtDBusDomainMemoryStats }, { "MigrateGetMaxDowntime", virtDBusDomainMigrateGetMaxDowntime }, { "MigrateGetMaxSpeed", virtDBusDomainMigrateGetMaxSpeed }, -- 2.15.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list