mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +00:00
xen: eliminate remaining uses of virDomainCpuSetParse
The final patch in Hu Tao's series to enhance virBitmap actually removes virDomainCpuSetParse and virDomainCpuSetFormat as "no longer used", and the rest of the series hadn't taken care of two uses of virDomainCpuSetParse in the xen code. This patch replaces those with appropriate virBitmap functions. It should be pushed prior to the patch removing virDomainCpuSetParse.
This commit is contained in:
parent
fe2a0b027b
commit
58d372d441
@ -134,7 +134,7 @@ xenDomainUsedCpus(virDomainPtr dom)
|
|||||||
char *res = NULL;
|
char *res = NULL;
|
||||||
int ncpus;
|
int ncpus;
|
||||||
int nb_vcpu;
|
int nb_vcpu;
|
||||||
char *cpulist = NULL;
|
virBitmapPtr cpulist = NULL;
|
||||||
unsigned char *cpumap = NULL;
|
unsigned char *cpumap = NULL;
|
||||||
size_t cpumaplen;
|
size_t cpumaplen;
|
||||||
int nb = 0;
|
int nb = 0;
|
||||||
@ -156,7 +156,7 @@ xenDomainUsedCpus(virDomainPtr dom)
|
|||||||
if (xenUnifiedNodeGetInfo(dom->conn, &nodeinfo) < 0)
|
if (xenUnifiedNodeGetInfo(dom->conn, &nodeinfo) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (VIR_ALLOC_N(cpulist, priv->nbNodeCpus) < 0) {
|
if (!(cpulist = virBitmapNew(priv->nbNodeCpus))) {
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@ -175,9 +175,11 @@ xenDomainUsedCpus(virDomainPtr dom)
|
|||||||
cpumap, cpumaplen)) >= 0) {
|
cpumap, cpumaplen)) >= 0) {
|
||||||
for (n = 0 ; n < ncpus ; n++) {
|
for (n = 0 ; n < ncpus ; n++) {
|
||||||
for (m = 0 ; m < priv->nbNodeCpus; m++) {
|
for (m = 0 ; m < priv->nbNodeCpus; m++) {
|
||||||
if ((cpulist[m] == 0) &&
|
bool used;
|
||||||
|
ignore_value(virBitmapGetBit(cpulist, m, &used));
|
||||||
|
if ((!used) &&
|
||||||
(VIR_CPU_USABLE(cpumap, cpumaplen, n, m))) {
|
(VIR_CPU_USABLE(cpumap, cpumaplen, n, m))) {
|
||||||
cpulist[m] = 1;
|
ignore_value(virBitmapSetBit(cpulist, m));
|
||||||
nb++;
|
nb++;
|
||||||
/* if all CPU are used just return NULL */
|
/* if all CPU are used just return NULL */
|
||||||
if (nb == priv->nbNodeCpus)
|
if (nb == priv->nbNodeCpus)
|
||||||
@ -186,11 +188,11 @@ xenDomainUsedCpus(virDomainPtr dom)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res = virDomainCpuSetFormat(cpulist, priv->nbNodeCpus);
|
res = virBitmapFormat(cpulist);
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
VIR_FREE(cpulist);
|
virBitmapFree(cpulist);
|
||||||
VIR_FREE(cpumap);
|
VIR_FREE(cpumap);
|
||||||
VIR_FREE(cpuinfo);
|
VIR_FREE(cpuinfo);
|
||||||
return res;
|
return res;
|
||||||
|
@ -1113,7 +1113,7 @@ sexpr_to_xend_topology(const struct sexpr *root,
|
|||||||
{
|
{
|
||||||
const char *nodeToCpu;
|
const char *nodeToCpu;
|
||||||
const char *cur;
|
const char *cur;
|
||||||
char *cpuset = NULL;
|
virBitmapPtr cpuset = NULL;
|
||||||
int *cpuNums = NULL;
|
int *cpuNums = NULL;
|
||||||
int cell, cpu, nb_cpus;
|
int cell, cpu, nb_cpus;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
@ -1126,8 +1126,6 @@ sexpr_to_xend_topology(const struct sexpr *root,
|
|||||||
numCpus = sexpr_int(root, "node/nr_cpus");
|
numCpus = sexpr_int(root, "node/nr_cpus");
|
||||||
|
|
||||||
|
|
||||||
if (VIR_ALLOC_N(cpuset, numCpus) < 0)
|
|
||||||
goto memory_error;
|
|
||||||
if (VIR_ALLOC_N(cpuNums, numCpus) < 0)
|
if (VIR_ALLOC_N(cpuNums, numCpus) < 0)
|
||||||
goto memory_error;
|
goto memory_error;
|
||||||
|
|
||||||
@ -1150,17 +1148,21 @@ sexpr_to_xend_topology(const struct sexpr *root,
|
|||||||
virSkipSpacesAndBackslash(&cur);
|
virSkipSpacesAndBackslash(&cur);
|
||||||
if (STRPREFIX(cur, "no cpus")) {
|
if (STRPREFIX(cur, "no cpus")) {
|
||||||
nb_cpus = 0;
|
nb_cpus = 0;
|
||||||
for (cpu = 0; cpu < numCpus; cpu++)
|
if (!(cpuset = virBitmapNew(numCpus)))
|
||||||
cpuset[cpu] = 0;
|
goto memory_error;
|
||||||
} else {
|
} else {
|
||||||
nb_cpus = virDomainCpuSetParse(cur, 'n', cpuset, numCpus);
|
nb_cpus = virBitmapParse(cur, 'n', &cpuset, numCpus);
|
||||||
if (nb_cpus < 0)
|
if (nb_cpus < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (n = 0, cpu = 0; cpu < numCpus; cpu++)
|
for (n = 0, cpu = 0; cpu < numCpus; cpu++) {
|
||||||
if (cpuset[cpu] == 1)
|
bool used;
|
||||||
|
|
||||||
|
ignore_value(virBitmapGetBit(cpuset, cpu, &used));
|
||||||
|
if (used)
|
||||||
cpuNums[n++] = cpu;
|
cpuNums[n++] = cpu;
|
||||||
|
}
|
||||||
|
|
||||||
if (virCapabilitiesAddHostNUMACell(caps,
|
if (virCapabilitiesAddHostNUMACell(caps,
|
||||||
cell,
|
cell,
|
||||||
@ -1169,20 +1171,20 @@ sexpr_to_xend_topology(const struct sexpr *root,
|
|||||||
goto memory_error;
|
goto memory_error;
|
||||||
}
|
}
|
||||||
VIR_FREE(cpuNums);
|
VIR_FREE(cpuNums);
|
||||||
VIR_FREE(cpuset);
|
virBitmapFree(cpuset);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
parse_error:
|
parse_error:
|
||||||
virReportError(VIR_ERR_XEN_CALL, "%s", _("topology syntax error"));
|
virReportError(VIR_ERR_XEN_CALL, "%s", _("topology syntax error"));
|
||||||
error:
|
error:
|
||||||
VIR_FREE(cpuNums);
|
VIR_FREE(cpuNums);
|
||||||
VIR_FREE(cpuset);
|
virBitmapFree(cpuset);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
memory_error:
|
memory_error:
|
||||||
VIR_FREE(cpuNums);
|
VIR_FREE(cpuNums);
|
||||||
VIR_FREE(cpuset);
|
virBitmapFree(cpuset);
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user