}
static unsigned char *
-vshParseCPUList(int *cpumaplen, const char *cpulist, int maxcpu)
+vshParseCPUList(vshControl *ctl, int *cpumaplen, const char *cpulist, int maxcpu)
{
unsigned char *cpumap = NULL;
virBitmapPtr map = NULL;
return NULL;
virBitmapSetAll(map);
} else {
- if (virBitmapParse(cpulist, '\0', &map, maxcpu) < 0)
- return NULL;
+ if ((virBitmapParse(cpulist, '\0', &map, 1024) < 0) ||
+ virBitmapIsAllClear(map)) {
+ vshError(ctl, _("Invalid cpulist '%s'"), cpulist);
+ goto cleanup;
+ }
+ int lastcpu = virBitmapLastSetBit(map);
+ if (lastcpu >= maxcpu) {
+ vshError(ctl, _("CPU %d in cpulist '%s' exceed the maxcpu %d"),
+ lastcpu, cpulist, maxcpu);
+ goto cleanup;
+ }
}
if (virBitmapToData(map, &cpumap, cpumaplen) < 0)
}
} else {
/* Pin mode: pinning specified vcpu to specified physical cpus*/
- if (!(cpumap = vshParseCPUList(&cpumaplen, cpulist, maxcpu)))
+ if (!(cpumap = vshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu)))
goto cleanup;
if (flags == -1) {
}
/* Pin mode: pinning emulator threads to specified physical cpus*/
- if (!(cpumap = vshParseCPUList(&cpumaplen, cpulist, maxcpu)))
+ if (!(cpumap = vshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu)))
goto cleanup;
if (flags == -1)
if ((maxcpu = vshNodeGetCPUCount(ctl->conn)) < 0)
goto cleanup;
- if (!(cpumap = vshParseCPUList(&cpumaplen, cpulist, maxcpu)))
+ if (!(cpumap = vshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu)))
goto cleanup;
if (virDomainPinIOThread(dom, iothread_id,