[libvirt-glib] API to suspend a domain

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Zeeshan Ali (Khattak)" <zeeshanak@xxxxxxxxx>

---
 libvirt-gobject/libvirt-gobject-domain.c |   30 ++++++++++++++++++++++++++++++
 libvirt-gobject/libvirt-gobject-domain.h |    3 +++
 libvirt-gobject/libvirt-gobject.sym      |    1 +
 3 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c
index 4301b14..0b52538 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -678,3 +678,33 @@ gboolean gvir_domain_open_graphics(GVirDomain *dom,
 cleanup:
     return ret;
 }
+
+/**
+ * gir_domain_suspend:
+ * @dom: the domain to suspend
+ * @err: Place-holder for possible errors
+ *
+ * Suspends an active domain, the process is frozen without further access to
+ * CPU resources and I/O but the memory used by the domain at the hypervisor
+ * level will stay allocated. Use gvir_domain_resume() to reactivate the domain.
+ *
+ * Returns: TRUE if domain was saved successfully, FALSE otherwise.
+ */
+gboolean gvir_domain_suspend (GVirDomain *dom,
+                              GError **err)
+{
+    gboolean ret = FALSE;
+
+    g_return_val_if_fail(GVIR_IS_DOMAIN(dom), FALSE);
+
+    if (virDomainSuspend(dom->priv->handle) < 0) {
+        gvir_set_error_literal(err, GVIR_DOMAIN_ERROR,
+                               0,
+                               "Unable to suspend domain");
+        goto cleanup;
+    }
+
+    ret = TRUE;
+cleanup:
+    return ret;
+}
diff --git a/libvirt-gobject/libvirt-gobject-domain.h b/libvirt-gobject/libvirt-gobject-domain.h
index 6fcec8d..a5923f4 100644
--- a/libvirt-gobject/libvirt-gobject-domain.h
+++ b/libvirt-gobject/libvirt-gobject-domain.h
@@ -153,6 +153,9 @@ gboolean gvir_domain_open_graphics(GVirDomain *dom,
                                    unsigned int flags,
                                    GError **err);
 
+gboolean gvir_domain_suspend (GVirDomain *dom,
+                              GError **err);
+
 G_END_DECLS
 
 #endif /* __LIBVIRT_GOBJECT_DOMAIN_H__ */
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index a523adc..526098d 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -51,6 +51,7 @@ LIBVIRT_GOBJECT_0.0.3 {
 	gvir_domain_start;
 	gvir_domain_resume;
 	gvir_domain_stop;
+	gvir_domain_suspend;
 	gvir_domain_delete;
 	gvir_domain_open_console;
 	gvir_domain_open_graphics;
-- 
1.7.7.4

--
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]