def->ncells = n;
for (i = 0 ; i < n ; i++) {
- char *cpus, *cpus_parse, *memory;
+ char *cpus, *memory;
int cpumasklen = VIR_DOMAIN_CPUMASK_LEN;
int ret, ncpus = 0;
def->cells[i].cellid = i;
- cpus = cpus_parse = virXMLPropString(nodes[i], "cpus");
+ cpus = virXMLPropString(nodes[i], "cpus");
if (!cpus) {
virCPUReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Missing 'cpus' attribute in NUMA cell"));
goto error;
}
+ def->cells[i].cpustr = cpus;
- def->cells[i].cpustr = strdup(cpus);
- if (!def->cells[i].cpustr) {
- VIR_FREE(cpus);
+ if (VIR_ALLOC_N(def->cells[i].cpumask, cpumasklen) < 0)
goto no_memory;
- }
- if (VIR_ALLOC_N(def->cells[i].cpumask, cpumasklen) < 0) {
- VIR_FREE(cpus);
- goto no_memory;
- }
-
- ncpus = virDomainCpuSetParse((const char **)&cpus_parse,
- 0, def->cells[i].cpumask, cpumasklen);
- if (ncpus <= 0) {
- VIR_FREE(cpus);
+ ncpus = virDomainCpuSetParse(cpus, 0, def->cells[i].cpumask,
+ cpumasklen);
+ if (ncpus <= 0)
goto error;
- }
def->cells_cpus += ncpus;
memory = virXMLPropString(nodes[i], "memory");
if (!memory) {
virCPUReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Missing 'memory' attribute in NUMA cell"));
- VIR_FREE(cpus);
goto error;
}
if (ret == -1) {
virCPUReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Invalid 'memory' attribute in NUMA cell"));
- VIR_FREE(cpus);
VIR_FREE(memory);
goto error;
}
- VIR_FREE(cpus);
VIR_FREE(memory);
}
}
virReportOOMError();
goto error;
}
- if (virDomainCpuSetParse((const char **)&set,
- 0, def->cpumask,
+ if (virDomainCpuSetParse(set, 0, def->cpumask,
cpumasklen) < 0)
goto error;
VIR_FREE(tmp);
if (VIR_ALLOC_N(def->cpumask, def->cpumasklen) < 0) {
goto no_memory;
}
- if (virDomainCpuSetParse((const char **)&set,
- 0, def->cpumask,
+ if (virDomainCpuSetParse(set, 0, def->cpumask,
def->cpumasklen) < 0)
goto error;
VIR_FREE(tmp);
}
/* "nodeset" leads same syntax with "cpuset". */
- if (virDomainCpuSetParse((const char **)&set,
- 0, def->numatune.memory.nodemask,
+ if (virDomainCpuSetParse(set, 0, def->numatune.memory.nodemask,
nodemasklen) < 0)
goto error;
VIR_FREE(tmp);
/**
* virDomainCpuSetParse:
* @conn: connection
- * @str: pointer to a CPU set string pointer
+ * @str: a CPU set string pointer
* @sep: potential character used to mark the end of string if not 0
* @cpuset: pointer to a char array for the CPU set
* @maxcpu: number of elements available in @cpuset
*
* Returns the number of CPU found in that set, or -1 in case of error.
* @cpuset is modified accordingly to the value parsed.
- * @str is updated to the end of the part parsed
*/
int
-virDomainCpuSetParse(const char **str, char sep,
+virDomainCpuSetParse(const char *str, char sep,
char *cpuset, int maxcpu)
{
const char *cur;
(maxcpu > 100000))
return (-1);
- cur = *str;
+ cur = str;
virSkipSpaces(&cur);
if (*cur == 0)
goto parse_error;
} else
goto parse_error;
}
- *str = cur;
return (ret);
parse_error:
unsigned int flags,
virBufferPtr buf);
-int virDomainCpuSetParse(const char **str,
+int virDomainCpuSetParse(const char *str,
char sep,
char *cpuset,
int maxcpu);
for (cpu = 0; cpu < numCpus; cpu++)
cpuset[cpu] = 0;
} else {
- nb_cpus = virDomainCpuSetParse(&cur, 'n', cpuset, numCpus);
+ nb_cpus = virDomainCpuSetParse(cur, 'n', cpuset, numCpus);
if (nb_cpus < 0)
goto error;
}
virReportOOMError();
goto cleanup;
}
- if (virDomainCpuSetParse((const char **)&mapstr, 0,
- cpuset, maxcpu) < 0)
+ if (virDomainCpuSetParse(mapstr, 0, cpuset, maxcpu) < 0)
goto cleanup;
VIR_FREE(entry->def->cpumask);
goto error;
}
- if (virDomainCpuSetParse(&cpus,
- 0, def->cpumask,
+ if (virDomainCpuSetParse(cpus, 0, def->cpumask,
def->cpumasklen) < 0) {
XENXS_ERROR(VIR_ERR_INTERNAL_ERROR,
_("invalid CPU mask %s"), cpus);
if (VIR_ALLOC_N(def->cpumask, def->cpumasklen) < 0)
goto no_memory;
- if (virDomainCpuSetParse(&str, 0,
+ if (virDomainCpuSetParse(str, 0,
def->cpumask, def->cpumasklen) < 0)
goto cleanup;
}