Francesco Romani has uploaded a new change for review.

Change subject: takset: fix taskset.get() on python 2.6
......................................................................

takset: fix taskset.get() on python 2.6

In python 2.6 we don't have int.bit_length(),
so we need to workaround it to make taskset.get() work.

This mistake gone unnoticed because:
- the rpm build step still doesn't run tests, so deploy on EL6
  was succesfull
- the taskset.get() function is used only in tests, and the
  real production code actually works.

Change-Id: I7621a1443367bfead7b953df5218dea24bf8095a
Label: ovirt-3.5-only
Bug-Url: https://bugzilla.redhat.com/1265205
Related-To: https://bugzilla.redhat.com/1247075
Signed-off-by: Francesco Romani <[email protected]>
---
M lib/vdsm/taskset.py
1 file changed, 9 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/13/47013/1

diff --git a/lib/vdsm/taskset.py b/lib/vdsm/taskset.py
index 3ec2987..bc7aea3 100644
--- a/lib/vdsm/taskset.py
+++ b/lib/vdsm/taskset.py
@@ -83,4 +83,12 @@
     """
     hexmask = line.rsplit(":", 1)[1].strip()
     mask = int(hexmask, 16)
-    return frozenset(i for i in range(mask.bit_length()) if mask & (1 << i))
+    return frozenset(i for i in range(_bit_length(mask)) if mask & (1 << i))
+
+
+# stolen with minimal changes from
+# https://docs.python.org/2/library/stdtypes.html#int.bit_length
+def _bit_length(n):
+    s = bin(n)          # binary representation:  bin(-37) --> '-0b100101'
+    s = s.lstrip('-0b') # remove leading zeros and minus sign
+    return len(s)       # len('100101') --> 6


-- 
To view, visit https://gerrit.ovirt.org/47013
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7621a1443367bfead7b953df5218dea24bf8095a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-3.5
Gerrit-Owner: Francesco Romani <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to