]> 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)
committerJim Fehlig <jfehlig@suse.com>
Fri, 1 Nov 2013 15:05:36 +0000 (09:05 -0600)
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>
src/libxl/libxl_driver.c

index 6aab11fd7f778dc62d654e188de12f642b6871de..3c3e21b381b7cd24939377d88274de37d9ce0bc5 100644 (file)
@@ -448,7 +448,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;
@@ -468,10 +468,12 @@ libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr driver, virDomainObjPtr vm)
         if (VIR_ALLOC_N(cpumap, cpumaplen) < 0)
             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);
         }