提交 c004f937 编写于 作者: J Jeremy Fitzhardinge 提交者: Cole Robinson

libxl: fix dubious cpumask handling in libxlDomainSetVcpuAffinities

Rather than casting the virBitmap pointer to uint8_t* and then using
the structure contents as a byte array, use the virBitmap API to determine
the bitmap size and test each bit.
Signed-off-by: NJeremy Fitzhardinge <jeremy@goop.org>
(cherry picked from commit ba1bf100)
上级 894b3a9e
...@@ -448,7 +448,7 @@ libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr driver, virDomainObjPtr vm) ...@@ -448,7 +448,7 @@ libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr driver, virDomainObjPtr vm)
libxlDomainObjPrivatePtr priv = vm->privateData; libxlDomainObjPrivatePtr priv = vm->privateData;
virDomainDefPtr def = vm->def; virDomainDefPtr def = vm->def;
libxl_bitmap map; libxl_bitmap map;
uint8_t *cpumask = NULL; virBitmapPtr cpumask = NULL;
uint8_t *cpumap = NULL; uint8_t *cpumap = NULL;
virNodeInfo nodeinfo; virNodeInfo nodeinfo;
size_t cpumaplen; size_t cpumaplen;
...@@ -468,10 +468,12 @@ libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr driver, virDomainObjPtr vm) ...@@ -468,10 +468,12 @@ libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr driver, virDomainObjPtr vm)
if (VIR_ALLOC_N(cpumap, cpumaplen) < 0) if (VIR_ALLOC_N(cpumap, cpumaplen) < 0)
goto cleanup; goto cleanup;
cpumask = (uint8_t*) def->cputune.vcpupin[vcpu]->cpumask; cpumask = def->cputune.vcpupin[vcpu]->cpumask;
for (i = 0; i < VIR_DOMAIN_CPUMASK_LEN; ++i) { for (i = 0; i < virBitmapSize(cpumask); ++i) {
if (cpumask[i]) bool bit;
ignore_value(virBitmapGetBit(cpumask, i, &bit));
if (bit)
VIR_USE_CPU(cpumap, i); VIR_USE_CPU(cpumap, i);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册