Signed-off-by: Katerina Koukiou <kkoukiou(a)redhat.com>
---
data/org.libvirt.Domain.xml | 4 ++++
src/domain.c | 21 +++++++++++++++++++++
test/test_domain.py | 15 +++++++++++++++
3 files changed, 40 insertions(+)
diff --git a/data/org.libvirt.Domain.xml b/data/org.libvirt.Domain.xml
index 39212ff..f31d078 100644
--- a/data/org.libvirt.Domain.xml
+++ b/data/org.libvirt.Domain.xml
@@ -84,6 +84,10 @@
value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainUndefineFla...
<arg name="flags" type="u" direction="in"/>
</method>
+ <method name="Suspend">
+ <annotation name="org.gtk.GDBus.DocString"
+ value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainSuspend&quo...
+ </method>
<signal name="DeviceAdded">
<annotation name="org.gtk.GDBus.DocString"
value="See
https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectDomainEven...
diff --git a/src/domain.c b/src/domain.c
index 4ff9f60..cb13b6b 100644
--- a/src/domain.c
+++ b/src/domain.c
@@ -450,6 +450,26 @@ virtDBusDomainUndefine(GVariant *inArgs G_GNUC_UNUSED,
virtDBusUtilSetLastVirtError(error);
}
+static void
+virtDBusDomainSuspend(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 (virDomainSuspend(domain) < 0)
+ virtDBusUtilSetLastVirtError(error);
+}
+
static virtDBusGDBusPropertyTable virtDBusDomainPropertyTable[] = {
{ "Name", virtDBusDomainGetName, NULL },
{ "UUID", virtDBusDomainGetUUID, NULL },
@@ -472,6 +492,7 @@ static virtDBusGDBusMethodTable virtDBusDomainMethodTable[] = {
{ "Reset", virtDBusDomainReset },
{ "Create", virtDBusDomainCreate },
{ "Undefine", virtDBusDomainUndefine },
+ { "Suspend", virtDBusDomainSuspend },
{ 0 }
};
diff --git a/test/test_domain.py b/test/test_domain.py
index e617b1b..bb1b498 100755
--- a/test/test_domain.py
+++ b/test/test_domain.py
@@ -67,6 +67,21 @@ class TestDomain(libvirttest.BaseTestClass):
self.main_loop()
+ def test_suspend(self):
+ def domain_suspended(name, path):
+ assert name == 'test'
+ assert isinstance(path, dbus.ObjectPath)
+ self.loop.quit()
+
+ self.connect.connect_to_signal('DomainSuspended', domain_suspended)
+
+ obj, domain = self.domain()
+ domain.Suspend()
+
+ state = obj.Get('org.libvirt.Domain', 'State',
dbus_interface=dbus.PROPERTIES_IFACE)
+ assert state == 'paused'
+
+ self.main_loop()
if __name__ == '__main__':
libvirttest.run()
--
2.15.0