[PATCH 1/2] libxl: Implement virConnectGetSysinfo

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

 



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(+), 0 deletions(-)

diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
index 754fc40..ea741bc 100644
--- a/src/libxl/libxl_conf.h
+++ b/src/libxl/libxl_conf.h
@@ -70,6 +70,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 935919b..0cdce86 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -45,6 +45,7 @@
 #include "virtypedparam.h"
 #include "viruri.h"
 #include "virstring.h"
+#include "virsysinfo.h"
 
 #define VIR_FROM_THIS VIR_FROM_LIBXL
 
@@ -1137,6 +1138,7 @@ libxlStateCleanup(void)
     VIR_FREE(libxl_driver->saveDir);
 
     virDomainEventStateFree(libxl_driver->domainEventState);
+    virSysinfoDefFree(libxl_driver->hostsysinfo);
 
     libxlDriverUnlock(libxl_driver);
     virMutexDestroy(&libxl_driver->lock);
@@ -1242,6 +1244,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;
@@ -1425,6 +1431,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)
@@ -4363,6 +4391,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 */
-- 
1.7.7

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]