mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 20:45:18 +00:00
libxl: Implement virConnectGetSysinfo
virConnectGetSysinfo was never implemented in the libxl driver. This patch provides an implementation based on the qemu driver.
This commit is contained in:
parent
ba64b97134
commit
fdc10e8d80
@ -74,6 +74,7 @@ struct _libxlDriverPrivate {
|
||||
virDomainObjListPtr domains;
|
||||
|
||||
virDomainEventStatePtr domainEventState;
|
||||
virSysinfoDefPtr hostsysinfo;
|
||||
|
||||
char *configDir;
|
||||
char *autostartDir;
|
||||
|
@ -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 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user