[dbus PATCH v2 12/22] Implement ManagedSave 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 |  5 +++++
 src/domain.c                | 24 ++++++++++++++++++++++++
 test/test_domain.py         | 15 +++++++++++++++
 3 files changed, 44 insertions(+)

diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
index 3903689..382b062 100644
--- a/data/org.libvirt.Domain.xml
+++ b/data/org.libvirt.Domain.xml
@@ -90,6 +90,11 @@
       <arg name="flags" type="u" direction="in"/>
       <arg name="xml" type="s" direction="out"/>
     </method>
+    <method name="ManagedSave">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainManagedSave"/>
+      <arg name="flags" type="u" direction="in"/>
+    </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 e1b2d72..53f8798 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -542,6 +542,29 @@ virtDBusDomainGetXMLDesc(GVariant *inArgs,
     *outArgs = g_variant_new("(s)", xml);
 }
 
+static void
+virtDBusDomainManagedSave(GVariant *inArgs,
+                          GUnixFDList *inFDs G_GNUC_UNUSED,
+                          const gchar *objectPath,
+                          gpointer userData,
+                          GVariant **outArgs G_GNUC_UNUSED,
+                          GUnixFDList **outFDs G_GNUC_UNUSED,
+                          GError **error)
+{
+    virtDBusConnect *connect = userData;
+    g_autoptr(virDomain) domain = NULL;
+    guint flags;
+
+    g_variant_get(inArgs, "(u)", &flags);
+
+    domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
+    if (!domain)
+        return;
+
+    if (virDomainManagedSave(domain, flags) < 0)
+        virtDBusUtilSetLastVirtError(error);
+}
+
 static void
 virtDBusDomainMemoryStats(GVariant *inArgs,
                           GUnixFDList *inFDs G_GNUC_UNUSED,
@@ -786,6 +809,7 @@ static virtDBusGDBusMethodTable virtDBusDomainMethodTable[] = {
     { "GetStats", virtDBusDomainGetStats },
     { "GetVcpus", virtDBusDomainGetVcpus },
     { "GetXMLDesc", virtDBusDomainGetXMLDesc },
+    { "ManagedSave", virtDBusDomainManagedSave },
     { "MemoryStats", virtDBusDomainMemoryStats },
     { "MigrateGetMaxDowntime", virtDBusDomainMigrateGetMaxDowntime },
     { "MigrateSetMaxDowntime", virtDBusDomainMigrateSetMaxDowntime },
diff --git a/test/test_domain.py b/test/test_domain.py
index a7cf962..31348ce 100755
--- a/test/test_domain.py
+++ b/test/test_domain.py
@@ -47,6 +47,21 @@ class TestDomain(libvirttest.BaseTestClass):
         autostart_current = domain.Get('org.libvirt.Domain', 'Autostart', dbus_interface=dbus.PROPERTIES_IFACE)
         assert autostart_current == dbus.Boolean(autostart_expected)
 
+    def test_domain_managed_save(self):
+        def domain_stopped(path, _event):
+            assert isinstance(path, dbus.ObjectPath)
+            self.loop.quit()
+
+        self.connect.connect_to_signal('DomainEvent', domain_stopped, arg1='Stopped')
+
+        obj, domain = self.domain()
+        domain.ManagedSave(0)
+
+        state = obj.Get('org.libvirt.Domain', 'State', dbus_interface=dbus.PROPERTIES_IFACE)
+        assert state == 'shutoff'
+
+        self.main_loop()
+
     def test_resume(self):
         def domain_resumed(path, _event):
             assert isinstance(path, dbus.ObjectPath)
-- 
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