From 0cb88f3b3895c1edca36cf748bd22f30e804d973 Mon Sep 17 00:00:00 2001 From: Roman Bogorodskiy Date: Wed, 23 Apr 2014 13:24:05 +0400 Subject: [PATCH] bhyve: implement connectGetSysinfo --- src/bhyve/bhyve_driver.c | 31 +++++++++++++++++++++++++++++++ src/bhyve/bhyve_utils.h | 1 + 2 files changed, 32 insertions(+) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 67571d2a40..580b12460d 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -238,6 +238,33 @@ bhyveConnectGetHostname(virConnectPtr conn ATTRIBUTE_UNUSED) return virGetHostname(); } +static char * +bhyveConnectGetSysinfo(virConnectPtr conn, unsigned int flags) +{ + bhyveConnPtr privconn = conn->privateData; + virBuffer buf = VIR_BUFFER_INITIALIZER; + + virCheckFlags(0, NULL); + + if (virConnectGetSysinfoEnsureACL(conn) < 0) + return NULL; + + if (!privconn->hostsysinfo) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Host SMBIOS information is not available")); + return NULL; + } + + if (virSysinfoFormat(&buf, privconn->hostsysinfo) < 0) + return NULL; + if (virBufferError(&buf)) { + virReportOOMError(); + return NULL; + } + + return virBufferContentAndReset(&buf); +} + static int bhyveConnectGetVersion(virConnectPtr conn ATTRIBUTE_UNUSED, unsigned long *version) { @@ -1047,6 +1074,7 @@ bhyveStateCleanup(void) virObjectUnref(bhyve_driver->domains); virObjectUnref(bhyve_driver->caps); virObjectUnref(bhyve_driver->xmlopt); + virObjectUnref(bhyve_driver->hostsysinfo); virObjectUnref(bhyve_driver->closeCallbacks); virMutexDestroy(&bhyve_driver->lock); @@ -1086,6 +1114,8 @@ bhyveStateInitialize(bool priveleged ATTRIBUTE_UNUSED, if (!(bhyve_driver->domains = virDomainObjListNew())) goto cleanup; + bhyve_driver->hostsysinfo = virSysinfoRead(); + if (virFileMakePath(BHYVE_LOG_DIR) < 0) { virReportSystemError(errno, _("Failed to mkdir %s"), @@ -1244,6 +1274,7 @@ static virDriver bhyveDriver = { .connectClose = bhyveConnectClose, /* 1.2.2 */ .connectGetVersion = bhyveConnectGetVersion, /* 1.2.2 */ .connectGetHostname = bhyveConnectGetHostname, /* 1.2.2 */ + .connectGetSysinfo = bhyveConnectGetSysinfo, /* 1.2.5 */ .domainGetInfo = bhyveDomainGetInfo, /* 1.2.2 */ .domainGetState = bhyveDomainGetState, /* 1.2.2 */ .connectGetCapabilities = bhyveConnectGetCapabilities, /* 1.2.2 */ diff --git a/src/bhyve/bhyve_utils.h b/src/bhyve/bhyve_utils.h index 94f31b0855..22f458de80 100644 --- a/src/bhyve/bhyve_utils.h +++ b/src/bhyve/bhyve_utils.h @@ -39,6 +39,7 @@ struct _bhyveConn { virCapsPtr caps; virDomainXMLOptionPtr xmlopt; char *pidfile; + virSysinfoDefPtr hostsysinfo; virCloseCallbacksPtr closeCallbacks; };