[dbus PATCH 06/15] Impement GetFSInfo method 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 |  6 +++++
 src/domain.c                | 66 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+)

diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
index fbf7140..b7fa35f 100644
--- a/data/org.libvirt.Domain.xml
+++ b/data/org.libvirt.Domain.xml
@@ -197,6 +197,12 @@
       <arg name="flags" type="u" direction="in"/>
       <arg name="diskErrors" type="a(ss)" direction="out"/>
     </method>
+    <method name="GetFSInfo">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetFSInfo"/>
+      <arg name="flags" type="u" direction="in"/>
+      <arg name="fsInfo" type="a(sssas)" direction="out"/>
+    </method>
     <method name="GetJobInfo">
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainGetJobInfo"/>
diff --git a/src/domain.c b/src/domain.c
index 67ea260..1156b84 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -66,6 +66,25 @@ VIRT_DBUS_ENUM_IMPL(virtDBusDomainMetadata,
                     "title",
                     "element")
 
+struct _virtDBusDomainFSInfoList {
+    virDomainFSInfoPtr *info;
+    gint count;
+};
+
+typedef struct _virtDBusDomainFSInfoList virtDBusDomainFSInfoList;
+
+static void
+virtDBusDomainFSInfoListFree(virtDBusDomainFSInfoList *info)
+{
+    for (gint i = 0; i < info->count; i++)
+        virDomainFSInfoFree(info->info[i]);
+
+    g_free(info->info);
+}
+
+G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(virtDBusDomainFSInfoList,
+                                 virtDBusDomainFSInfoListFree);
+
 static GVariant *
 virtDBusDomainMemoryStatsToGVariant(virDomainMemoryStatPtr stats,
                                     gint nr_stats)
@@ -1056,6 +1075,52 @@ virtDBusDomainGetDiskErrors(GVariant *inArgs,
     *outArgs = g_variant_new_tuple(&res, 1);
 }
 
+static void
+virtDBusDomainGetFSInfo(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_auto(virtDBusDomainFSInfoList) info = { 0 };
+    GVariantBuilder builder;
+    guint flags;
+    GVariant *gret;
+
+    g_variant_get(inArgs, "(u)", &flags);
+
+    domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
+    if (!domain)
+        return;
+
+    info.count = virDomainGetFSInfo(domain, &info.info, flags);
+    if (info.count < 0)
+        return virtDBusUtilSetLastVirtError(error);
+
+    g_variant_builder_init(&builder, G_VARIANT_TYPE("a(sssas)"));
+
+    for (gint i = 0; i < info.count; i++) {
+        g_variant_builder_open(&builder, G_VARIANT_TYPE("(sssas)"));
+        g_variant_builder_add(&builder, "s", info.info[i]->mountpoint);
+        g_variant_builder_add(&builder, "s", info.info[i]->name);
+        g_variant_builder_add(&builder, "s", info.info[i]->fstype);
+
+        g_variant_builder_open(&builder, G_VARIANT_TYPE("as"));
+        for (guint j = 0; j < info.info[i]->ndevAlias; j++) {
+            g_variant_builder_add(&builder, "s", info.info[i]->devAlias[j]);
+            g_variant_builder_close(&builder);
+        }
+        g_variant_builder_close(&builder);
+    }
+    gret = g_variant_builder_end(&builder);
+
+    *outArgs = g_variant_new_tuple(&gret, 1);
+}
+
 static void
 virtDBusDomainGetJobInfo(GVariant *inArgs G_GNUC_UNUSED,
                          GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -2135,6 +2200,7 @@ static virtDBusGDBusMethodTable virtDBusDomainMethodTable[] = {
     { "GetBlockJobInfo", virtDBusDomainGetBlockJobInfo },
     { "GetControlInfo", virtDBusDomainGetControlInfo },
     { "GetDiskErrors", virtDBusDomainGetDiskErrors },
+    { "GetFSInfo", virtDBusDomainGetFSInfo },
     { "GetJobInfo", virtDBusDomainGetJobInfo },
     { "GetMemoryParameters", virtDBusDomainGetMemoryParameters },
     { "GetSchedulerParameters", virtDBusDomainGetSchedulerParameters },
-- 
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