From: Jan Kiszka <[email protected]> Creates a simple set of CPU numbers from the cell configuration. This will be used by the config checker for exhaustion and overlap checks.
Signed-off-by: Jan Kiszka <[email protected]> --- pyjailhouse/config_parser.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pyjailhouse/config_parser.py b/pyjailhouse/config_parser.py index 2a59b651..be0c749e 100644 --- a/pyjailhouse/config_parser.py +++ b/pyjailhouse/config_parser.py @@ -180,8 +180,16 @@ class CellConfig: self.name = str(name.decode().strip('\0')) self.arch = convert_arch(self.arch) - mem_region_offs = struct.calcsize(CellConfig._HEADER_FORMAT) + \ - self.cpu_set_size + cpu_set_offs = struct.calcsize(CellConfig._HEADER_FORMAT) + mask_array = struct.unpack_from('%dB' % self.cpu_set_size, + self.data[cpu_set_offs:]) + self.cpus = set() + for n in range(self.cpu_set_size): + for bit in range(8): + if mask_array[n] & (1 << bit) != 0: + self.cpus.add(n * 8 + bit) + + mem_region_offs = cpu_set_offs + self.cpu_set_size self.memory_regions = [] for n in range(self.num_memory_regions): self.memory_regions.append( -- 2.35.3 -- You received this message because you are subscribed to the Google Groups "Jailhouse" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jailhouse-dev/3c759dbcae3449a2f4e1df52616dda2220ac69fd.1674415741.git.jan.kiszka%40siemens.com.
