]> xenbits.xensource.com Git - libvirt.git/commitdiff
Add LXC version implementation
authorDan Smith <danms@us.ibm.com>
Wed, 3 Sep 2008 17:21:27 +0000 (17:21 +0000)
committerDan Smith <danms@us.ibm.com>
Wed, 3 Sep 2008 17:21:27 +0000 (17:21 +0000)
This patch adds an implementation of the version function to the LXC driver.
The providers use the hypervisor version in a field of one of the instances,
so we need to have something meaningful here.  AFAICT, the only real option
we have (considering the limitations of the libvirt version information) is
to use the kernel version.

ChangeLog
src/lxc_driver.c

index 0a471876d3200ffc9165f39bf99cc96741a90825..33ae01b7d681f6bed6f23da6d5fc2a95600fcc21 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Wed Sep  3 10:14:00 PDT 2008 Dan Smith <danms@us.ibm.com>
+       * src/lxc_driver.c:
+         Add hypervisor version implementation
+
 Wed Sep  3 11:52:00 EST 2008 Cole Robinson <crobinso@redhat.com>
 
        * src/domain_conf.c src/domain_conf.h src/qemu_driver.c:
index 8d2e617fc435382dcbe9dfa5899bb8b77a63414e..fd1eff436bc2210ad5db83f8f8a5082dd9edaf7e 100644 (file)
@@ -1110,6 +1110,29 @@ lxcActive(void) {
     return 0;
 }
 
+static int lxcVersion(virConnectPtr conn, unsigned long *version)
+{
+    struct utsname ver;
+    int maj;
+    int min;
+    int rev;
+
+    if (uname(&ver) != 0) {
+        lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR,
+                 _("uname(): %m"));
+        return -1;
+    }
+
+    if (sscanf(ver.release, "%i.%i.%i", &maj, &min, &rev) != 3) {
+        lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR,
+                 _("Unknown release: %s"), ver.release);
+        return -1;
+    }
+
+    *version = (maj * 1000 * 1000) + (min * 1000) + rev;
+
+    return 0;
+}
 
 /* Function Tables */
 static virDriver lxcDriver = {
@@ -1121,7 +1144,7 @@ static virDriver lxcDriver = {
     lxcClose, /* close */
     NULL, /* supports_feature */
     NULL, /* type */
-    NULL, /* version */
+    lxcVersion, /* version */
     NULL, /* getHostname */
     NULL, /* getURI */
     NULL, /* getMaxVcpus */