mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-06-09 02:24:45 +00:00
acrn-config: support to parse pci_devs for pre launched vm
As it doesn't depends on the scenario, there are sos/pre launched VMS in config xmls, emulate vhostbridge for sos vm, specify the pass-thru PCI device for pre launched vm. Add support to parse pci_devs for pre launched vm. Tracked-On: #4641 Signed-off-by: Wei Liu <weix.w.liu@intel.com> Acked-by: Victor Sun <victor.sun@intel.com> Acked-by: Terry Zou <terry.zou@intel.com>
This commit is contained in:
@@ -9,7 +9,7 @@ import scenario_cfg_lib
|
||||
PCI_DEV_TYPE = ['PCI_DEV_TYPE_HVEMUL', 'PCI_DEV_TYPE_PTDEV']
|
||||
|
||||
|
||||
def generate_file(config):
|
||||
def generate_file(vm_info, config):
|
||||
"""
|
||||
Generate pci_dev.c while logical_partition scenario
|
||||
:param config: it is pointer for for file write to
|
||||
@@ -29,27 +29,31 @@ def generate_file(config):
|
||||
print(" * The memory range of vBAR should exactly match with the e820 layout of VM.",
|
||||
file=config)
|
||||
print(" */", file=config)
|
||||
for i in list(common.VM_TYPES.keys()):
|
||||
for vm_i, pci_bdf_devs_list in vm_info.cfg_pci.pci_devs.items():
|
||||
pci_cnt = 1
|
||||
if not pci_bdf_devs_list:
|
||||
continue
|
||||
|
||||
print("", file=config)
|
||||
print("struct acrn_vm_pci_dev_config " +
|
||||
"vm{}_pci_devs[VM{}_CONFIG_PCI_DEV_NUM] = {{".format(i, i), file=config)
|
||||
"vm{}_pci_devs[{}] = {{".format(vm_i, vm_info.cfg_pci.pci_dev_num[vm_i]), file=config)
|
||||
print("\t{", file=config)
|
||||
print("\t\t.emu_type = {},".format(PCI_DEV_TYPE[0]), file=config)
|
||||
print("\t\t.vbdf.bits = {.b = 0x00U, .d = 0x00U, .f = 0x00U},", file=config)
|
||||
print("\t\t.vdev_ops = &vhostbridge_ops,", file=config)
|
||||
print("\t},", file=config)
|
||||
print("\t{", file=config)
|
||||
print("\t\t.emu_type = {},".format(PCI_DEV_TYPE[1]), file=config)
|
||||
print("\t\t.vbdf.bits = {.b = 0x00U, .d = 0x01U, .f = 0x00U},", file=config)
|
||||
print("\t\tVM{}_STORAGE_CONTROLLER".format(i), file=config)
|
||||
print("\t},", file=config)
|
||||
if i != 0:
|
||||
print("#if defined(VM{}_NETWORK_CONTROLLER)".format(i), file=config)
|
||||
print("\t{", file=config)
|
||||
print("\t\t.emu_type = {},".format(PCI_DEV_TYPE[1]), file=config)
|
||||
print("\t\t.vbdf.bits = {.b = 0x00U, .d = 0x02U, .f = 0x00U},", file=config)
|
||||
print("\t\tVM{}_NETWORK_CONTROLLER".format(i), file=config)
|
||||
print("\t},", file=config)
|
||||
if i != 0:
|
||||
print("#endif", file=config)
|
||||
|
||||
for pci_bdf_dev in pci_bdf_devs_list:
|
||||
if not pci_bdf_dev:
|
||||
continue
|
||||
bus = int(pci_bdf_dev.split(':')[0], 16)
|
||||
dev = int(pci_bdf_dev.split(':')[1].split('.')[0], 16)
|
||||
fun = int(pci_bdf_dev.split('.')[1], 16)
|
||||
print("\t{", file=config)
|
||||
print("\t\t.emu_type = {},".format(PCI_DEV_TYPE[1]), file=config)
|
||||
print("\t\t.vbdf.bits = {{.b = 0x00U, .d = 0x0{}U, .f = 0x00U}},".format(pci_cnt), file=config)
|
||||
print("\t\t.pbdf.bits = {{.b = 0x{:02X}U, .d = 0x{:02X}U, .f = 0x{:02X}U}},".format(bus, dev, fun), file=config)
|
||||
print("\t},", file=config)
|
||||
pci_cnt += 1
|
||||
|
||||
print("};", file=config)
|
||||
|
||||
Reference in New Issue
Block a user