[PATCH 2/2] virDomainFormatSchedDef: Check @schedMap bounds

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In the function, @schedMap is a bitmap used to track pinning of
scheduling units (e.g. vcpu, iothreads). However, as a corner
case it may happen that it's empty but the scheduler is set to
either RR or FIFO. If that's the case we may get -1 when asking
for the next bit set in @schedMap and proceed with that. The code
is able to deal with that because we are ignoring some errors
afterwards, but it's safer to check upfront.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 67415fa..a842ee4 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -21485,20 +21485,21 @@ virDomainFormatSchedDef(virDomainDefPtr def,
             case VIR_PROC_POLICY_FIFO:
             case VIR_PROC_POLICY_RR:
                 virBitmapClearAll(prioMap);
-                hasPriority = true;
 
                 /* we need to find a subset of vCPUs with the given scheduler
                  * that share the priority */
-                nextprio = virBitmapNextSetBit(schedMap, -1);
-                sched = func(def, nextprio);
-                priority = sched->priority;
-
-                ignore_value(virBitmapSetBit(prioMap, nextprio));
-
-                while ((nextprio = virBitmapNextSetBit(schedMap, nextprio)) > -1) {
+                if ((nextprio = virBitmapNextSetBit(schedMap, -1)) > -1) {
                     sched = func(def, nextprio);
-                    if (sched->priority == priority)
-                        ignore_value(virBitmapSetBit(prioMap, nextprio));
+                    priority = sched->priority;
+                    hasPriority = true;
+
+                    ignore_value(virBitmapSetBit(prioMap, nextprio));
+
+                    while ((nextprio = virBitmapNextSetBit(schedMap, nextprio)) > -1) {
+                        sched = func(def, nextprio);
+                        if (sched->priority == priority)
+                            ignore_value(virBitmapSetBit(prioMap, nextprio));
+                    }
                 }
 
                 currentMap = prioMap;
-- 
2.4.10

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]