diff --git a/src/nodeinfo.c b/src/nodeinfo.c index acd3188472..22d53e53be 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -61,7 +61,8 @@ /* NB, this is not static as we need to call it from the testsuite */ int linuxNodeInfoCPUPopulate(FILE *cpuinfo, - virNodeInfoPtr nodeinfo); + virNodeInfoPtr nodeinfo, + bool need_hyperthreads); /* Return the positive decimal contents of the given * CPU_SYS_PATH/cpu%u/FILE, or -1 on error. If MISSING_OK and the @@ -167,7 +168,8 @@ static int parse_socket(unsigned int cpu) } int linuxNodeInfoCPUPopulate(FILE *cpuinfo, - virNodeInfoPtr nodeinfo) + virNodeInfoPtr nodeinfo, + bool need_hyperthreads) { char line[1024]; DIR *cpudir = NULL; @@ -244,6 +246,9 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo, return -1; } + if (!need_hyperthreads) + return 0; + /* OK, we've parsed what we can out of /proc/cpuinfo. Get the socket * and thread information from /sys */ @@ -338,7 +343,7 @@ int nodeGetInfo(virConnectPtr conn ATTRIBUTE_UNUSED, virNodeInfoPtr nodeinfo) { _("cannot open %s"), CPUINFO_PATH); return -1; } - ret = linuxNodeInfoCPUPopulate(cpuinfo, nodeinfo); + ret = linuxNodeInfoCPUPopulate(cpuinfo, nodeinfo, true); VIR_FORCE_FCLOSE(cpuinfo); if (ret < 0) return -1; diff --git a/tests/nodeinfotest.c b/tests/nodeinfotest.c index f56247b854..c690403503 100644 --- a/tests/nodeinfotest.c +++ b/tests/nodeinfotest.c @@ -26,7 +26,8 @@ static char *abs_srcdir; # define MAX_FILE 4096 -extern int linuxNodeInfoCPUPopulate(FILE *cpuinfo, virNodeInfoPtr nodeinfo); +extern int linuxNodeInfoCPUPopulate(FILE *cpuinfo, virNodeInfoPtr nodeinfo, + bool need_hyperthreads); static int linuxTestCompareFiles(const char *cpuinfofile, const char *outputfile) { char actualData[MAX_FILE]; @@ -43,7 +44,7 @@ static int linuxTestCompareFiles(const char *cpuinfofile, const char *outputfile return -1; memset(&nodeinfo, 0, sizeof(nodeinfo)); - if (linuxNodeInfoCPUPopulate(cpuinfo, &nodeinfo) < 0) { + if (linuxNodeInfoCPUPopulate(cpuinfo, &nodeinfo, false) < 0) { if (virTestGetDebug()) { virErrorPtr error = virSaveLastError(); if (error && error->code != VIR_ERR_OK)