mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
Remove virConnectPtr from nodeReportError
This commit is contained in:
parent
8bd8bcaca8
commit
6c175fa3d1
@ -51,8 +51,8 @@
|
|||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_NONE
|
#define VIR_FROM_THIS VIR_FROM_NONE
|
||||||
|
|
||||||
#define nodeReportError(conn, code, ...) \
|
#define nodeReportError(code, ...) \
|
||||||
virReportErrorHelper(conn, VIR_FROM_NONE, code, __FILE__, \
|
virReportErrorHelper(NULL, VIR_FROM_NONE, code, __FILE__, \
|
||||||
__FUNCTION__, __LINE__, __VA_ARGS__)
|
__FUNCTION__, __LINE__, __VA_ARGS__)
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
@ -60,7 +60,7 @@
|
|||||||
# define CPU_SYS_PATH "/sys/devices/system/cpu"
|
# define CPU_SYS_PATH "/sys/devices/system/cpu"
|
||||||
|
|
||||||
/* NB, this is not static as we need to call it from the testsuite */
|
/* NB, this is not static as we need to call it from the testsuite */
|
||||||
int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
|
int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
|
||||||
virNodeInfoPtr nodeinfo);
|
virNodeInfoPtr nodeinfo);
|
||||||
|
|
||||||
static unsigned long count_thread_siblings(unsigned int cpu)
|
static unsigned long count_thread_siblings(unsigned int cpu)
|
||||||
@ -133,7 +133,7 @@ static int parse_socket(unsigned int cpu)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (virStrToLong_i(socket_str, &tmp, 10, &socket) < 0) {
|
if (virStrToLong_i(socket_str, &tmp, 10, &socket) < 0) {
|
||||||
nodeReportError(NULL, VIR_ERR_INTERNAL_ERROR,
|
nodeReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("could not convert '%s' to an integer"),
|
_("could not convert '%s' to an integer"),
|
||||||
socket_str);
|
socket_str);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -146,7 +146,7 @@ cleanup:
|
|||||||
return socket;
|
return socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
|
int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
|
||||||
virNodeInfoPtr nodeinfo)
|
virNodeInfoPtr nodeinfo)
|
||||||
{
|
{
|
||||||
char line[1024];
|
char line[1024];
|
||||||
@ -178,7 +178,7 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
|
|||||||
while (*buf && c_isspace(*buf))
|
while (*buf && c_isspace(*buf))
|
||||||
buf++;
|
buf++;
|
||||||
if (*buf != ':') {
|
if (*buf != ':') {
|
||||||
nodeReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
nodeReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("parsing cpuinfo processor"));
|
"%s", _("parsing cpuinfo processor"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -190,7 +190,7 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
|
|||||||
while (*buf && c_isspace(*buf))
|
while (*buf && c_isspace(*buf))
|
||||||
buf++;
|
buf++;
|
||||||
if (*buf != ':' || !buf[1]) {
|
if (*buf != ':' || !buf[1]) {
|
||||||
nodeReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
nodeReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("parsing cpuinfo cpu MHz"));
|
"%s", _("parsing cpuinfo cpu MHz"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -205,7 +205,7 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
|
|||||||
while (*buf && c_isspace(*buf))
|
while (*buf && c_isspace(*buf))
|
||||||
buf++;
|
buf++;
|
||||||
if (*buf != ':' || !buf[1]) {
|
if (*buf != ':' || !buf[1]) {
|
||||||
nodeReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
nodeReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"parsing cpuinfo cpu cores %c", *buf);
|
"parsing cpuinfo cpu cores %c", *buf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -217,7 +217,7 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!nodeinfo->cpus) {
|
if (!nodeinfo->cpus) {
|
||||||
nodeReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
nodeReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("no cpus found"));
|
"%s", _("no cpus found"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -257,12 +257,12 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
|
|||||||
|
|
||||||
/* there should always be at least one socket and one thread */
|
/* there should always be at least one socket and one thread */
|
||||||
if (nodeinfo->sockets == 0) {
|
if (nodeinfo->sockets == 0) {
|
||||||
nodeReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
nodeReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("no sockets found"));
|
"%s", _("no sockets found"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (nodeinfo->threads == 0) {
|
if (nodeinfo->threads == 0) {
|
||||||
nodeReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
nodeReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("no threads found"));
|
"%s", _("no threads found"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -272,8 +272,7 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo,
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int nodeGetInfo(virConnectPtr conn,
|
int nodeGetInfo(virConnectPtr conn ATTRIBUTE_UNUSED, virNodeInfoPtr nodeinfo) {
|
||||||
virNodeInfoPtr nodeinfo) {
|
|
||||||
memset(nodeinfo, 0, sizeof(*nodeinfo));
|
memset(nodeinfo, 0, sizeof(*nodeinfo));
|
||||||
|
|
||||||
#ifdef HAVE_UNAME
|
#ifdef HAVE_UNAME
|
||||||
@ -296,7 +295,7 @@ int nodeGetInfo(virConnectPtr conn,
|
|||||||
_("cannot open %s"), CPUINFO_PATH);
|
_("cannot open %s"), CPUINFO_PATH);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ret = linuxNodeInfoCPUPopulate(conn, cpuinfo, nodeinfo);
|
ret = linuxNodeInfoCPUPopulate(cpuinfo, nodeinfo);
|
||||||
fclose(cpuinfo);
|
fclose(cpuinfo);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -308,7 +307,7 @@ int nodeGetInfo(virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* XXX Solaris will need an impl later if they port QEMU driver */
|
/* XXX Solaris will need an impl later if they port QEMU driver */
|
||||||
nodeReportError(conn, VIR_ERR_NO_SUPPORT, "%s",
|
nodeReportError(VIR_ERR_NO_SUPPORT, "%s",
|
||||||
_("node info not implemented on this platform"));
|
_("node info not implemented on this platform"));
|
||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
@ -380,7 +379,7 @@ cleanup:
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
nodeGetCellsFreeMemory(virConnectPtr conn,
|
nodeGetCellsFreeMemory(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||||
unsigned long long *freeMems,
|
unsigned long long *freeMems,
|
||||||
int startCell,
|
int startCell,
|
||||||
int maxCells)
|
int maxCells)
|
||||||
@ -390,13 +389,13 @@ nodeGetCellsFreeMemory(virConnectPtr conn,
|
|||||||
int maxCell;
|
int maxCell;
|
||||||
|
|
||||||
if (numa_available() < 0) {
|
if (numa_available() < 0) {
|
||||||
nodeReportError(conn, VIR_ERR_NO_SUPPORT,
|
nodeReportError(VIR_ERR_NO_SUPPORT,
|
||||||
"%s", _("NUMA not supported on this host"));
|
"%s", _("NUMA not supported on this host"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
maxCell = numa_max_node();
|
maxCell = numa_max_node();
|
||||||
if (startCell > maxCell) {
|
if (startCell > maxCell) {
|
||||||
nodeReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
nodeReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("start cell %d out of range (0-%d)"),
|
_("start cell %d out of range (0-%d)"),
|
||||||
startCell, maxCell);
|
startCell, maxCell);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -408,7 +407,7 @@ nodeGetCellsFreeMemory(virConnectPtr conn,
|
|||||||
for (numCells = 0, n = startCell ; n <= lastCell ; n++) {
|
for (numCells = 0, n = startCell ; n <= lastCell ; n++) {
|
||||||
long long mem;
|
long long mem;
|
||||||
if (numa_node_size64(n, &mem) < 0) {
|
if (numa_node_size64(n, &mem) < 0) {
|
||||||
nodeReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
nodeReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("Failed to query NUMA free memory"));
|
"%s", _("Failed to query NUMA free memory"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -421,13 +420,13 @@ cleanup:
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned long long
|
unsigned long long
|
||||||
nodeGetFreeMemory(virConnectPtr conn)
|
nodeGetFreeMemory(virConnectPtr conn ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
unsigned long long freeMem = 0;
|
unsigned long long freeMem = 0;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
if (numa_available() < 0) {
|
if (numa_available() < 0) {
|
||||||
nodeReportError(conn, VIR_ERR_NO_SUPPORT,
|
nodeReportError(VIR_ERR_NO_SUPPORT,
|
||||||
"%s", _("NUMA not supported on this host"));
|
"%s", _("NUMA not supported on this host"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -435,7 +434,7 @@ nodeGetFreeMemory(virConnectPtr conn)
|
|||||||
for (n = 0 ; n <= numa_max_node() ; n++) {
|
for (n = 0 ; n <= numa_max_node() ; n++) {
|
||||||
long long mem;
|
long long mem;
|
||||||
if (numa_node_size64(n, &mem) < 0) {
|
if (numa_node_size64(n, &mem) < 0) {
|
||||||
nodeReportError(conn, VIR_ERR_INTERNAL_ERROR,
|
nodeReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("Failed to query NUMA free memory"));
|
"%s", _("Failed to query NUMA free memory"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -456,14 +455,14 @@ int nodeGetCellsFreeMemory(virConnectPtr conn,
|
|||||||
int startCell ATTRIBUTE_UNUSED,
|
int startCell ATTRIBUTE_UNUSED,
|
||||||
int maxCells ATTRIBUTE_UNUSED)
|
int maxCells ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
nodeReportError(conn, VIR_ERR_NO_SUPPORT, "%s",
|
nodeReportError(VIR_ERR_NO_SUPPORT, "%s",
|
||||||
_("NUMA memory information not available on this platform"));
|
_("NUMA memory information not available on this platform"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long long nodeGetFreeMemory(virConnectPtr conn)
|
unsigned long long nodeGetFreeMemory(virConnectPtr conn)
|
||||||
{
|
{
|
||||||
nodeReportError(conn, VIR_ERR_NO_SUPPORT, "%s",
|
nodeReportError(VIR_ERR_NO_SUPPORT, "%s",
|
||||||
_("NUMA memory information not available on this platform"));
|
_("NUMA memory information not available on this platform"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ static char *abs_srcdir;
|
|||||||
|
|
||||||
# define MAX_FILE 4096
|
# define MAX_FILE 4096
|
||||||
|
|
||||||
extern int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr nodeinfo);
|
extern int linuxNodeInfoCPUPopulate(FILE *cpuinfo, virNodeInfoPtr nodeinfo);
|
||||||
|
|
||||||
static int linuxTestCompareFiles(const char *cpuinfofile, const char *outputfile) {
|
static int linuxTestCompareFiles(const char *cpuinfofile, const char *outputfile) {
|
||||||
char actualData[MAX_FILE];
|
char actualData[MAX_FILE];
|
||||||
@ -40,7 +40,7 @@ static int linuxTestCompareFiles(const char *cpuinfofile, const char *outputfile
|
|||||||
cpuinfo = fopen(cpuinfofile, "r");
|
cpuinfo = fopen(cpuinfofile, "r");
|
||||||
if (!cpuinfo)
|
if (!cpuinfo)
|
||||||
return -1;
|
return -1;
|
||||||
if (linuxNodeInfoCPUPopulate(NULL, cpuinfo, &nodeinfo) < 0) {
|
if (linuxNodeInfoCPUPopulate(cpuinfo, &nodeinfo) < 0) {
|
||||||
fclose(cpuinfo);
|
fclose(cpuinfo);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user