[libvirt] [PATCH] lxc: Add lxcGetHostname()

Dan Smith danms at us.ibm.com
Tue Apr 14 18:29:36 UTC 2009


This patch adds the getHostname method to the lxc driver structure
(using the qemu driver's generic code).  Apparently virsh started
using that method during console attachment recently.  Without this
implementation, the virsh refused to attach to lxc consoles.

Signed-off-by: Dan Smith <danms at us.ibm.com>

-- 
Dan Smith
IBM Linux Technology Center
email: danms at us.ibm.com

Index: src/lxc_driver.c
===================================================================
RCS file: /data/cvs/libvirt/src/lxc_driver.c,v
retrieving revision 1.65
diff -u -r1.65 lxc_driver.c
--- src/lxc_driver.c	31 Mar 2009 15:47:17 -0000	1.65
+++ src/lxc_driver.c	14 Apr 2009 18:22:45 -0000
@@ -1404,6 +1404,20 @@
     return ret;
 }
 
+static char *lxcGetHostname (virConnectPtr conn)
+{
+    char *result;
+
+    result = virGetHostname();
+    if (result == NULL) {
+        virReportSystemError (conn, errno,
+                              "%s", _("failed to determine host name"));
+        return NULL;
+    }
+    /* Caller frees this string. */
+    return result;
+}
+
 /* Function Tables */
 static virDriver lxcDriver = {
     VIR_DRV_LXC, /* the number virDrvNo */
@@ -1413,7 +1427,7 @@
     NULL, /* supports_feature */
     NULL, /* type */
     lxcVersion, /* version */
-    NULL, /* getHostname */
+    lxcGetHostname, /* getHostname */
     NULL, /* getMaxVcpus */
     NULL, /* nodeGetInfo */
     NULL, /* getCapabilities */




More information about the libvir-list mailing list