]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
nodeinfo: fix nodeGetFreePages when max node is zero
authorJincheng Miao <jmiao@redhat.com>
Wed, 24 Sep 2014 05:45:30 +0000 (13:45 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 24 Sep 2014 11:33:43 +0000 (13:33 +0200)
In nodeGetFreePages, if startCell is given by '0',
and the max node number is '0' too. The for-loop
wouldn't be executed.
So convert it to while-loop.

Before:
> virsh freepages --cellno 0 --pagesize 4
error: internal error: no suitable info found

After:
> virsh freepages --cellno 0 --pagesize 4
4KiB: 472637

Signed-off-by: Jincheng Miao <jmiao@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/nodeinfo.c

index 245992275d7909ffe5a5d674642e2e110795b27c..04ae38223e1edb3a3db6e2136a2af8cd8103f3ce 100644 (file)
@@ -2043,7 +2043,7 @@ nodeGetFreePages(unsigned int npages,
 
     lastCell = MIN(lastCell, startCell + cellCount);
 
-    for (cell = startCell; cell < lastCell; cell++) {
+    for (cell = startCell; cell <= lastCell; cell++) {
         for (i = 0; i < npages; i++) {
             unsigned int page_size = pages[i];
             unsigned int page_free;