]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
libxl: fix dubious cpumask handling in libxlDomainSetVcpuAffinities
authorJeremy Fitzhardinge <jeremy@goop.org>
Wed, 30 Oct 2013 17:38:08 +0000 (10:38 -0700)
committerCole Robinson <crobinso@redhat.com>
Sun, 17 Nov 2013 23:02:46 +0000 (18:02 -0500)
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: Jeremy Fitzhardinge <jeremy@goop.org>
(cherry picked from commit ba1bf10063a0205c1de12b209b0282833710214f)

src/libxl/libxl_driver.c

index adaec7557975cf7b6a071f1bff2c1f55297746f0..f47aceb43e9f253cc6a45d0e17fd013c5b49ac3a 100644 (file)
@@ -808,7 +808,7 @@ libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr driver, virDomainObjPtr vm)
     libxlDomainObjPrivatePtr priv = vm->privateData;
     virDomainDefPtr def = vm->def;
     libxl_bitmap map;
-    uint8_t *cpumask = NULL;
+    virBitmapPtr cpumask = NULL;
     uint8_t *cpumap = NULL;
     virNodeInfo nodeinfo;
     size_t cpumaplen;
@@ -829,10 +829,12 @@ libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr driver, virDomainObjPtr vm)
             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) {
-            if (cpumask[i])
+        for (i = 0; i < virBitmapSize(cpumask); ++i) {
+            bool bit;
+            ignore_value(virBitmapGetBit(cpumask, i, &bit));
+            if (bit)
                 VIR_USE_CPU(cpumap, i);
         }