From 6202b72387b22b12b804852bcd5c4200ee3a1af5 Mon Sep 17 00:00:00 2001 From: Maxim Nestratov Date: Thu, 7 Apr 2016 21:52:43 +0300 Subject: [PATCH] vz: implement connectGetSysinfo hypervisor callback Signed-off-by: Maxim Nestratov --- src/vz/vz_driver.c | 25 +++++++++++++++++++++++++ src/vz/vz_utils.h | 1 + 2 files changed, 26 insertions(+) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index e8b536e835..b7c26d19ed 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -179,6 +179,7 @@ static void vzDriverDispose(void * obj) virObjectUnref(driver->caps); virObjectUnref(driver->xmlopt); virObjectEventStateFree(driver->domainEventState); + virSysinfoDefFree(driver->hostsysinfo); } static int vzDriverOnceInit(void) @@ -312,6 +313,7 @@ vzDriverObjNew(void) return NULL; } + driver->hostsysinfo = virSysinfoRead(); ignore_value(prlsdkLoadDomains(driver)); return driver; } @@ -421,6 +423,28 @@ static char *vzConnectGetHostname(virConnectPtr conn ATTRIBUTE_UNUSED) return virGetHostname(); } +static char * +vzConnectGetSysinfo(virConnectPtr conn, unsigned int flags) +{ + vzConnPtr privconn = conn->privateData; + vzDriverPtr driver = privconn->driver; + 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 (virBufferCheckError(&buf) < 0) + return NULL; + + return virBufferContentAndReset(&buf); +} static int vzConnectListDomains(virConnectPtr conn, int *ids, int maxids) @@ -1576,6 +1600,7 @@ static virHypervisorDriver vzHypervisorDriver = { .connectClose = vzConnectClose, /* 0.10.0 */ .connectGetVersion = vzConnectGetVersion, /* 0.10.0 */ .connectGetHostname = vzConnectGetHostname, /* 0.10.0 */ + .connectGetSysinfo = vzConnectGetSysinfo, /* 1.3.4 */ .connectGetMaxVcpus = vzConnectGetMaxVcpus, /* 1.2.21 */ .nodeGetInfo = vzNodeGetInfo, /* 0.10.0 */ .nodeGetCPUStats = vzNodeGetCPUStats, /* 1.2.21 */ diff --git a/src/vz/vz_utils.h b/src/vz/vz_utils.h index 5c14048b67..64a03485e0 100644 --- a/src/vz/vz_utils.h +++ b/src/vz/vz_utils.h @@ -70,6 +70,7 @@ struct _vzDriver { virCapsPtr caps; virDomainXMLOptionPtr xmlopt; virObjectEventStatePtr domainEventState; + virSysinfoDefPtr hostsysinfo; unsigned long vzVersion; vzCapabilities vzCaps; };