[dbus PATCH v2 13/22] Implement HasManagedSaveImage 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                | 29 +++++++++++++++++++++++++++++
 test/test_domain.py         |  2 +-
 3 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
index 382b062..57e5ea4 100644
--- a/data/org.libvirt.Domain.xml
+++ b/data/org.libvirt.Domain.xml
@@ -90,6 +90,12 @@
       <arg name="flags" type="u" direction="in"/>
       <arg name="xml" type="s" direction="out"/>
     </method>
+    <method name="HasManagedSaveImage">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainHasManagedSaveImage"/>
+      <arg name="flags" type="u" direction="in"/>
+      <arg name="managedSaveImage" type="u" direction="out"/>
+    </method>
     <method name="ManagedSave">
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainManagedSave"/>
diff --git a/src/domain.c b/src/domain.c
index 53f8798..26f6bbf 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -542,6 +542,34 @@ virtDBusDomainGetXMLDesc(GVariant *inArgs,
     *outArgs = g_variant_new("(s)", xml);
 }
 
+static void
+virtDBusDomainHasManagedSaveImage(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;
+    gint managedSaveImage;
+    guint flags;
+
+    g_variant_get(inArgs, "(u)", &flags);
+
+    domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
+    if (!domain)
+        return;
+
+    managedSaveImage = virDomainHasManagedSaveImage(domain, flags);
+    if (managedSaveImage < 0)
+        return virtDBusUtilSetLastVirtError(error);
+
+    *outArgs = g_variant_new("(u)", managedSaveImage);
+}
+
 static void
 virtDBusDomainManagedSave(GVariant *inArgs,
                           GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -809,6 +837,7 @@ static virtDBusGDBusMethodTable virtDBusDomainMethodTable[] = {
     { "GetStats", virtDBusDomainGetStats },
     { "GetVcpus", virtDBusDomainGetVcpus },
     { "GetXMLDesc", virtDBusDomainGetXMLDesc },
+    { "HasManagedSaveImage", virtDBusDomainHasManagedSaveImage },
     { "ManagedSave", virtDBusDomainManagedSave },
     { "MemoryStats", virtDBusDomainMemoryStats },
     { "MigrateGetMaxDowntime", virtDBusDomainMigrateGetMaxDowntime },
diff --git a/test/test_domain.py b/test/test_domain.py
index 31348ce..13f27f7 100755
--- a/test/test_domain.py
+++ b/test/test_domain.py
@@ -56,7 +56,7 @@ class TestDomain(libvirttest.BaseTestClass):
 
         obj, domain = self.domain()
         domain.ManagedSave(0)
-
+        assert domain.HasManagedSaveImage(0) == dbus.Boolean(True)
         state = obj.Get('org.libvirt.Domain', 'State', dbus_interface=dbus.PROPERTIES_IFACE)
         assert state == 'shutoff'
 
-- 
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