int virFCReadRportValue(const char *rport, const char *entry, char **result) { int ret = -1; char *buf = NULL, *p = NULL; if (virFileReadValueString(&buf, "%s/%s/%s", SYSFS_FC_RPORT_PATH, rport, entry) < 0) { return -1; } if ((p = strchr(buf, '\n'))) *p = '\0'; if (VIR_STRDUP(*result, buf) < 0) goto cleanup; ret = 0; cleanup: VIR_FREE(buf); return ret; }
int virNumaGetNodeCPUs(int node, virBitmapPtr *cpus) { int ret = -1; char *cpulist = NULL; if (virFileReadValueString(&cpulist, "%s/node/node%u/cpulist", SYSFS_SYSTEM_PATH, node) < 0) return -1; *cpus = virBitmapParseUnlimited(cpulist); if (!*cpus) goto cleanup; ret = virBitmapCountBits(*cpus); cleanup: VIR_FREE(cpulist); return ret; }
int virFCReadRportValue(const char *rport, const char *entry, char **result) { VIR_AUTOFREE(char *) buf = NULL; char *p = NULL; if (virFileReadValueString(&buf, "%s/%s/%s", SYSFS_FC_RPORT_PATH, rport, entry) < 0) { return -1; } if ((p = strchr(buf, '\n'))) *p = '\0'; if (VIR_STRDUP(*result, buf) < 0) return -1; return 0; }