404507
From 95cade1ca8bbf611fe14a80bd4cdd821c246ff74 Mon Sep 17 00:00:00 2001
404507
Message-Id: <95cade1ca8bbf611fe14a80bd4cdd821c246ff74@dist-git>
404507
From: Peter Krempa <pkrempa@redhat.com>
404507
Date: Mon, 5 Feb 2018 17:57:36 +0100
404507
Subject: [PATCH] util: bitmap: Fix value of 'map_alloc' when shrinking bitmap
404507
404507
The virBitmap code uses VIR_RESIZE_N to do quadratic scaling, which
404507
means that along with the number of requested map elements we also need
404507
to keep the number of actually allocated elements for the scaling
404507
algorithm to work properly.
404507
404507
The shrinking code did not fix 'map_alloc' thus virResizeN might
404507
actually not expand the bitmap properly after called on a previously
404507
shrunk bitmap.
404507
404507
(cherry picked from commit bf924e8e1be03982b0006e05b4faa3a645a45578)
404507
404507
https://bugzilla.redhat.com/show_bug.cgi?id=1540817
404507
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
404507
---
404507
 src/util/virbitmap.c | 1 +
404507
 1 file changed, 1 insertion(+)
404507
404507
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
404507
index 33cae2f305..36ecc95deb 100644
404507
--- a/src/util/virbitmap.c
404507
+++ b/src/util/virbitmap.c
404507
@@ -1231,5 +1231,6 @@ virBitmapShrink(virBitmapPtr map,
404507
         return -1;
404507
 
404507
     map->map_len = nl;
404507
+    map->map_alloc = nl;
404507
     return 0;
404507
 }
404507
-- 
404507
2.16.1
404507