9119d9
From 2c3dba741df506af7a46f43ddff856a975b794dd Mon Sep 17 00:00:00 2001
9119d9
Message-Id: <2c3dba741df506af7a46f43ddff856a975b794dd@dist-git>
9119d9
From: Jincheng Miao <jmiao@redhat.com>
9119d9
Date: Wed, 15 Oct 2014 12:11:13 +0200
9119d9
Subject: [PATCH] nodeinfo: fix nodeGetFreePages when max node is zero
9119d9
9119d9
https://bugzilla.redhat.com/show_bug.cgi?id=1145048
9119d9
9119d9
In nodeGetFreePages, if startCell is given by '0',
9119d9
and the max node number is '0' too. The for-loop
9119d9
wouldn't be executed.
9119d9
So convert it to while-loop.
9119d9
9119d9
Before:
9119d9
> virsh freepages --cellno 0 --pagesize 4
9119d9
error: internal error: no suitable info found
9119d9
9119d9
After:
9119d9
> virsh freepages --cellno 0 --pagesize 4
9119d9
4KiB: 472637
9119d9
9119d9
Signed-off-by: Jincheng Miao <jmiao@redhat.com>
9119d9
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9119d9
(cherry picked from commit 8baf0f025f975267e3f9a3af71f69137130907b7)
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
---
9119d9
 src/nodeinfo.c | 2 +-
9119d9
 1 file changed, 1 insertion(+), 1 deletion(-)
9119d9
9119d9
diff --git a/src/nodeinfo.c b/src/nodeinfo.c
9119d9
index 80c723e..dfde085 100644
9119d9
--- a/src/nodeinfo.c
9119d9
+++ b/src/nodeinfo.c
9119d9
@@ -2047,7 +2047,7 @@ nodeGetFreePages(unsigned int npages,
9119d9
 
9119d9
     lastCell = MIN(lastCell, startCell + cellCount);
9119d9
 
9119d9
-    for (cell = startCell; cell < lastCell; cell++) {
9119d9
+    for (cell = startCell; cell <= lastCell; cell++) {
9119d9
         for (i = 0; i < npages; i++) {
9119d9
             unsigned int page_size = pages[i];
9119d9
             unsigned int page_free;
9119d9
-- 
9119d9
2.1.3
9119d9