On Mon, Dec 12, 2011 at 04:04:44PM +0000, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange(a)redhat.com>
---
libvirt-gobject/libvirt-gobject-domain.c | 48 ++++++++++++++++++++++++++++++
libvirt-gobject/libvirt-gobject-domain.h | 6 ++++
libvirt-gobject/libvirt-gobject.sym | 1 +
3 files changed, 55 insertions(+), 0 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-domain.c
b/libvirt-gobject/libvirt-gobject-domain.c
index 7bfb0ae..331a533 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -589,3 +589,51 @@ end:
virStreamFree(st);
return mime;
}
+
+
+/**
+ * gvir_domain_open_console:
+ * @dom: (transfer none): the domain
+ * @devname: (transfer none)(allow-none): the device name
+ * @stream: (transfer none): stream to use as output
+ * @flags: extra flags, currently unused
+ *
+ * Open a text console for the domain @dom, connecting it to the
+ * stream @stream. If @devname is NULL, the default console will
+ * be opened, otherwise @devname can be used to specify a non-default
+ * console device.
+ *
+ * Returns: TRUE if the console was opened, FALSE otherwise.
+ */
+gboolean gvir_domain_open_console(GVirDomain *dom,
+ GVirStream *stream,
+ const gchar *devname,
+ guint flags,
+ GError **err)
+{
+ GVirDomainPrivate *priv;
+ virStreamPtr st = NULL;
+ gboolean ret = FALSE;
+
+ g_return_val_if_fail(GVIR_IS_DOMAIN(dom), FALSE);
+ g_return_val_if_fail(GVIR_IS_STREAM(stream), FALSE);
+
+ priv = dom->priv;
+ g_object_get(stream, "handle", &st, NULL);
+
+ if (virDomainOpenConsole(priv->handle,
+ devname,
+ st,
+ flags) < 0) {
+ gvir_set_error_literal(err, GVIR_DOMAIN_ERROR,
+ 0,
+ "Unable to open console");
+ goto cleanup;
+ }
+
+ ret = TRUE;
+cleanup:
+ if (st != NULL)
+ virStreamFree(st);
I'd go with g_boxed_free I think, but that's just a small detail, ACK.
Christophe
+ return ret;
+}
diff --git a/libvirt-gobject/libvirt-gobject-domain.h
b/libvirt-gobject/libvirt-gobject-domain.h
index b9e39dd..3a4dd02 100644
--- a/libvirt-gobject/libvirt-gobject-domain.h
+++ b/libvirt-gobject/libvirt-gobject-domain.h
@@ -141,6 +141,12 @@ gchar *gvir_domain_screenshot(GVirDomain *dom,
guint flags,
GError **err);
+gboolean gvir_domain_open_console(GVirDomain *dom,
+ GVirStream *stream,
+ const gchar *devname,
+ guint flags,
+ 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 d0444bd..caef28d 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -52,6 +52,7 @@ LIBVIRT_GOBJECT_0.0.1 {
gvir_domain_resume;
gvir_domain_stop;
gvir_domain_delete;
+ gvir_domain_open_console;
gvir_domain_shutdown;
gvir_domain_reboot;
gvir_domain_get_config;
--
1.7.7.3
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list