|
|
7a3408 |
From 56f8f0b1c608f6ae3488658d6c1367e8fc933e52 Mon Sep 17 00:00:00 2001
|
|
|
7a3408 |
Message-Id: <56f8f0b1c608f6ae3488658d6c1367e8fc933e52@dist-git>
|
|
|
7a3408 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
7a3408 |
Date: Wed, 8 Jul 2015 11:06:59 +0200
|
|
|
7a3408 |
Subject: [PATCH] util: bitmap: Don't alloc overly large binary bitmaps
|
|
|
7a3408 |
|
|
|
7a3408 |
Optimize the virBitmap to array-of-char bitmap conversion by skipping
|
|
|
7a3408 |
trailing zero bytes.
|
|
|
7a3408 |
|
|
|
7a3408 |
This also fixes a regression when requesting iothread information from a
|
|
|
7a3408 |
live VM since after commit 825df8c3158cfaf5f398418471f10f4ff3c3515a the
|
|
|
7a3408 |
bitmap returned from virProcessGetAffinity is too big to be formatted
|
|
|
7a3408 |
properly via RPC. A user would get the following error:
|
|
|
7a3408 |
|
|
|
7a3408 |
error: Unable to get domain IOThreads information
|
|
|
7a3408 |
error: Unable to encode message payload
|
|
|
7a3408 |
|
|
|
7a3408 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1238589
|
|
|
7a3408 |
(cherry picked from commit e8c5f61e91025f244bb022b1774a3fc6484625f8)
|
|
|
7a3408 |
|
|
|
7a3408 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
7a3408 |
---
|
|
|
7a3408 |
src/util/virbitmap.c | 7 +++++--
|
|
|
7a3408 |
1 file changed, 5 insertions(+), 2 deletions(-)
|
|
|
7a3408 |
|
|
|
7a3408 |
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
|
|
|
7a3408 |
index 9abc807..4d270a9 100644
|
|
|
7a3408 |
--- a/src/util/virbitmap.c
|
|
|
7a3408 |
+++ b/src/util/virbitmap.c
|
|
|
7a3408 |
@@ -498,9 +498,12 @@ virBitmapPtr virBitmapNewData(void *data, int len)
|
|
|
7a3408 |
*/
|
|
|
7a3408 |
int virBitmapToData(virBitmapPtr bitmap, unsigned char **data, int *dataLen)
|
|
|
7a3408 |
{
|
|
|
7a3408 |
- int len;
|
|
|
7a3408 |
+ ssize_t len;
|
|
|
7a3408 |
|
|
|
7a3408 |
- len = (bitmap->max_bit + CHAR_BIT - 1) / CHAR_BIT;
|
|
|
7a3408 |
+ if ((len = virBitmapLastSetBit(bitmap)) < 0)
|
|
|
7a3408 |
+ len = 1;
|
|
|
7a3408 |
+ else
|
|
|
7a3408 |
+ len = (len + CHAR_BIT) / CHAR_BIT;
|
|
|
7a3408 |
|
|
|
7a3408 |
if (VIR_ALLOC_N(*data, len) < 0)
|
|
|
7a3408 |
return -1;
|
|
|
7a3408 |
--
|
|
|
7a3408 |
2.4.5
|
|
|
7a3408 |
|