Move lines with similar context together and add some comments. This commit serves also as a preparation for the following commit.
No functional change. Signed-off-by: Andrej Utz <[email protected]> --- tools/jailhouse-config-create | 80 ++++++++++++++++------------------- 1 file changed, 36 insertions(+), 44 deletions(-) diff --git a/tools/jailhouse-config-create b/tools/jailhouse-config-create index 1e2df742..709cf2ef 100755 --- a/tools/jailhouse-config-create +++ b/tools/jailhouse-config-create @@ -240,41 +240,43 @@ if jh_enabled == '1': file=sys.stderr) sys.exit(1) -IOAPIC_MAX_PINS = 120 -int_src_count = IOAPIC_MAX_PINS - -(pcidevices, pcicaps, cnt) = sysfs_parser.parse_pcidevices() - -int_src_count += cnt -vtd_interrupt_limit = 2**math.ceil(math.log(int_src_count, 2)) - -product = [input_readline('/sys/class/dmi/id/sys_vendor', - True).rstrip(), - input_readline('/sys/class/dmi/id/product_name', - True).rstrip() - ] - -inmatemem = kmg_multiply_str(options.mem_inmates) -hvmem = [0, kmg_multiply_str(options.mem_hv)] - -(mem_regions, dmar_regions) = sysfs_parser.parse_iomem(pcidevices) -ourmem = parse_kernel_cmdline() -total = hvmem[1] + inmatemem +# Information collection +######################### +debug_console = DebugConsole(options.console) +# System infromation +product = [ + input_readline('/sys/class/dmi/id/sys_vendor', True).rstrip(), + input_readline('/sys/class/dmi/id/product_name', True).rstrip(), +] +cpu_count = count_cpus() mmconfig = MMConfig.parse() +# Query devices +(pci_devices, pci_caps, int_src_count) = sysfs_parser.parse_pcidevices() +(mem_regions, dmar_regions) = sysfs_parser.parse_iomem(pci_devices) +(port_regions, pm_timer_base) = sysfs_parser.parse_ioports() ioapics = sysfs_parser.parse_madt() - vendor = sysfs_parser.get_cpu_vendor() if vendor == 'GenuineIntel': - (iommu_units, extra_memregs) = sysfs_parser.parse_dmar(pcidevices, ioapics, + (iommu_units, extra_memregs) = sysfs_parser.parse_dmar(pci_devices, ioapics, dmar_regions) else: - (iommu_units, extra_memregs) = sysfs_parser.parse_ivrs(pcidevices, ioapics) + (iommu_units, extra_memregs) = sysfs_parser.parse_ivrs(pci_devices, ioapics) mem_regions += extra_memregs -# kernel does not have memmap region, pick one +IOAPIC_MAX_PINS = 120 +int_src_count += IOAPIC_MAX_PINS +vtd_interrupt_limit = 2**math.ceil(math.log(int_src_count, 2)) + +# Determine hypervisor memory +inmatemem = kmg_multiply_str(options.mem_inmates) +hvmem = [0, kmg_multiply_str(options.mem_hv)] +total = hvmem[1] + inmatemem + +ourmem = parse_kernel_cmdline() if ourmem is None: + # kernel does not have memmap region, pick one ourmem = alloc_mem(mem_regions, total) elif (total > ourmem[1]): raise RuntimeError('Your memmap reservation is too small you need >="' + @@ -282,22 +284,10 @@ elif (total > ourmem[1]): '"memmap=' + hex(total) + '$' + hex(ourmem[0]) + '"') hvmem[0] = ourmem[0] +mem_regions.append(sysfs_parser.MemRegion(ourmem[0] + hvmem[1], + ourmem[0] + hvmem[1] + inmatemem - 1, + 'JAILHOUSE Inmate Memory')) -inmatereg = sysfs_parser.MemRegion(ourmem[0] + hvmem[1], - ourmem[0] + hvmem[1] + inmatemem - 1, - 'JAILHOUSE Inmate Memory') -mem_regions.append(inmatereg) - -cpucount = count_cpus() - -port_regions, pm_timer_base = sysfs_parser.parse_ioports() - -debug_console = DebugConsole(options.console) - - -f = open(options.file, 'w') -tmpl = Template(filename=os.path.join(options.template_dir, - 'root-cell-config.c.tmpl')) kwargs = { 'mem_regions': mem_regions, 'port_regions': port_regions, @@ -305,9 +295,9 @@ kwargs = { 'argstr': ' '.join(sys.argv), 'hvmem': hvmem, 'product': product, - 'pcidevices': pcidevices, - 'pcicaps': pcicaps, - 'cpucount': cpucount, + 'pcidevices': pci_devices, + 'pcicaps': pci_caps, + 'cpucount': cpu_count, 'irqchips': ioapics, 'pm_timer_base': pm_timer_base, 'vtd_interrupt_limit': vtd_interrupt_limit, @@ -316,6 +306,8 @@ kwargs = { 'debug_console': debug_console, } -f.write(tmpl.render(**kwargs)) +tmpl = Template(filename=os.path.join(options.template_dir, + 'root-cell-config.c.tmpl')) -f.close() +with open(options.file, 'w') as f: + f.write(tmpl.render(**kwargs)) -- 2.27.0 -- 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/20200609131143.2133316-1-andrej.utz%40st.oth-regensburg.de.
