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

[libvirt] [PATCH] Wire up sysinfo for LXC driver



From: "Daniel P. Berrange" <berrange redhat com>

The sysinfo code used by QEMU is trivially portable to the
LXC driver
---
 src/lxc/lxc_conf.h   |  3 +++
 src/lxc/lxc_driver.c | 29 +++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/src/lxc/lxc_conf.h b/src/lxc/lxc_conf.h
index b46dc32..f8f7c9a 100644
--- a/src/lxc/lxc_conf.h
+++ b/src/lxc/lxc_conf.h
@@ -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;
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index ba14db7..17f01d5 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -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);
@@ -4547,6 +4551,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,
@@ -4555,6 +4583,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 */
-- 
1.8.1.4


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