[dbus PATCH 04/25] Implement BlockPeek metohd for Domain Interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx>
---
 data/org.libvirt.Domain.xml |  9 +++++++++
 src/domain.c                | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+)

diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
index 48b8a95..85e2cf6 100644
--- a/data/org.libvirt.Domain.xml
+++ b/data/org.libvirt.Domain.xml
@@ -54,6 +54,15 @@
       <arg name="xml" type="s" direction="in"/>
       <arg name="flags" type="u" direction="in"/>
     </method>
+    <method name="BlockPeek">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainCreateWithFlags"/>
+      <arg name="disk" type="s" direction="in"/>
+      <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="Create">
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainCreateWithFlags"/>
diff --git a/src/domain.c b/src/domain.c
index 9197755..c02e289 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -383,6 +383,44 @@ virtDBusDomainAttachDevice(GVariant *inArgs,
         virtDBusUtilSetLastVirtError(error);
 }
 
+static void
+virtDBusDomainBlockPeek(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;
+    const gchar *disk;
+    gulong offset;
+    guint size;
+    guint flags;
+    g_autofree guchar *buffer = NULL;
+    GVariantBuilder *builder;
+    GVariant *res;
+
+    g_variant_get(inArgs, "(&stuu)", &disk, &offset, &size, &flags);
+
+    domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
+    if (!domain)
+        return;
+
+    buffer = g_new0(guchar, size);
+    if (virDomainBlockPeek(domain, disk, 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
 virtDBusDomainCreate(GVariant *inArgs,
                      GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -1203,6 +1241,7 @@ static virtDBusGDBusPropertyTable virtDBusDomainPropertyTable[] = {
 static virtDBusGDBusMethodTable virtDBusDomainMethodTable[] = {
     { "AbortJob", virtDBusDomainAbortJob },
     { "AttachDevice", virtDBusDomainAttachDevice },
+    { "BlockPeek", virtDBusDomainBlockPeek },
     { "Create", virtDBusDomainCreate },
     { "Destroy", virtDBusDomainDestroy },
     { "DetachDevice", virtDBusDomainDetachDevice },
-- 
2.15.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux