mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 18:05:20 +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;
|
virDomainObjListPtr domains;
|
||||||
|
|
||||||
virDomainEventStatePtr domainEventState;
|
virDomainEventStatePtr domainEventState;
|
||||||
|
virSysinfoDefPtr hostsysinfo;
|
||||||
|
|
||||||
char *configDir;
|
char *configDir;
|
||||||
char *autostartDir;
|
char *autostartDir;
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include "virtypedparam.h"
|
#include "virtypedparam.h"
|
||||||
#include "viruri.h"
|
#include "viruri.h"
|
||||||
#include "virstring.h"
|
#include "virstring.h"
|
||||||
|
#include "virsysinfo.h"
|
||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_LIBXL
|
#define VIR_FROM_THIS VIR_FROM_LIBXL
|
||||||
|
|
||||||
@ -1153,6 +1154,7 @@ libxlStateCleanup(void)
|
|||||||
VIR_FREE(libxl_driver->saveDir);
|
VIR_FREE(libxl_driver->saveDir);
|
||||||
|
|
||||||
virDomainEventStateFree(libxl_driver->domainEventState);
|
virDomainEventStateFree(libxl_driver->domainEventState);
|
||||||
|
virSysinfoDefFree(libxl_driver->hostsysinfo);
|
||||||
|
|
||||||
libxlDriverUnlock(libxl_driver);
|
libxlDriverUnlock(libxl_driver);
|
||||||
virMutexDestroy(&libxl_driver->lock);
|
virMutexDestroy(&libxl_driver->lock);
|
||||||
@ -1282,6 +1284,10 @@ libxlStateInitialize(bool privileged,
|
|||||||
}
|
}
|
||||||
VIR_FREE(log_file);
|
VIR_FREE(log_file);
|
||||||
|
|
||||||
|
/* read the host sysinfo */
|
||||||
|
if (privileged)
|
||||||
|
libxl_driver->hostsysinfo = virSysinfoRead();
|
||||||
|
|
||||||
libxl_driver->domainEventState = virDomainEventStateNew();
|
libxl_driver->domainEventState = virDomainEventStateNew();
|
||||||
if (!libxl_driver->domainEventState)
|
if (!libxl_driver->domainEventState)
|
||||||
goto error;
|
goto error;
|
||||||
@ -1475,6 +1481,28 @@ static char *libxlConnectGetHostname(virConnectPtr conn ATTRIBUTE_UNUSED)
|
|||||||
return virGetHostname();
|
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
|
static int
|
||||||
libxlConnectGetMaxVcpus(virConnectPtr conn, const char *type ATTRIBUTE_UNUSED)
|
libxlConnectGetMaxVcpus(virConnectPtr conn, const char *type ATTRIBUTE_UNUSED)
|
||||||
@ -4413,6 +4441,7 @@ static virDriver libxlDriver = {
|
|||||||
.connectGetType = libxlConnectGetType, /* 0.9.0 */
|
.connectGetType = libxlConnectGetType, /* 0.9.0 */
|
||||||
.connectGetVersion = libxlConnectGetVersion, /* 0.9.0 */
|
.connectGetVersion = libxlConnectGetVersion, /* 0.9.0 */
|
||||||
.connectGetHostname = libxlConnectGetHostname, /* 0.9.0 */
|
.connectGetHostname = libxlConnectGetHostname, /* 0.9.0 */
|
||||||
|
.connectGetSysinfo = libxlConnectGetSysinfo, /* 1.0.7 */
|
||||||
.connectGetMaxVcpus = libxlConnectGetMaxVcpus, /* 0.9.0 */
|
.connectGetMaxVcpus = libxlConnectGetMaxVcpus, /* 0.9.0 */
|
||||||
.nodeGetInfo = libxlNodeGetInfo, /* 0.9.0 */
|
.nodeGetInfo = libxlNodeGetInfo, /* 0.9.0 */
|
||||||
.connectGetCapabilities = libxlConnectGetCapabilities, /* 0.9.0 */
|
.connectGetCapabilities = libxlConnectGetCapabilities, /* 0.9.0 */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user