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

[libvirt] [PATCH 07/11] vz: implement connectGetSysinfo hypervisor callback



Signed-off-by: Maxim Nestratov <mnestratov virtuozzo com>
---
 src/vz/vz_driver.c | 26 ++++++++++++++++++++++++++
 src/vz/vz_utils.h  |  1 +
 2 files changed, 27 insertions(+)

diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 36030a7..4c30305 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -176,6 +176,7 @@ static void vzConnDispose(void * obj)
     virObjectUnref(conn->domains);
     virObjectUnref(conn->caps);
     virObjectUnref(conn->xmlopt);
+    virSysinfoDefFree(conn->hostsysinfo);
     virObjectEventStateFree(conn->domainEventState);
 }
 
@@ -299,6 +300,7 @@ vzConnObjNew(void)
         return NULL;
     }
 
+    conn->hostsysinfo = virSysinfoRead();
     return conn;
 }
 
@@ -375,6 +377,29 @@ static char *vzConnectGetHostname(virConnectPtr conn ATTRIBUTE_UNUSED)
     return virGetHostname();
 }
 
+static char *
+vzConnectGetSysinfo(virConnectPtr conn ATTRIBUTE_UNUSED, unsigned int flags)
+{
+    vzConnPtr privconn = vzGetConnection();
+    if (!privconn)
+        return NULL;
+    virBuffer buf = VIR_BUFFER_INITIALIZER;
+
+    virCheckFlags(0, 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 (virBufferCheckError(&buf) < 0)
+        return NULL;
+
+    return virBufferContentAndReset(&buf);
+}
 
 static int
 vzConnectListDomains(virConnectPtr conn ATTRIBUTE_UNUSED, int *ids, int maxids)
@@ -1568,6 +1593,7 @@ static virHypervisorDriver vzDriver = {
     .connectClose = vzConnectClose,          /* 0.10.0 */
     .connectGetVersion = vzConnectGetVersion,   /* 0.10.0 */
     .connectGetHostname = vzConnectGetHostname,      /* 0.10.0 */
+    .connectGetSysinfo = vzConnectGetSysinfo, /* 1.3.3 */
     .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 00e795f..a2b86c7 100644
--- a/src/vz/vz_utils.h
+++ b/src/vz/vz_utils.h
@@ -72,6 +72,7 @@ struct _vzConn {
     virObjectEventStatePtr domainEventState;
     /* Immutable pointer, self-locking APIs */
     virConnectCloseCallbackDataPtr closeCallback;
+    virSysinfoDefPtr hostsysinfo;
     unsigned long vzVersion;
     vzCapabilities vzCaps;
 };
-- 
2.4.3


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