Wire up sysinfo for LXC driver

The sysinfo code used by QEMU is trivially portable to the
LXC driver
This commit is contained in:
Daniel P. Berrange 2013-04-03 18:55:20 +01:00
parent e2b373e6d6
commit 6263fc5a5b
2 changed files with 32 additions and 0 deletions

View 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;

View 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 */