]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Wire up sysinfo for LXC driver
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 3 Apr 2013 17:55:20 +0000 (18:55 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 4 Apr 2013 10:07:00 +0000 (11:07 +0100)
The sysinfo code used by QEMU is trivially portable to the
LXC driver

src/lxc/lxc_conf.h
src/lxc/lxc_driver.c

index b46dc322279256f042a901a073a64f0bf6b50377..f8f7c9ad7132f30f4ed268eeea9ebf6a78215b3a 100644 (file)
@@ -35,6 +35,7 @@
 # include "vircgroup.h"
 # include "security/security_manager.h"
 # include "configmake.h"
+# include "virsysinfo.h"
 # include "virusb.h"
 
 # define LXC_DRIVER_NAME "LXC"
@@ -55,6 +56,8 @@ struct _virLXCDriver {
 
     virCgroupPtr cgroup;
 
+    virSysinfoDefPtr hostsysinfo;
+
     size_t nactive;
     virStateInhibitCallback inhibitCallback;
     void *inhibitOpaque;
index 654ab99c67d26c2398577575297c3e3e7a49de1e..bb65ac7584251890c5bf5a78b3482ff7430b85b8 100644 (file)
@@ -1457,6 +1457,8 @@ static int lxcStartup(bool privileged,
     if (!lxc_driver->domainEventState)
         goto cleanup;
 
+    lxc_driver->hostsysinfo = virSysinfoRead();
+
     lxc_driver->log_libvirtd = 0; /* by default log to container logfile */
     lxc_driver->have_netns = lxcCheckNetNsSupport();
 
@@ -1574,6 +1576,8 @@ static int lxcShutdown(void)
 
     virLXCProcessAutoDestroyShutdown(lxc_driver);
 
+    virSysinfoDefFree(lxc_driver->hostsysinfo);
+
     virObjectUnref(lxc_driver->activeUsbHostdevs);
     virObjectUnref(lxc_driver->caps);
     virObjectUnref(lxc_driver->securityManager);
@@ -4536,6 +4540,30 @@ cleanup:
 }
 
 
+static char *
+lxcGetSysinfo(virConnectPtr conn, unsigned int flags)
+{
+    virLXCDriverPtr driver = conn->privateData;
+    virBuffer buf = VIR_BUFFER_INITIALIZER;
+
+    virCheckFlags(0, NULL);
+
+    if (!driver->hostsysinfo) {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                       _("Host SMBIOS information is not available"));
+        return NULL;
+    }
+
+    if (virSysinfoFormat(&buf, driver->hostsysinfo) < 0)
+        return NULL;
+    if (virBufferError(&buf)) {
+        virReportOOMError();
+        return NULL;
+    }
+    return virBufferContentAndReset(&buf);
+}
+
+
 /* Function Tables */
 static virDriver lxcDriver = {
     .no = VIR_DRV_LXC,
@@ -4544,6 +4572,7 @@ static virDriver lxcDriver = {
     .close = lxcClose, /* 0.4.2 */
     .version = lxcVersion, /* 0.4.6 */
     .getHostname = virGetHostname, /* 0.6.3 */
+    .getSysinfo = lxcGetSysinfo, /* 1.0.5 */
     .nodeGetInfo = nodeGetInfo, /* 0.6.5 */
     .getCapabilities = lxcGetCapabilities, /* 0.6.5 */
     .listDomains = lxcListDomains, /* 0.4.2 */