[libvirt] [PATCH 0/4] Couple of nodeinfo enhancements

Look at the patches :P Michal Privoznik (4): nodeinfo: Introduce @arch to linuxNodeInfoCPUPopulate virNodeParseNode: Propagate host architecture nodeinfotest: Print error if cpuinfo file can't be opened virNodeParseSocket: Take ARM into account cfg.mk | 2 +- src/nodeinfo.c | 199 +++++++++++---------- src/nodeinfopriv.h | 1 + .../nodeinfodata/linux-armv6l-raspberrypi.cpuinfo | 12 ++ .../nodeinfodata/linux-armv6l-raspberrypi.expected | 1 + .../linux-raspberrypi/cpu/cpu0/topology/core_id | 1 + .../cpu/cpu0/topology/core_siblings | 1 + .../cpu/cpu0/topology/core_siblings_list | 1 + .../cpu/cpu0/topology/physical_package_id | 1 + .../cpu/cpu0/topology/thread_siblings | 1 + .../cpu/cpu0/topology/thread_siblings_list | 1 + .../linux-raspberrypi/cpu/cpuidle/current_driver | 1 + .../cpu/cpuidle/current_governor_ro | 1 + .../nodeinfodata/linux-raspberrypi/cpu/kernel_max | 1 + tests/nodeinfodata/linux-raspberrypi/cpu/offline | 1 + tests/nodeinfodata/linux-raspberrypi/cpu/online | 1 + tests/nodeinfodata/linux-raspberrypi/cpu/possible | 1 + tests/nodeinfodata/linux-raspberrypi/cpu/present | 1 + ...86-test1.cpuinfo => linux-x86_64-test1.cpuinfo} | 0 ...-test1.expected => linux-x86_64-test1.expected} | 0 ...86-test2.cpuinfo => linux-x86_64-test2.cpuinfo} | 0 ...-test2.expected => linux-x86_64-test2.expected} | 0 ...86-test3.cpuinfo => linux-x86_64-test3.cpuinfo} | 0 ...-test3.expected => linux-x86_64-test3.expected} | 0 ...86-test4.cpuinfo => linux-x86_64-test4.cpuinfo} | 0 ...-test4.expected => linux-x86_64-test4.expected} | 0 ...86-test5.cpuinfo => linux-x86_64-test5.cpuinfo} | 0 ...-test5.expected => linux-x86_64-test5.expected} | 0 ...86-test6.cpuinfo => linux-x86_64-test6.cpuinfo} | 0 ...-test6.expected => linux-x86_64-test6.expected} | 0 ...86-test7.cpuinfo => linux-x86_64-test7.cpuinfo} | 0 ...-test7.expected => linux-x86_64-test7.expected} | 0 ...86-test8.cpuinfo => linux-x86_64-test8.cpuinfo} | 0 ...-test8.expected => linux-x86_64-test8.expected} | 0 tests/nodeinfotest.c | 63 ++++--- 35 files changed, 164 insertions(+), 127 deletions(-) create mode 100644 tests/nodeinfodata/linux-armv6l-raspberrypi.cpuinfo create mode 100644 tests/nodeinfodata/linux-armv6l-raspberrypi.expected create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/core_id create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/core_siblings create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/core_siblings_list create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/physical_package_id create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/thread_siblings create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/thread_siblings_list create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpuidle/current_driver create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpuidle/current_governor_ro create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/kernel_max create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/offline create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/online create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/possible create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/present rename tests/nodeinfodata/{linux-x86-test1.cpuinfo => linux-x86_64-test1.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test1.expected => linux-x86_64-test1.expected} (100%) rename tests/nodeinfodata/{linux-x86-test2.cpuinfo => linux-x86_64-test2.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test2.expected => linux-x86_64-test2.expected} (100%) rename tests/nodeinfodata/{linux-x86-test3.cpuinfo => linux-x86_64-test3.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test3.expected => linux-x86_64-test3.expected} (100%) rename tests/nodeinfodata/{linux-x86-test4.cpuinfo => linux-x86_64-test4.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test4.expected => linux-x86_64-test4.expected} (100%) rename tests/nodeinfodata/{linux-x86-test5.cpuinfo => linux-x86_64-test5.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test5.expected => linux-x86_64-test5.expected} (100%) rename tests/nodeinfodata/{linux-x86-test6.cpuinfo => linux-x86_64-test6.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test6.expected => linux-x86_64-test6.expected} (100%) rename tests/nodeinfodata/{linux-x86-test7.cpuinfo => linux-x86_64-test7.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test7.expected => linux-x86_64-test7.expected} (100%) rename tests/nodeinfodata/{linux-x86-test8.cpuinfo => linux-x86_64-test8.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test8.expected => linux-x86_64-test8.expected} (100%) -- 1.8.5.5

So far, we are doing compile time decisions on which architecture is used. However, for testing purposes it's much easier if we pass host architecture as parameter and then let the function decide which code snippet for extracting host CPU info will be used. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/nodeinfo.c | 141 +++++++++++---------- src/nodeinfopriv.h | 1 + ...86-test1.cpuinfo => linux-x86_64-test1.cpuinfo} | 0 ...-test1.expected => linux-x86_64-test1.expected} | 0 ...86-test2.cpuinfo => linux-x86_64-test2.cpuinfo} | 0 ...-test2.expected => linux-x86_64-test2.expected} | 0 ...86-test3.cpuinfo => linux-x86_64-test3.cpuinfo} | 0 ...-test3.expected => linux-x86_64-test3.expected} | 0 ...86-test4.cpuinfo => linux-x86_64-test4.cpuinfo} | 0 ...-test4.expected => linux-x86_64-test4.expected} | 0 ...86-test5.cpuinfo => linux-x86_64-test5.cpuinfo} | 0 ...-test5.expected => linux-x86_64-test5.expected} | 0 ...86-test6.cpuinfo => linux-x86_64-test6.cpuinfo} | 0 ...-test6.expected => linux-x86_64-test6.expected} | 0 ...86-test7.cpuinfo => linux-x86_64-test7.cpuinfo} | 0 ...-test7.expected => linux-x86_64-test7.expected} | 0 ...86-test8.cpuinfo => linux-x86_64-test8.cpuinfo} | 0 ...-test8.expected => linux-x86_64-test8.expected} | 0 tests/nodeinfotest.c | 57 ++++----- 19 files changed, 100 insertions(+), 99 deletions(-) rename tests/nodeinfodata/{linux-x86-test1.cpuinfo => linux-x86_64-test1.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test1.expected => linux-x86_64-test1.expected} (100%) rename tests/nodeinfodata/{linux-x86-test2.cpuinfo => linux-x86_64-test2.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test2.expected => linux-x86_64-test2.expected} (100%) rename tests/nodeinfodata/{linux-x86-test3.cpuinfo => linux-x86_64-test3.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test3.expected => linux-x86_64-test3.expected} (100%) rename tests/nodeinfodata/{linux-x86-test4.cpuinfo => linux-x86_64-test4.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test4.expected => linux-x86_64-test4.expected} (100%) rename tests/nodeinfodata/{linux-x86-test5.cpuinfo => linux-x86_64-test5.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test5.expected => linux-x86_64-test5.expected} (100%) rename tests/nodeinfodata/{linux-x86-test6.cpuinfo => linux-x86_64-test6.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test6.expected => linux-x86_64-test6.expected} (100%) rename tests/nodeinfodata/{linux-x86-test7.cpuinfo => linux-x86_64-test7.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test7.expected => linux-x86_64-test7.expected} (100%) rename tests/nodeinfodata/{linux-x86-test8.cpuinfo => linux-x86_64-test8.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test8.expected => linux-x86_64-test8.expected} (100%) diff --git a/src/nodeinfo.c b/src/nodeinfo.c index 5332ede..19164d9 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -52,9 +52,12 @@ #include "virtypedparam.h" #include "virstring.h" #include "virnuma.h" +#include "virlog.h" #define VIR_FROM_THIS VIR_FROM_NONE +VIR_LOG_INIT("nodeinfo"); + #if defined(__FreeBSD__) || defined(__APPLE__) static int appleFreebsdNodeGetCPUCount(void) @@ -557,6 +560,7 @@ virNodeParseNode(const char *node, int linuxNodeInfoCPUPopulate(FILE *cpuinfo, const char *sysfs_dir, + virArch arch, virNodeInfoPtr nodeinfo) { char line[1024]; @@ -571,86 +575,86 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo, /* Start with parsing CPU clock speed from /proc/cpuinfo */ while (fgets(line, sizeof(line), cpuinfo) != NULL) { -# if defined(__x86_64__) || \ - defined(__amd64__) || \ - defined(__i386__) - char *buf = line; - if (STRPREFIX(buf, "cpu MHz")) { - char *p; - unsigned int ui; + if (arch == VIR_ARCH_X86_64 || arch == VIR_ARCH_I686) { + char *buf = line; + if (STRPREFIX(buf, "cpu MHz")) { + char *p; + unsigned int ui; - buf += 7; - while (*buf && c_isspace(*buf)) - buf++; + buf += 7; + while (*buf && c_isspace(*buf)) + buf++; - if (*buf != ':' || !buf[1]) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("parsing cpu MHz from cpuinfo")); - goto cleanup; + if (*buf != ':' || !buf[1]) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("parsing cpu MHz from cpuinfo")); + goto cleanup; + } + + if (virStrToLong_ui(buf+1, &p, 10, &ui) == 0 && + /* Accept trailing fractional part. */ + (*p == '\0' || *p == '.' || c_isspace(*p))) + nodeinfo->mhz = ui; } - if (virStrToLong_ui(buf+1, &p, 10, &ui) == 0 && - /* Accept trailing fractional part. */ - (*p == '\0' || *p == '.' || c_isspace(*p))) - nodeinfo->mhz = ui; - } + } else if (arch == VIR_ARCH_PPC || arch == VIR_ARCH_PPCLE || + arch == VIR_ARCH_PPC64 || arch == VIR_ARCH_PPC64LE || + arch == VIR_ARCH_PPCEMB) { + char *buf = line; + if (STRPREFIX(buf, "clock")) { + char *p; + unsigned int ui; -# elif defined(__powerpc__) || \ - defined(__powerpc64__) - char *buf = line; - if (STRPREFIX(buf, "clock")) { - char *p; - unsigned int ui; + buf += 5; + while (*buf && c_isspace(*buf)) + buf++; - buf += 5; - while (*buf && c_isspace(*buf)) - buf++; + if (*buf != ':' || !buf[1]) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("parsing cpu MHz from cpuinfo")); + goto cleanup; + } - if (*buf != ':' || !buf[1]) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("parsing cpu MHz from cpuinfo")); - goto cleanup; + if (virStrToLong_ui(buf+1, &p, 10, &ui) == 0 && + /* Accept trailing fractional part. */ + (*p == '\0' || *p == '.' || c_isspace(*p))) + nodeinfo->mhz = ui; + /* No other interesting infos are available in /proc/cpuinfo. + * However, there is a line identifying processor's version, + * identification and machine, but we don't want it to be caught + * and parsed in next iteration, because it is not in expected + * format and thus lead to error. */ } + } else if (arch == VIR_ARCH_ARMV6L || arch == VIR_ARCH_ARMV7L || + arch == VIR_ARCH_ARMV7B || arch == VIR_ARCH_AARCH64) { + char *buf = line; + if (STRPREFIX(buf, "BogoMIPS")) { + char *p; + unsigned int ui; - if (virStrToLong_ui(buf+1, &p, 10, &ui) == 0 && - /* Accept trailing fractional part. */ - (*p == '\0' || *p == '.' || c_isspace(*p))) - nodeinfo->mhz = ui; - /* No other interesting infos are available in /proc/cpuinfo. - * However, there is a line identifying processor's version, - * identification and machine, but we don't want it to be caught - * and parsed in next iteration, because it is not in expected - * format and thus lead to error. */ - } -# elif defined(__arm__) || defined(__aarch64__) - char *buf = line; - if (STRPREFIX(buf, "BogoMIPS")) { - char *p; - unsigned int ui; + buf += 8; + while (*buf && c_isspace(*buf)) + buf++; - buf += 8; - while (*buf && c_isspace(*buf)) - buf++; + if (*buf != ':' || !buf[1]) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("parsing cpu MHz from cpuinfo")); + goto cleanup; + } - if (*buf != ':' || !buf[1]) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("parsing cpu MHz from cpuinfo")); - goto cleanup; + if (virStrToLong_ui(buf+1, &p, 10, &ui) == 0 + /* Accept trailing fractional part. */ + && (*p == '\0' || *p == '.' || c_isspace(*p))) + nodeinfo->mhz = ui; } - - if (virStrToLong_ui(buf+1, &p, 10, &ui) == 0 - /* Accept trailing fractional part. */ - && (*p == '\0' || *p == '.' || c_isspace(*p))) - nodeinfo->mhz = ui; + } else if (arch == VIR_ARCH_S390 || arch == VIR_ARCH_S390X) { + /* s390x has no realistic value for CPU speed, + * assign a value of zero to signify this */ + nodeinfo->mhz = 0; + } else { + VIR_WARN("Parser for /proc/cpuinfo needs to be adapted for your architecture"); + break; } -# elif defined(__s390__) || \ - defined(__s390x__) - /* s390x has no realistic value for CPU speed, - * assign a value of zero to signify this */ - nodeinfo->mhz = 0; -# else -# warning Parser for /proc/cpuinfo needs to be adapted for your architecture -# endif } /* OK, we've parsed clock speed out of /proc/cpuinfo. Get the @@ -1057,7 +1061,8 @@ int nodeGetInfo(virNodeInfoPtr nodeinfo) return -1; } - ret = linuxNodeInfoCPUPopulate(cpuinfo, SYSFS_SYSTEM_PATH, nodeinfo); + ret = linuxNodeInfoCPUPopulate(cpuinfo, SYSFS_SYSTEM_PATH, + hostarch, nodeinfo); if (ret < 0) goto cleanup; diff --git a/src/nodeinfopriv.h b/src/nodeinfopriv.h index 6692363..8bfbe1e 100644 --- a/src/nodeinfopriv.h +++ b/src/nodeinfopriv.h @@ -27,6 +27,7 @@ # ifdef __linux__ int linuxNodeInfoCPUPopulate(FILE *cpuinfo, const char *sysfs_dir, + virArch arch, virNodeInfoPtr nodeinfo); int linuxNodeGetCPUStats(FILE *procstat, diff --git a/tests/nodeinfodata/linux-x86-test1.cpuinfo b/tests/nodeinfodata/linux-x86_64-test1.cpuinfo similarity index 100% rename from tests/nodeinfodata/linux-x86-test1.cpuinfo rename to tests/nodeinfodata/linux-x86_64-test1.cpuinfo diff --git a/tests/nodeinfodata/linux-x86-test1.expected b/tests/nodeinfodata/linux-x86_64-test1.expected similarity index 100% rename from tests/nodeinfodata/linux-x86-test1.expected rename to tests/nodeinfodata/linux-x86_64-test1.expected diff --git a/tests/nodeinfodata/linux-x86-test2.cpuinfo b/tests/nodeinfodata/linux-x86_64-test2.cpuinfo similarity index 100% rename from tests/nodeinfodata/linux-x86-test2.cpuinfo rename to tests/nodeinfodata/linux-x86_64-test2.cpuinfo diff --git a/tests/nodeinfodata/linux-x86-test2.expected b/tests/nodeinfodata/linux-x86_64-test2.expected similarity index 100% rename from tests/nodeinfodata/linux-x86-test2.expected rename to tests/nodeinfodata/linux-x86_64-test2.expected diff --git a/tests/nodeinfodata/linux-x86-test3.cpuinfo b/tests/nodeinfodata/linux-x86_64-test3.cpuinfo similarity index 100% rename from tests/nodeinfodata/linux-x86-test3.cpuinfo rename to tests/nodeinfodata/linux-x86_64-test3.cpuinfo diff --git a/tests/nodeinfodata/linux-x86-test3.expected b/tests/nodeinfodata/linux-x86_64-test3.expected similarity index 100% rename from tests/nodeinfodata/linux-x86-test3.expected rename to tests/nodeinfodata/linux-x86_64-test3.expected diff --git a/tests/nodeinfodata/linux-x86-test4.cpuinfo b/tests/nodeinfodata/linux-x86_64-test4.cpuinfo similarity index 100% rename from tests/nodeinfodata/linux-x86-test4.cpuinfo rename to tests/nodeinfodata/linux-x86_64-test4.cpuinfo diff --git a/tests/nodeinfodata/linux-x86-test4.expected b/tests/nodeinfodata/linux-x86_64-test4.expected similarity index 100% rename from tests/nodeinfodata/linux-x86-test4.expected rename to tests/nodeinfodata/linux-x86_64-test4.expected diff --git a/tests/nodeinfodata/linux-x86-test5.cpuinfo b/tests/nodeinfodata/linux-x86_64-test5.cpuinfo similarity index 100% rename from tests/nodeinfodata/linux-x86-test5.cpuinfo rename to tests/nodeinfodata/linux-x86_64-test5.cpuinfo diff --git a/tests/nodeinfodata/linux-x86-test5.expected b/tests/nodeinfodata/linux-x86_64-test5.expected similarity index 100% rename from tests/nodeinfodata/linux-x86-test5.expected rename to tests/nodeinfodata/linux-x86_64-test5.expected diff --git a/tests/nodeinfodata/linux-x86-test6.cpuinfo b/tests/nodeinfodata/linux-x86_64-test6.cpuinfo similarity index 100% rename from tests/nodeinfodata/linux-x86-test6.cpuinfo rename to tests/nodeinfodata/linux-x86_64-test6.cpuinfo diff --git a/tests/nodeinfodata/linux-x86-test6.expected b/tests/nodeinfodata/linux-x86_64-test6.expected similarity index 100% rename from tests/nodeinfodata/linux-x86-test6.expected rename to tests/nodeinfodata/linux-x86_64-test6.expected diff --git a/tests/nodeinfodata/linux-x86-test7.cpuinfo b/tests/nodeinfodata/linux-x86_64-test7.cpuinfo similarity index 100% rename from tests/nodeinfodata/linux-x86-test7.cpuinfo rename to tests/nodeinfodata/linux-x86_64-test7.cpuinfo diff --git a/tests/nodeinfodata/linux-x86-test7.expected b/tests/nodeinfodata/linux-x86_64-test7.expected similarity index 100% rename from tests/nodeinfodata/linux-x86-test7.expected rename to tests/nodeinfodata/linux-x86_64-test7.expected diff --git a/tests/nodeinfodata/linux-x86-test8.cpuinfo b/tests/nodeinfodata/linux-x86_64-test8.cpuinfo similarity index 100% rename from tests/nodeinfodata/linux-x86-test8.cpuinfo rename to tests/nodeinfodata/linux-x86_64-test8.cpuinfo diff --git a/tests/nodeinfodata/linux-x86-test8.expected b/tests/nodeinfodata/linux-x86_64-test8.expected similarity index 100% rename from tests/nodeinfodata/linux-x86-test8.expected rename to tests/nodeinfodata/linux-x86_64-test8.expected diff --git a/tests/nodeinfotest.c b/tests/nodeinfotest.c index a00a0b7..f0b8196 100644 --- a/tests/nodeinfotest.c +++ b/tests/nodeinfotest.c @@ -13,11 +13,7 @@ #define VIR_FROM_THIS VIR_FROM_NONE -#if ! (defined __linux__ && (defined(__x86_64__) || \ - defined(__amd64__) || \ - defined(__i386__) || \ - defined(__powerpc__) || \ - defined(__powerpc64__))) +#if !(defined __linux__) int main(void) @@ -30,6 +26,7 @@ main(void) static int linuxTestCompareFiles(const char *cpuinfofile, char *sysfs_dir, + virArch arch, const char *outputfile) { int ret = -1; @@ -46,7 +43,7 @@ linuxTestCompareFiles(const char *cpuinfofile, goto fail; memset(&nodeinfo, 0, sizeof(nodeinfo)); - if (linuxNodeInfoCPUPopulate(cpuinfo, sysfs_dir, &nodeinfo) < 0) { + if (linuxNodeInfoCPUPopulate(cpuinfo, sysfs_dir, arch, &nodeinfo) < 0) { if (virTestGetDebug()) { virErrorPtr error = virSaveLastError(); if (error && error->code != VIR_ERR_OK) @@ -167,31 +164,31 @@ linuxCPUStatsCompareFiles(const char *cpustatfile, } +struct linuxTestNodeInfoData { + const char *testName; + virArch arch; +}; + static int -linuxTestNodeInfo(const void *data) +linuxTestNodeInfo(const void *opaque) { int result = -1; char *cpuinfo = NULL; char *sysfs_dir = NULL; char *output = NULL; - const char *test = data; - const char *arch = "x86"; - -# if defined(__powerpc__) || \ - defined(__powerpc64__) - arch = "ppc"; -# endif + struct linuxTestNodeInfoData *data = (struct linuxTestNodeInfoData *) opaque; + const char *archStr = virArchToString(data->arch); if (virAsprintf(&sysfs_dir, "%s/nodeinfodata/linux-%s", - abs_srcdir, test) < 0 || + abs_srcdir, data->testName) < 0 || virAsprintf(&cpuinfo, "%s/nodeinfodata/linux-%s-%s.cpuinfo", - abs_srcdir, arch, test) < 0 || + abs_srcdir, archStr, data->testName) < 0 || virAsprintf(&output, "%s/nodeinfodata/linux-%s-%s.expected", - abs_srcdir, arch, test) < 0) { + abs_srcdir, archStr, data->testName) < 0) { goto cleanup; } - result = linuxTestCompareFiles(cpuinfo, sysfs_dir, output); + result = linuxTestCompareFiles(cpuinfo, sysfs_dir, data->arch, output); cleanup: VIR_FREE(cpuinfo); @@ -235,25 +232,23 @@ mymain(void) { int ret = 0; size_t i; - const char *nodeData[] = { - "test1", -# if !(defined(__powerpc__) || \ - defined(__powerpc64__)) - "test2", - "test3", - "test4", - "test5", - "test6", - "test7", - "test8", -# endif + const struct linuxTestNodeInfoData nodeData[] = { + {"test1", VIR_ARCH_X86_64}, + {"test1", VIR_ARCH_PPC}, + {"test2", VIR_ARCH_X86_64}, + {"test3", VIR_ARCH_X86_64}, + {"test4", VIR_ARCH_X86_64}, + {"test5", VIR_ARCH_X86_64}, + {"test6", VIR_ARCH_X86_64}, + {"test7", VIR_ARCH_X86_64}, + {"test8", VIR_ARCH_X86_64}, }; if (virInitialize() < 0) return EXIT_FAILURE; for (i = 0; i < ARRAY_CARDINALITY(nodeData); i++) - if (virtTestRun(nodeData[i], linuxTestNodeInfo, nodeData[i]) != 0) + if (virtTestRun(nodeData[i].testName, linuxTestNodeInfo, &nodeData[i]) != 0) ret = -1; # define DO_TEST_CPU_STATS(name, ncpus) \ -- 1.8.5.5

As in previous commit, there are again some places where we can do runtime decision instead of compile time. This time it's whether the 'topology/physical_package_id' is allowed to have '-1' within or not. Then, core ID is pared differently on s390(x) than on the rest of architectures. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/nodeinfo.c | 56 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/src/nodeinfo.c b/src/nodeinfo.c index 19164d9..56690b8 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -389,19 +389,21 @@ virNodeCountThreadSiblings(const char *dir, unsigned int cpu) } static int -virNodeParseSocket(const char *dir, unsigned int cpu) +virNodeParseSocket(const char *dir, + virArch arch, + unsigned int cpu) { - int ret = virNodeGetCpuValue(dir, cpu, "topology/physical_package_id", - 0); -# if defined(__powerpc__) || \ - defined(__powerpc64__) || \ - defined(__s390__) || \ - defined(__s390x__) || \ - defined(__aarch64__) - /* ppc and s390(x) has -1 */ - if (ret < 0) - ret = 0; -# endif + int ret = virNodeGetCpuValue(dir, cpu, "topology/physical_package_id", 0); + + if (arch == VIR_ARCH_PPC || arch == VIR_ARCH_PPCLE || + arch == VIR_ARCH_PPC64 || arch == VIR_ARCH_PPC64LE || + arch == VIR_ARCH_PPCEMB || + arch == VIR_ARCH_S390 || arch == VIR_ARCH_S390X) { + /* ppc and s390(x) has -1 */ + if (ret < 0) + ret = 0; + } + return ret; } @@ -421,10 +423,11 @@ CPU_COUNT(cpu_set_t *set) /* parses a node entry, returning number of processors in the node and * filling arguments */ static int -ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) -ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4) -ATTRIBUTE_NONNULL(5) +ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3) +ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5) +ATTRIBUTE_NONNULL(6) virNodeParseNode(const char *node, + virArch arch, int *sockets, int *cores, int *threads, @@ -467,7 +470,7 @@ virNodeParseNode(const char *node, continue; /* Parse socket */ - if ((sock = virNodeParseSocket(node, cpu)) < 0) + if ((sock = virNodeParseSocket(node, arch, cpu)) < 0) goto cleanup; CPU_SET(sock, &sock_map); @@ -504,7 +507,7 @@ virNodeParseNode(const char *node, processors++; /* Parse socket */ - if ((sock = virNodeParseSocket(node, cpu)) < 0) + if ((sock = virNodeParseSocket(node, arch, cpu)) < 0) goto cleanup; if (!CPU_ISSET(sock, &sock_map)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -513,13 +516,12 @@ virNodeParseNode(const char *node, } /* Parse core */ -# if defined(__s390__) || \ - defined(__s390x__) - /* logical cpu is equivalent to a core on s390 */ - core = cpu; -# else - core = virNodeGetCpuValue(node, cpu, "topology/core_id", 0); -# endif + if (arch == VIR_ARCH_S390 || arch == VIR_ARCH_S390X) { + /* logical cpu is equivalent to a core on s390 */ + core = cpu; + } else { + core = virNodeGetCpuValue(node, cpu, "topology/core_id", 0); + } CPU_SET(core, &core_maps[sock]); @@ -678,7 +680,8 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo, sysfs_dir, nodedirent->d_name) < 0) goto cleanup; - if ((cpus = virNodeParseNode(sysfs_cpudir, &socks, &cores, + if ((cpus = virNodeParseNode(sysfs_cpudir, arch, + &socks, &cores, &threads, &offline)) < 0) goto cleanup; @@ -708,7 +711,8 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo, if (virAsprintf(&sysfs_cpudir, "%s/cpu", sysfs_dir) < 0) goto cleanup; - if ((cpus = virNodeParseNode(sysfs_cpudir, &socks, &cores, + if ((cpus = virNodeParseNode(sysfs_cpudir, arch, + &socks, &cores, &threads, &offline)) < 0) goto cleanup; -- 1.8.5.5

Currently, we are opening the cpuinfo file via fopen() which if fails doesn't print any error message. We should do that instead. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tests/nodeinfotest.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/nodeinfotest.c b/tests/nodeinfotest.c index f0b8196..650a674 100644 --- a/tests/nodeinfotest.c +++ b/tests/nodeinfotest.c @@ -39,8 +39,11 @@ linuxTestCompareFiles(const char *cpuinfofile, goto fail; cpuinfo = fopen(cpuinfofile, "r"); - if (!cpuinfo) + if (!cpuinfo) { + fprintf(stderr, "unable to open: %s : %s\n", + cpuinfofile, strerror(errno)); goto fail; + } memset(&nodeinfo, 0, sizeof(nodeinfo)); if (linuxNodeInfoCPUPopulate(cpuinfo, sysfs_dir, arch, &nodeinfo) < 0) { -- 1.8.5.5

From: Michal Privoznik <miso.privoznik@gmail.com> The virNodeParseSocket() function tries to get socked ID from 'topology/physical_package_id' file. However, on some architectures the file contains the -1 constant which makes in turn libvirt think the info extraction was unsuccessful. If that's the case, we need to overwrite the obtained integer with zero like we are doing for other architectures. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- cfg.mk | 2 +- src/nodeinfo.c | 6 ++++-- tests/nodeinfodata/linux-armv6l-raspberrypi.cpuinfo | 12 ++++++++++++ tests/nodeinfodata/linux-armv6l-raspberrypi.expected | 1 + .../nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/core_id | 1 + .../linux-raspberrypi/cpu/cpu0/topology/core_siblings | 1 + .../linux-raspberrypi/cpu/cpu0/topology/core_siblings_list | 1 + .../linux-raspberrypi/cpu/cpu0/topology/physical_package_id | 1 + .../linux-raspberrypi/cpu/cpu0/topology/thread_siblings | 1 + .../linux-raspberrypi/cpu/cpu0/topology/thread_siblings_list | 1 + .../linux-raspberrypi/cpu/cpuidle/current_driver | 1 + .../linux-raspberrypi/cpu/cpuidle/current_governor_ro | 1 + tests/nodeinfodata/linux-raspberrypi/cpu/kernel_max | 1 + tests/nodeinfodata/linux-raspberrypi/cpu/offline | 1 + tests/nodeinfodata/linux-raspberrypi/cpu/online | 1 + tests/nodeinfodata/linux-raspberrypi/cpu/possible | 1 + tests/nodeinfodata/linux-raspberrypi/cpu/present | 1 + tests/nodeinfotest.c | 1 + 18 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 tests/nodeinfodata/linux-armv6l-raspberrypi.cpuinfo create mode 100644 tests/nodeinfodata/linux-armv6l-raspberrypi.expected create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/core_id create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/core_siblings create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/core_siblings_list create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/physical_package_id create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/thread_siblings create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/thread_siblings_list create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpuidle/current_driver create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpuidle/current_governor_ro create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/kernel_max create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/offline create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/online create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/possible create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/present diff --git a/cfg.mk b/cfg.mk index 1f07639..77409a3 100644 --- a/cfg.mk +++ b/cfg.mk @@ -1124,4 +1124,4 @@ exclude_file_name_regexp--sc_prohibit_mixed_case_abbreviations = \ ^src/(vbox/vbox_CAPI.*.h|esx/esx_vi.(c|h)|esx/esx_storage_backend_iscsi.c)$$ exclude_file_name_regexp--sc_prohibit_empty_first_line = \ - ^(README|daemon/THREADS\.txt|src/esx/README|docs/library.xen|tests/vmwareverdata/fusion-5.0.3.txt)$$ + ^(README|daemon/THREADS\.txt|src/esx/README|docs/library.xen|tests/vmwareverdata/fusion-5.0.3.txt|tests/nodeinfodata/linux-raspberrypi/cpu/offline)$$ diff --git a/src/nodeinfo.c b/src/nodeinfo.c index 56690b8..4c96024 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -398,8 +398,10 @@ virNodeParseSocket(const char *dir, if (arch == VIR_ARCH_PPC || arch == VIR_ARCH_PPCLE || arch == VIR_ARCH_PPC64 || arch == VIR_ARCH_PPC64LE || arch == VIR_ARCH_PPCEMB || - arch == VIR_ARCH_S390 || arch == VIR_ARCH_S390X) { - /* ppc and s390(x) has -1 */ + arch == VIR_ARCH_S390 || arch == VIR_ARCH_S390X || + arch == VIR_ARCH_ARMV6L || arch == VIR_ARCH_ARMV7L || + arch == VIR_ARCH_ARMV7B || arch == VIR_ARCH_AARCH64) { + /* arm, ppc and s390(x) has -1 */ if (ret < 0) ret = 0; } diff --git a/tests/nodeinfodata/linux-armv6l-raspberrypi.cpuinfo b/tests/nodeinfodata/linux-armv6l-raspberrypi.cpuinfo new file mode 100644 index 0000000..8857da0 --- /dev/null +++ b/tests/nodeinfodata/linux-armv6l-raspberrypi.cpuinfo @@ -0,0 +1,12 @@ +Processor : ARMv6-compatible processor rev 7 (v6l) +BogoMIPS : 697.95 +Features : swp half thumb fastmult vfp edsp java tls +CPU implementer : 0x41 +CPU architecture: 7 +CPU variant : 0x0 +CPU part : 0xb76 +CPU revision : 7 + +Hardware : BCM2708 +Revision : 1000003 +Serial : 000000008fbfc895 diff --git a/tests/nodeinfodata/linux-armv6l-raspberrypi.expected b/tests/nodeinfodata/linux-armv6l-raspberrypi.expected new file mode 100644 index 0000000..146bd07 --- /dev/null +++ b/tests/nodeinfodata/linux-armv6l-raspberrypi.expected @@ -0,0 +1 @@ +CPUs: 1/1, MHz: 697, Nodes: 1, Sockets: 1, Cores: 1, Threads: 1 diff --git a/tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/core_id b/tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/core_id new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/core_id @@ -0,0 +1 @@ +0 diff --git a/tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/core_siblings b/tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/core_siblings new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/core_siblings @@ -0,0 +1 @@ +1 diff --git a/tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/core_siblings_list b/tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/core_siblings_list new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/core_siblings_list @@ -0,0 +1 @@ +0 diff --git a/tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/physical_package_id b/tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/physical_package_id new file mode 100644 index 0000000..3a2e3f4 --- /dev/null +++ b/tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/physical_package_id @@ -0,0 +1 @@ +-1 diff --git a/tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/thread_siblings b/tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/thread_siblings new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/thread_siblings @@ -0,0 +1 @@ +1 diff --git a/tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/thread_siblings_list b/tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/thread_siblings_list new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/thread_siblings_list @@ -0,0 +1 @@ +0 diff --git a/tests/nodeinfodata/linux-raspberrypi/cpu/cpuidle/current_driver b/tests/nodeinfodata/linux-raspberrypi/cpu/cpuidle/current_driver new file mode 100644 index 0000000..621e94f --- /dev/null +++ b/tests/nodeinfodata/linux-raspberrypi/cpu/cpuidle/current_driver @@ -0,0 +1 @@ +none diff --git a/tests/nodeinfodata/linux-raspberrypi/cpu/cpuidle/current_governor_ro b/tests/nodeinfodata/linux-raspberrypi/cpu/cpuidle/current_governor_ro new file mode 100644 index 0000000..c35a724 --- /dev/null +++ b/tests/nodeinfodata/linux-raspberrypi/cpu/cpuidle/current_governor_ro @@ -0,0 +1 @@ +menu diff --git a/tests/nodeinfodata/linux-raspberrypi/cpu/kernel_max b/tests/nodeinfodata/linux-raspberrypi/cpu/kernel_max new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/nodeinfodata/linux-raspberrypi/cpu/kernel_max @@ -0,0 +1 @@ +0 diff --git a/tests/nodeinfodata/linux-raspberrypi/cpu/offline b/tests/nodeinfodata/linux-raspberrypi/cpu/offline new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tests/nodeinfodata/linux-raspberrypi/cpu/offline @@ -0,0 +1 @@ + diff --git a/tests/nodeinfodata/linux-raspberrypi/cpu/online b/tests/nodeinfodata/linux-raspberrypi/cpu/online new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/nodeinfodata/linux-raspberrypi/cpu/online @@ -0,0 +1 @@ +0 diff --git a/tests/nodeinfodata/linux-raspberrypi/cpu/possible b/tests/nodeinfodata/linux-raspberrypi/cpu/possible new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/nodeinfodata/linux-raspberrypi/cpu/possible @@ -0,0 +1 @@ +0 diff --git a/tests/nodeinfodata/linux-raspberrypi/cpu/present b/tests/nodeinfodata/linux-raspberrypi/cpu/present new file mode 100644 index 0000000..573541a --- /dev/null +++ b/tests/nodeinfodata/linux-raspberrypi/cpu/present @@ -0,0 +1 @@ +0 diff --git a/tests/nodeinfotest.c b/tests/nodeinfotest.c index 650a674..3c76e5d 100644 --- a/tests/nodeinfotest.c +++ b/tests/nodeinfotest.c @@ -245,6 +245,7 @@ mymain(void) {"test6", VIR_ARCH_X86_64}, {"test7", VIR_ARCH_X86_64}, {"test8", VIR_ARCH_X86_64}, + {"raspberrypi", VIR_ARCH_ARMV6L}, }; if (virInitialize() < 0) -- 1.8.5.5

So far three ARM processor families are known to libvirt, however the cpu driver knows only about one of them. This make host initialization on the other two fail: 2014-06-17 13:35:41.419+0000: 6840: info : libvirt version: 1.2.6 2014-06-17 13:35:41.419+0000: 6840: error : cpuNodeData:342 : this function is not supported by the connection driver: cannot get node CPU data for armv6l architecture 2014-06-17 13:35:41.433+0000: 6840: warning : virQEMUCapsInit:943 : Failed to get host CPU Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/cpu/cpu_arm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cpu/cpu_arm.c b/src/cpu/cpu_arm.c index 53bf4f4..39e8f12 100644 --- a/src/cpu/cpu_arm.c +++ b/src/cpu/cpu_arm.c @@ -30,7 +30,9 @@ #define VIR_FROM_THIS VIR_FROM_CPU -static const virArch archs[] = { VIR_ARCH_ARMV7L }; +static const virArch archs[] = {VIR_ARCH_ARMV6L, + VIR_ARCH_ARMV7B, + VIR_ARCH_ARMV7L}; static virCPUDataPtr ArmNodeData(virArch arch) -- 1.8.5.5

On 06/17/2014 03:38 PM, Michal Privoznik wrote:
So far three ARM processor families are known to libvirt, however the cpu driver knows only about one of them. This make host initialization on the other two fail:
2014-06-17 13:35:41.419+0000: 6840: info : libvirt version: 1.2.6 2014-06-17 13:35:41.419+0000: 6840: error : cpuNodeData:342 : this function is not supported by the connection driver: cannot get node CPU data for armv6l architecture 2014-06-17 13:35:41.433+0000: 6840: warning : virQEMUCapsInit:943 : Failed to get host CPU
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/cpu/cpu_arm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
ACK

On 06/17/2014 02:48 PM, Michal Privoznik wrote:
Look at the patches :P
:P
Michal Privoznik (4): nodeinfo: Introduce @arch to linuxNodeInfoCPUPopulate virNodeParseNode: Propagate host architecture nodeinfotest: Print error if cpuinfo file can't be opened virNodeParseSocket: Take ARM into account
cfg.mk | 2 +- src/nodeinfo.c | 199 +++++++++++---------- src/nodeinfopriv.h | 1 + .../nodeinfodata/linux-armv6l-raspberrypi.cpuinfo | 12 ++ .../nodeinfodata/linux-armv6l-raspberrypi.expected | 1 + .../linux-raspberrypi/cpu/cpu0/topology/core_id | 1 + .../cpu/cpu0/topology/core_siblings | 1 + .../cpu/cpu0/topology/core_siblings_list | 1 + .../cpu/cpu0/topology/physical_package_id | 1 + .../cpu/cpu0/topology/thread_siblings | 1 + .../cpu/cpu0/topology/thread_siblings_list | 1 + .../linux-raspberrypi/cpu/cpuidle/current_driver | 1 + .../cpu/cpuidle/current_governor_ro | 1 + .../nodeinfodata/linux-raspberrypi/cpu/kernel_max | 1 + tests/nodeinfodata/linux-raspberrypi/cpu/offline | 1 + tests/nodeinfodata/linux-raspberrypi/cpu/online | 1 + tests/nodeinfodata/linux-raspberrypi/cpu/possible | 1 + tests/nodeinfodata/linux-raspberrypi/cpu/present | 1 + ...86-test1.cpuinfo => linux-x86_64-test1.cpuinfo} | 0 ...-test1.expected => linux-x86_64-test1.expected} | 0 ...86-test2.cpuinfo => linux-x86_64-test2.cpuinfo} | 0 ...-test2.expected => linux-x86_64-test2.expected} | 0 ...86-test3.cpuinfo => linux-x86_64-test3.cpuinfo} | 0 ...-test3.expected => linux-x86_64-test3.expected} | 0 ...86-test4.cpuinfo => linux-x86_64-test4.cpuinfo} | 0 ...-test4.expected => linux-x86_64-test4.expected} | 0 ...86-test5.cpuinfo => linux-x86_64-test5.cpuinfo} | 0 ...-test5.expected => linux-x86_64-test5.expected} | 0 ...86-test6.cpuinfo => linux-x86_64-test6.cpuinfo} | 0 ...-test6.expected => linux-x86_64-test6.expected} | 0 ...86-test7.cpuinfo => linux-x86_64-test7.cpuinfo} | 0 ...-test7.expected => linux-x86_64-test7.expected} | 0 ...86-test8.cpuinfo => linux-x86_64-test8.cpuinfo} | 0 ...-test8.expected => linux-x86_64-test8.expected} | 0 tests/nodeinfotest.c | 63 ++++--- 35 files changed, 164 insertions(+), 127 deletions(-) create mode 100644 tests/nodeinfodata/linux-armv6l-raspberrypi.cpuinfo create mode 100644 tests/nodeinfodata/linux-armv6l-raspberrypi.expected create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/core_id create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/core_siblings create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/core_siblings_list create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/physical_package_id create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/thread_siblings create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/thread_siblings_list create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpuidle/current_driver create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpuidle/current_governor_ro create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/kernel_max create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/offline create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/online create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/possible create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/present rename tests/nodeinfodata/{linux-x86-test1.cpuinfo => linux-x86_64-test1.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test1.expected => linux-x86_64-test1.expected} (100%) rename tests/nodeinfodata/{linux-x86-test2.cpuinfo => linux-x86_64-test2.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test2.expected => linux-x86_64-test2.expected} (100%) rename tests/nodeinfodata/{linux-x86-test3.cpuinfo => linux-x86_64-test3.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test3.expected => linux-x86_64-test3.expected} (100%) rename tests/nodeinfodata/{linux-x86-test4.cpuinfo => linux-x86_64-test4.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test4.expected => linux-x86_64-test4.expected} (100%) rename tests/nodeinfodata/{linux-x86-test5.cpuinfo => linux-x86_64-test5.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test5.expected => linux-x86_64-test5.expected} (100%) rename tests/nodeinfodata/{linux-x86-test6.cpuinfo => linux-x86_64-test6.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test6.expected => linux-x86_64-test6.expected} (100%) rename tests/nodeinfodata/{linux-x86-test7.cpuinfo => linux-x86_64-test7.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test7.expected => linux-x86_64-test7.expected} (100%) rename tests/nodeinfodata/{linux-x86-test8.cpuinfo => linux-x86_64-test8.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test8.expected => linux-x86_64-test8.expected} (100%)
Fails syntax-check for me: tests/nodeinfodata/linux-armv6l-raspberrypi.cpuinfo:3:Features : swp half thumb fastmult vfp edsp java tls maint.mk: found trailing blank(s) ACK series with that fixed Also, defining and using macros like: # define ARCH_IS_X86(arch) ((arch) == VIR_ARCH_X86_64 ||\ (arch) == VIR_ARCH_I686) for PPC, S390 and ARM could make the code more readable. Jan

On 20.06.2014 13:40, Ján Tomko wrote:
On 06/17/2014 02:48 PM, Michal Privoznik wrote:
Look at the patches :P
:P
Michal Privoznik (4): nodeinfo: Introduce @arch to linuxNodeInfoCPUPopulate virNodeParseNode: Propagate host architecture nodeinfotest: Print error if cpuinfo file can't be opened virNodeParseSocket: Take ARM into account
cfg.mk | 2 +- src/nodeinfo.c | 199 +++++++++++---------- src/nodeinfopriv.h | 1 + .../nodeinfodata/linux-armv6l-raspberrypi.cpuinfo | 12 ++ .../nodeinfodata/linux-armv6l-raspberrypi.expected | 1 + .../linux-raspberrypi/cpu/cpu0/topology/core_id | 1 + .../cpu/cpu0/topology/core_siblings | 1 + .../cpu/cpu0/topology/core_siblings_list | 1 + .../cpu/cpu0/topology/physical_package_id | 1 + .../cpu/cpu0/topology/thread_siblings | 1 + .../cpu/cpu0/topology/thread_siblings_list | 1 + .../linux-raspberrypi/cpu/cpuidle/current_driver | 1 + .../cpu/cpuidle/current_governor_ro | 1 + .../nodeinfodata/linux-raspberrypi/cpu/kernel_max | 1 + tests/nodeinfodata/linux-raspberrypi/cpu/offline | 1 + tests/nodeinfodata/linux-raspberrypi/cpu/online | 1 + tests/nodeinfodata/linux-raspberrypi/cpu/possible | 1 + tests/nodeinfodata/linux-raspberrypi/cpu/present | 1 + ...86-test1.cpuinfo => linux-x86_64-test1.cpuinfo} | 0 ...-test1.expected => linux-x86_64-test1.expected} | 0 ...86-test2.cpuinfo => linux-x86_64-test2.cpuinfo} | 0 ...-test2.expected => linux-x86_64-test2.expected} | 0 ...86-test3.cpuinfo => linux-x86_64-test3.cpuinfo} | 0 ...-test3.expected => linux-x86_64-test3.expected} | 0 ...86-test4.cpuinfo => linux-x86_64-test4.cpuinfo} | 0 ...-test4.expected => linux-x86_64-test4.expected} | 0 ...86-test5.cpuinfo => linux-x86_64-test5.cpuinfo} | 0 ...-test5.expected => linux-x86_64-test5.expected} | 0 ...86-test6.cpuinfo => linux-x86_64-test6.cpuinfo} | 0 ...-test6.expected => linux-x86_64-test6.expected} | 0 ...86-test7.cpuinfo => linux-x86_64-test7.cpuinfo} | 0 ...-test7.expected => linux-x86_64-test7.expected} | 0 ...86-test8.cpuinfo => linux-x86_64-test8.cpuinfo} | 0 ...-test8.expected => linux-x86_64-test8.expected} | 0 tests/nodeinfotest.c | 63 ++++--- 35 files changed, 164 insertions(+), 127 deletions(-) create mode 100644 tests/nodeinfodata/linux-armv6l-raspberrypi.cpuinfo create mode 100644 tests/nodeinfodata/linux-armv6l-raspberrypi.expected create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/core_id create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/core_siblings create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/core_siblings_list create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/physical_package_id create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/thread_siblings create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpu0/topology/thread_siblings_list create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpuidle/current_driver create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/cpuidle/current_governor_ro create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/kernel_max create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/offline create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/online create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/possible create mode 100644 tests/nodeinfodata/linux-raspberrypi/cpu/present rename tests/nodeinfodata/{linux-x86-test1.cpuinfo => linux-x86_64-test1.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test1.expected => linux-x86_64-test1.expected} (100%) rename tests/nodeinfodata/{linux-x86-test2.cpuinfo => linux-x86_64-test2.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test2.expected => linux-x86_64-test2.expected} (100%) rename tests/nodeinfodata/{linux-x86-test3.cpuinfo => linux-x86_64-test3.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test3.expected => linux-x86_64-test3.expected} (100%) rename tests/nodeinfodata/{linux-x86-test4.cpuinfo => linux-x86_64-test4.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test4.expected => linux-x86_64-test4.expected} (100%) rename tests/nodeinfodata/{linux-x86-test5.cpuinfo => linux-x86_64-test5.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test5.expected => linux-x86_64-test5.expected} (100%) rename tests/nodeinfodata/{linux-x86-test6.cpuinfo => linux-x86_64-test6.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test6.expected => linux-x86_64-test6.expected} (100%) rename tests/nodeinfodata/{linux-x86-test7.cpuinfo => linux-x86_64-test7.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test7.expected => linux-x86_64-test7.expected} (100%) rename tests/nodeinfodata/{linux-x86-test8.cpuinfo => linux-x86_64-test8.cpuinfo} (100%) rename tests/nodeinfodata/{linux-x86-test8.expected => linux-x86_64-test8.expected} (100%)
Fails syntax-check for me: tests/nodeinfodata/linux-armv6l-raspberrypi.cpuinfo:3:Features : swp half thumb fastmult vfp edsp java tls maint.mk: found trailing blank(s)
I'm undecided how to fix this. The cpuinfo file is pure copy&paste from the /proc/cpuinfo on my Raspberry which does contain the trailing whitespace. So while I'd like to keep the cpuinfo in sync with its origin, it's causing the syntax-check error. So maybe add a syntax-check rule exception? exclude_file_name_regexp--sc_trailing_blank = \ /qemuhelpdata/|/sysinfodata/.*\.data$$
ACK series with that fixed
Also, defining and using macros like: # define ARCH_IS_X86(arch) ((arch) == VIR_ARCH_X86_64 ||\ (arch) == VIR_ARCH_I686)
Clever idea. I'll do that.
for PPC, S390 and ARM could make the code more readable.
Jan
Michal

On 06/20/2014 01:55 PM, Michal Privoznik wrote:
On 20.06.2014 13:40, Ján Tomko wrote:
Fails syntax-check for me: tests/nodeinfodata/linux-armv6l-raspberrypi.cpuinfo:3:Features : swp half thumb fastmult vfp edsp java tls maint.mk: found trailing blank(s)
I'm undecided how to fix this. The cpuinfo file is pure copy&paste from the /proc/cpuinfo on my Raspberry which does contain the trailing whitespace. So while I'd like to keep the cpuinfo in sync with its origin, it's causing the syntax-check error. So maybe add a syntax-check rule exception?
exclude_file_name_regexp--sc_trailing_blank = \ /qemuhelpdata/|/sysinfodata/.*\.data$$
That would be my choice, especially since we already have an exception for sysinfodata. Jan

On 20.06.2014 13:59, Ján Tomko wrote:
On 06/20/2014 01:55 PM, Michal Privoznik wrote:
On 20.06.2014 13:40, Ján Tomko wrote:
Fails syntax-check for me: tests/nodeinfodata/linux-armv6l-raspberrypi.cpuinfo:3:Features : swp half thumb fastmult vfp edsp java tls maint.mk: found trailing blank(s)
I'm undecided how to fix this. The cpuinfo file is pure copy&paste from the /proc/cpuinfo on my Raspberry which does contain the trailing whitespace. So while I'd like to keep the cpuinfo in sync with its origin, it's causing the syntax-check error. So maybe add a syntax-check rule exception?
exclude_file_name_regexp--sc_trailing_blank = \ /qemuhelpdata/|/sysinfodata/.*\.data$$
That would be my choice, especially since we already have an exception for sysinfodata.
Jan
Pushed now, thanks. Michal

On 06/20/2014 05:55 AM, Michal Privoznik wrote:
On 20.06.2014 13:40, Ján Tomko wrote:
Fails syntax-check for me: tests/nodeinfodata/linux-armv6l-raspberrypi.cpuinfo:3:Features : swp half thumb fastmult vfp edsp java tls maint.mk: found trailing blank(s)
I'm undecided how to fix this. The cpuinfo file is pure copy&paste from the /proc/cpuinfo on my Raspberry which does contain the trailing whitespace. So while I'd like to keep the cpuinfo in sync with its origin, it's causing the syntax-check error. So maybe add a syntax-check rule exception?
Yes, that's standard behavior - we want to exempt files that are copy-and-paste from actual systems, since we want to test that our code handles what they will actually encounter. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (3)
-
Eric Blake
-
Ján Tomko
-
Michal Privoznik