[dbus PATCH v2 2/5] Implement Resume 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 |  4 ++++
 src/domain.c                | 21 +++++++++++++++++++++
 test/test_domain.py         | 17 +++++++++++++++++
 3 files changed, 42 insertions(+)

diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
index f31d078..7679018 100644
--- a/data/org.libvirt.Domain.xml
+++ b/data/org.libvirt.Domain.xml
@@ -88,6 +88,10 @@
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainSuspend"/>
     </method>
+    <method name="Resume">
+      <annotation name="org.gtk.GDBus.DocString"
+        value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainResume"/>
+    </method>
     <signal name="DeviceAdded">
       <annotation name="org.gtk.GDBus.DocString"
         value="See https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectDomainEventDeviceAddedCallback"/>
diff --git a/src/domain.c b/src/domain.c
index cb13b6b..a530987 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -470,6 +470,26 @@ virtDBusDomainSuspend(GVariant *inArgs G_GNUC_UNUSED,
         virtDBusUtilSetLastVirtError(error);
 }
 
+static void
+virtDBusDomainResume(GVariant *inArgs G_GNUC_UNUSED,
+                     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;
+
+    domain = virtDBusDomainGetVirDomain(connect, objectPath, error);
+    if (!domain)
+        return;
+
+    if (virDomainResume(domain) < 0)
+        virtDBusUtilSetLastVirtError(error);
+}
+
 static virtDBusGDBusPropertyTable virtDBusDomainPropertyTable[] = {
     { "Name", virtDBusDomainGetName, NULL },
     { "UUID", virtDBusDomainGetUUID, NULL },
@@ -493,6 +513,7 @@ static virtDBusGDBusMethodTable virtDBusDomainMethodTable[] = {
     { "Create", virtDBusDomainCreate },
     { "Undefine", virtDBusDomainUndefine },
     { "Suspend", virtDBusDomainSuspend },
+    { "Resume", virtDBusDomainResume },
     { 0 }
 };
 
diff --git a/test/test_domain.py b/test/test_domain.py
index bb1b498..1433ff5 100755
--- a/test/test_domain.py
+++ b/test/test_domain.py
@@ -83,5 +83,22 @@ class TestDomain(libvirttest.BaseTestClass):
 
         self.main_loop()
 
+    def test_resume(self):
+        def domain_resumed(name, path):
+            assert name == 'test'
+            assert isinstance(path, dbus.ObjectPath)
+            self.loop.quit()
+
+        self.connect.connect_to_signal('DomainResumed', domain_resumed)
+
+        obj, domain = self.domain()
+        domain.Suspend()
+        domain.Resume()
+
+        state = obj.Get('org.libvirt.Domain', 'State', dbus_interface=dbus.PROPERTIES_IFACE)
+        assert state == 'running'
+
+        self.main_loop()
+
 if __name__ == '__main__':
     libvirttest.run()
-- 
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