mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 14:57:42 +00:00
Replace use of nodeReportError with virReportError
Update the nodeinfo helper code to use virReportError instead of the nodeReportError custom macro Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
b8605b22e5
commit
47ab34e232
1
cfg.mk
1
cfg.mk
@ -509,7 +509,6 @@ msg_gen_function =
|
|||||||
msg_gen_function += VIR_ERROR
|
msg_gen_function += VIR_ERROR
|
||||||
msg_gen_function += VMX_ERROR
|
msg_gen_function += VMX_ERROR
|
||||||
msg_gen_function += lxcError
|
msg_gen_function += lxcError
|
||||||
msg_gen_function += nodeReportError
|
|
||||||
msg_gen_function += regerror
|
msg_gen_function += regerror
|
||||||
msg_gen_function += statsError
|
msg_gen_function += statsError
|
||||||
msg_gen_function += vah_error
|
msg_gen_function += vah_error
|
||||||
|
@ -52,10 +52,6 @@
|
|||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_NONE
|
#define VIR_FROM_THIS VIR_FROM_NONE
|
||||||
|
|
||||||
#define nodeReportError(code, ...) \
|
|
||||||
virReportErrorHelper(VIR_FROM_NONE, code, __FILE__, \
|
|
||||||
__FUNCTION__, __LINE__, __VA_ARGS__)
|
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
# define CPUINFO_PATH "/proc/cpuinfo"
|
# define CPUINFO_PATH "/proc/cpuinfo"
|
||||||
# define SYSFS_SYSTEM_PATH "/sys/devices/system"
|
# define SYSFS_SYSTEM_PATH "/sys/devices/system"
|
||||||
@ -114,7 +110,7 @@ virNodeGetCpuValue(const char *dir, unsigned int cpu, const char *file,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
if (virStrToLong_i(value_str, &tmp, 10, &value) < 0) {
|
if (virStrToLong_i(value_str, &tmp, 10, &value) < 0) {
|
||||||
nodeReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("could not convert '%s' to an integer"),
|
_("could not convert '%s' to an integer"),
|
||||||
value_str);
|
value_str);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -275,7 +271,7 @@ virNodeParseNode(const char *node, int *sockets, int *cores, int *threads)
|
|||||||
/* Parse socket */
|
/* Parse socket */
|
||||||
sock = virNodeParseSocket(node, cpu);
|
sock = virNodeParseSocket(node, cpu);
|
||||||
if (!CPU_ISSET(sock, &sock_map)) {
|
if (!CPU_ISSET(sock, &sock_map)) {
|
||||||
nodeReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("CPU socket topology has changed"));
|
_("CPU socket topology has changed"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -363,7 +359,7 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
|
|||||||
buf++;
|
buf++;
|
||||||
|
|
||||||
if (*buf != ':' || !buf[1]) {
|
if (*buf != ':' || !buf[1]) {
|
||||||
nodeReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("parsing cpu MHz from cpuinfo"));
|
_("parsing cpu MHz from cpuinfo"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -386,7 +382,7 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
|
|||||||
buf++;
|
buf++;
|
||||||
|
|
||||||
if (*buf != ':' || !buf[1]) {
|
if (*buf != ':' || !buf[1]) {
|
||||||
nodeReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("parsing cpu MHz from cpuinfo"));
|
_("parsing cpu MHz from cpuinfo"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -485,17 +481,17 @@ fallback:
|
|||||||
done:
|
done:
|
||||||
/* There should always be at least one cpu, socket, node, and thread. */
|
/* There should always be at least one cpu, socket, node, and thread. */
|
||||||
if (nodeinfo->cpus == 0) {
|
if (nodeinfo->cpus == 0) {
|
||||||
nodeReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no CPUs found"));
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no CPUs found"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodeinfo->sockets == 0) {
|
if (nodeinfo->sockets == 0) {
|
||||||
nodeReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no sockets found"));
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no sockets found"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodeinfo->threads == 0) {
|
if (nodeinfo->threads == 0) {
|
||||||
nodeReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no threads found"));
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no threads found"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -566,7 +562,7 @@ int linuxNodeGetCPUStats(FILE *procstat,
|
|||||||
switch (i) {
|
switch (i) {
|
||||||
case 0: /* fill kernel cpu time here */
|
case 0: /* fill kernel cpu time here */
|
||||||
if (virStrcpyStatic(param->field, VIR_NODE_CPU_STATS_KERNEL) == NULL) {
|
if (virStrcpyStatic(param->field, VIR_NODE_CPU_STATS_KERNEL) == NULL) {
|
||||||
nodeReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("Field kernel cpu time too long for destination"));
|
"%s", _("Field kernel cpu time too long for destination"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -575,7 +571,7 @@ int linuxNodeGetCPUStats(FILE *procstat,
|
|||||||
|
|
||||||
case 1: /* fill user cpu time here */
|
case 1: /* fill user cpu time here */
|
||||||
if (virStrcpyStatic(param->field, VIR_NODE_CPU_STATS_USER) == NULL) {
|
if (virStrcpyStatic(param->field, VIR_NODE_CPU_STATS_USER) == NULL) {
|
||||||
nodeReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("Field kernel cpu time too long for destination"));
|
"%s", _("Field kernel cpu time too long for destination"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -584,7 +580,7 @@ int linuxNodeGetCPUStats(FILE *procstat,
|
|||||||
|
|
||||||
case 2: /* fill idle cpu time here */
|
case 2: /* fill idle cpu time here */
|
||||||
if (virStrcpyStatic(param->field, VIR_NODE_CPU_STATS_IDLE) == NULL) {
|
if (virStrcpyStatic(param->field, VIR_NODE_CPU_STATS_IDLE) == NULL) {
|
||||||
nodeReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("Field kernel cpu time too long for destination"));
|
"%s", _("Field kernel cpu time too long for destination"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -593,7 +589,7 @@ int linuxNodeGetCPUStats(FILE *procstat,
|
|||||||
|
|
||||||
case 3: /* fill iowait cpu time here */
|
case 3: /* fill iowait cpu time here */
|
||||||
if (virStrcpyStatic(param->field, VIR_NODE_CPU_STATS_IOWAIT) == NULL) {
|
if (virStrcpyStatic(param->field, VIR_NODE_CPU_STATS_IOWAIT) == NULL) {
|
||||||
nodeReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("Field kernel cpu time too long for destination"));
|
"%s", _("Field kernel cpu time too long for destination"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -679,7 +675,7 @@ int linuxNodeGetMemoryStats(FILE *meminfo,
|
|||||||
for (i = 0; i < 2; i++) {
|
for (i = 0; i < 2; i++) {
|
||||||
p = strchr(p, ' ');
|
p = strchr(p, ' ');
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
nodeReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("no prefix found"));
|
"%s", _("no prefix found"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -698,7 +694,7 @@ int linuxNodeGetMemoryStats(FILE *meminfo,
|
|||||||
virNodeMemoryStatsPtr param = ¶ms[k++];
|
virNodeMemoryStatsPtr param = ¶ms[k++];
|
||||||
|
|
||||||
if (virStrcpyStatic(param->field, convp->field) == NULL) {
|
if (virStrcpyStatic(param->field, convp->field) == NULL) {
|
||||||
nodeReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("Field kernel memory too long for destination"));
|
"%s", _("Field kernel memory too long for destination"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -712,7 +708,7 @@ int linuxNodeGetMemoryStats(FILE *meminfo,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (found == 0) {
|
if (found == 0) {
|
||||||
nodeReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("no available memory line found"));
|
"%s", _("no available memory line found"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -798,7 +794,7 @@ cleanup:
|
|||||||
}
|
}
|
||||||
#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(VIR_ERR_NO_SUPPORT, "%s",
|
virReportError(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
|
||||||
@ -827,7 +823,7 @@ int nodeGetCPUStats(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
nodeReportError(VIR_ERR_NO_SUPPORT, "%s",
|
virReportError(VIR_ERR_NO_SUPPORT, "%s",
|
||||||
_("node CPU stats not implemented on this platform"));
|
_("node CPU stats not implemented on this platform"));
|
||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
@ -857,7 +853,7 @@ int nodeGetMemoryStats(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
# if HAVE_NUMACTL
|
# if HAVE_NUMACTL
|
||||||
if (numa_available() < 0) {
|
if (numa_available() < 0) {
|
||||||
# endif
|
# endif
|
||||||
nodeReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("NUMA not supported on this host"));
|
"%s", _("NUMA not supported on this host"));
|
||||||
return -1;
|
return -1;
|
||||||
# if HAVE_NUMACTL
|
# if HAVE_NUMACTL
|
||||||
@ -894,7 +890,7 @@ int nodeGetMemoryStats(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
nodeReportError(VIR_ERR_NO_SUPPORT, "%s",
|
virReportError(VIR_ERR_NO_SUPPORT, "%s",
|
||||||
_("node memory stats not implemented on this platform"));
|
_("node memory stats not implemented on this platform"));
|
||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
@ -918,7 +914,7 @@ nodeGetCPUmap(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
VIR_FREE(path);
|
VIR_FREE(path);
|
||||||
return cpumap;
|
return cpumap;
|
||||||
#else
|
#else
|
||||||
nodeReportError(VIR_ERR_NO_SUPPORT, "%s",
|
virReportError(VIR_ERR_NO_SUPPORT, "%s",
|
||||||
_("node cpumap not implemented on this platform"));
|
_("node cpumap not implemented on this platform"));
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
#endif
|
||||||
@ -1012,13 +1008,13 @@ nodeGetCellsFreeMemory(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
int maxCell;
|
int maxCell;
|
||||||
|
|
||||||
if (numa_available() < 0) {
|
if (numa_available() < 0) {
|
||||||
nodeReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%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(VIR_ERR_INTERNAL_ERROR,
|
virReportError(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;
|
||||||
@ -1030,7 +1026,7 @@ nodeGetCellsFreeMemory(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
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(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Failed to query NUMA free memory for node: %d"),
|
_("Failed to query NUMA free memory for node: %d"),
|
||||||
n);
|
n);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1050,7 +1046,7 @@ nodeGetFreeMemory(virConnectPtr conn ATTRIBUTE_UNUSED)
|
|||||||
int n;
|
int n;
|
||||||
|
|
||||||
if (numa_available() < 0) {
|
if (numa_available() < 0) {
|
||||||
nodeReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("NUMA not supported on this host"));
|
"%s", _("NUMA not supported on this host"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -1058,7 +1054,7 @@ nodeGetFreeMemory(virConnectPtr conn ATTRIBUTE_UNUSED)
|
|||||||
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(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"%s", _("Failed to query NUMA free memory"));
|
"%s", _("Failed to query NUMA free memory"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -1079,14 +1075,14 @@ int nodeGetCellsFreeMemory(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
int startCell ATTRIBUTE_UNUSED,
|
int startCell ATTRIBUTE_UNUSED,
|
||||||
int maxCells ATTRIBUTE_UNUSED)
|
int maxCells ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
nodeReportError(VIR_ERR_NO_SUPPORT, "%s",
|
virReportError(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 ATTRIBUTE_UNUSED)
|
unsigned long long nodeGetFreeMemory(virConnectPtr conn ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
nodeReportError(VIR_ERR_NO_SUPPORT, "%s",
|
virReportError(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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user