From fdc10e8d80395945fa49d7b9318f89517604839d Mon Sep 17 00:00:00 2001 From: Jim Fehlig Date: Wed, 12 Jun 2013 09:49:27 -0600 Subject: [PATCH] libxl: Implement virConnectGetSysinfo virConnectGetSysinfo was never implemented in the libxl driver. This patch provides an implementation based on the qemu driver. --- src/libxl/libxl_conf.h | 1 + src/libxl/libxl_driver.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h index 16982c3846..2b4a28166a 100644 --- a/src/libxl/libxl_conf.h +++ b/src/libxl/libxl_conf.h @@ -74,6 +74,7 @@ struct _libxlDriverPrivate { virDomainObjListPtr domains; virDomainEventStatePtr domainEventState; + virSysinfoDefPtr hostsysinfo; char *configDir; char *autostartDir; diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 20ad41f264..a5dffc178f 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -46,6 +46,7 @@ #include "virtypedparam.h" #include "viruri.h" #include "virstring.h" +#include "virsysinfo.h" #define VIR_FROM_THIS VIR_FROM_LIBXL @@ -1153,6 +1154,7 @@ libxlStateCleanup(void) VIR_FREE(libxl_driver->saveDir); virDomainEventStateFree(libxl_driver->domainEventState); + virSysinfoDefFree(libxl_driver->hostsysinfo); libxlDriverUnlock(libxl_driver); virMutexDestroy(&libxl_driver->lock); @@ -1282,6 +1284,10 @@ libxlStateInitialize(bool privileged, } VIR_FREE(log_file); + /* read the host sysinfo */ + if (privileged) + libxl_driver->hostsysinfo = virSysinfoRead(); + libxl_driver->domainEventState = virDomainEventStateNew(); if (!libxl_driver->domainEventState) goto error; @@ -1475,6 +1481,28 @@ static char *libxlConnectGetHostname(virConnectPtr conn ATTRIBUTE_UNUSED) return virGetHostname(); } +static char * +libxlConnectGetSysinfo(virConnectPtr conn, unsigned int flags) +{ + libxlDriverPrivatePtr 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); +} static int libxlConnectGetMaxVcpus(virConnectPtr conn, const char *type ATTRIBUTE_UNUSED) @@ -4413,6 +4441,7 @@ static virDriver libxlDriver = { .connectGetType = libxlConnectGetType, /* 0.9.0 */ .connectGetVersion = libxlConnectGetVersion, /* 0.9.0 */ .connectGetHostname = libxlConnectGetHostname, /* 0.9.0 */ + .connectGetSysinfo = libxlConnectGetSysinfo, /* 1.0.7 */ .connectGetMaxVcpus = libxlConnectGetMaxVcpus, /* 0.9.0 */ .nodeGetInfo = libxlNodeGetInfo, /* 0.9.0 */ .connectGetCapabilities = libxlConnectGetCapabilities, /* 0.9.0 */