
When using kimchi inside a virtual machine it's possible to get a ZeroDivisionError exception because self.sockets is 0, so the division self.cores_per_socket = self.cores_present/self.sockets will fail. In this case, self.sockets is 0 because cores_present = 1 and threads_per_core = 4, which will truncate 0.25 to 0 during the integer division. This is a low priority corner case since kimchi is obviously not supposed to run under a virtual machine but for a plugin development, which will not use any virtualization capability, it might become handy. Signed-off-by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com> --- src/kimchi/model/cpuinfo.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/kimchi/model/cpuinfo.py b/src/kimchi/model/cpuinfo.py index 3411ef5..d063425 100644 --- a/src/kimchi/model/cpuinfo.py +++ b/src/kimchi/model/cpuinfo.py @@ -84,6 +84,8 @@ class CPUInfoModel(object): if not rc: self.threads_per_core = int(out.split()[-1]) self.sockets = self.cores_present/self.threads_per_core + if self.sockets == 0: + self.sockets = 1 self.cores_per_socket = self.cores_present/self.sockets else: # Intel or AMD -- 1.9.1