Commit 3fba4801 authored by Leonid Podolny's avatar Leonid Podolny Committed by Daniel P. Berrange

domain.go: construct cpumaps correctly for CPU pinning verbs

In PinEmulator() and PinIOThread() there is an identical code that
converts []bool into a bitmask. It calculates the location in the
bitmask and then sets it always to 1, instead of looking at the
actual bool value.
Signed-off-by: default avatarDaniel P. Berrange <berrange@redhat.com>
parent bd9dd147
......@@ -3967,10 +3967,12 @@ func (d *Domain) PinEmulator(cpumap []bool, flags DomainModificationImpact) erro
maplen := (len(cpumap) + 7) / 8
ccpumaps := make([]C.uchar, maplen)
for i := 0; i < len(cpumap); i++ {
byte := i / 8
bit := i % 8
if cpumap[i] {
byte := i / 8
bit := i % 8
ccpumaps[byte] |= (1 << uint(bit))
ccpumaps[byte] |= (1 << uint(bit))
}
}
ret := C.virDomainPinEmulator(d.ptr, &ccpumaps[0], C.int(maplen), C.uint(flags))
......@@ -3989,10 +3991,12 @@ func (d *Domain) PinIOThread(iothreadid uint, cpumap []bool, flags DomainModific
maplen := (len(cpumap) + 7) / 8
ccpumaps := make([]C.uchar, maplen)
for i := 0; i < len(cpumap); i++ {
byte := i / 8
bit := i % 8
if cpumap[i] {
byte := i / 8
bit := i % 8
ccpumaps[byte] |= (1 << uint(bit))
ccpumaps[byte] |= (1 << uint(bit))
}
}
ret := C.virDomainPinIOThreadCompat(d.ptr, C.uint(iothreadid), &ccpumaps[0], C.int(maplen), C.uint(flags))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment