Re: [PATCH 3/5] acrn-config: support to parse pci_devs for pre launched vm


Zou, Terry
 

Acked-by: Terry Zou <terry.zou@...>

-----Original Message-----
From: Liu, WeiX W <weix.w.liu@...>
Sent: Thursday, April 16, 2020 4:56 PM
To: acrn-dev@...
Cc: Wu, Binbin <binbin.wu@...>; Sun, Victor <victor.sun@...>; Zou, Terry <terry.zou@...>
Subject: [PATCH 3/5] 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.

Signed-off-by: Wei Liu <weix.w.liu@...>
---
misc/acrn-config/launch_config/launch_item.py | 24 ++--
misc/acrn-config/library/common.py | 24 +++-
misc/acrn-config/library/launch_cfg_lib.py | 12 --
misc/acrn-config/library/scenario_cfg_lib.py | 117 +++++++++++++----- misc/acrn-config/scenario_config/pci_dev_c.py | 38 +++---
.../scenario_config/scenario_cfg_gen.py | 3 +-
.../scenario_config/scenario_item.py | 19 ++-
.../scenario_config/vm_configurations_c.py | 15 ++-
8 files changed, 166 insertions(+), 86 deletions(-)

diff --git a/misc/acrn-config/launch_config/launch_item.py b/misc/acrn-config/launch_config/launch_item.py
index 29e19c68..cdacb4ba 100644
--- a/misc/acrn-config/launch_config/launch_item.py
+++ b/misc/acrn-config/launch_config/launch_item.py
@@ -49,18 +49,18 @@ class AvailablePthru():
return self.bdf_vpid_map

def get_pci_dev(self):
- self.avl["usb_xdci"] = launch_cfg_lib.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['usb_xdci'])
- self.avl["ipu"] = launch_cfg_lib.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['ipu'])
- self.avl["ipu_i2c"] = launch_cfg_lib.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['ipu_i2c'])
- self.avl["cse"] = launch_cfg_lib.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['cse'])
- self.avl["audio"] = launch_cfg_lib.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['audio'])
- self.avl["audio_codec"] = launch_cfg_lib.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['audio_codec'])
- self.avl["sd_card"] = launch_cfg_lib.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['sd_card'])
- self.avl["wifi"] = launch_cfg_lib.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['wifi'])
- self.avl["ethernet"] = launch_cfg_lib.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['ethernet'])
- self.avl["sata"] = launch_cfg_lib.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['sata'])
- self.avl["nvme"] = launch_cfg_lib.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['nvme'])
- self.avl["bluetooth"] = launch_cfg_lib.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['bluetooth'])
+ self.avl["usb_xdci"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['usb_xdci'])
+ self.avl["ipu"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['ipu'])
+ self.avl["ipu_i2c"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['ipu_i2c'])
+ self.avl["cse"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['cse'])
+ self.avl["audio"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['audio'])
+ self.avl["audio_codec"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['audio_codec'])
+ self.avl["sd_card"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['sd_card'])
+ self.avl["wifi"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['wifi'])
+ self.avl["ethernet"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['ethernet'])
+ self.avl["sata"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['sata'])
+ self.avl["nvme"] = common.get_avl_dev_info(self.bdf_desc_map, launch_cfg_lib.PT_SUB_PCI['nvme'])
+ self.avl["bluetooth"] =
+ common.get_avl_dev_info(self.bdf_desc_map,
+ launch_cfg_lib.PT_SUB_PCI['bluetooth'])

def insert_nun(self):
self.avl["usb_xdci"].insert(0, '') diff --git a/misc/acrn-config/library/common.py b/misc/acrn-config/library/common.py
index 058b607e..2b503ade 100644
--- a/misc/acrn-config/library/common.py
+++ b/misc/acrn-config/library/common.py
@@ -19,7 +19,7 @@ PY_CACHES = ["__pycache__", "../board_config/__pycache__", "../scenario_config/_ GUEST_FLAG = ["0UL", "GUEST_FLAG_SECURE_WORLD_ENABLED", "GUEST_FLAG_LAPIC_PASSTHROUGH",
"GUEST_FLAG_IO_COMPLETION_POLLING", "GUEST_FLAG_HIDE_MTRR", "GUEST_FLAG_RT"]

-MULTI_ITEM = ["guest_flag", "pcpu_id", "vcpu_clos", "input", "block", "network"]
+MULTI_ITEM = ["guest_flag", "pcpu_id", "vcpu_clos", "input", "block",
+"network", "pci_dev"]

SIZE_K = 1024
SIZE_M = SIZE_K * 1024
@@ -43,6 +43,7 @@ class MultiItem():
self.vir_block = []
self.vir_console = []
self.vir_network = []
+ self.pci_dev = []

class TmpItem():

@@ -255,7 +256,6 @@ def get_leaf_value(tmp, tag_str, leaf):
# get guest flag for logical partition vm1
if leaf.tag == "guest_flag" and tag_str == "guest_flag":
t_flag = find_tmp_flag(leaf.text)
- #print("--debug: tag:{},{}".format(tag_str), t_flag)
tmp.multi.guest_flag.append(t_flag)

# get cpu for vm
@@ -278,6 +278,10 @@ def get_leaf_value(tmp, tag_str, leaf):
if leaf.tag == "network" and tag_str == "network":
tmp.multi.vir_network.append(leaf.text)

+ # get pci_dev for vm
+ if leaf.tag == "pci_dev" and tag_str == "pci_dev":
+ tmp.multi.pci_dev.append(leaf.text)
+

def get_sub_value(tmp, tag_str, vm_id):

@@ -305,6 +309,10 @@ def get_sub_value(tmp, tag_str, vm_id):
if tmp.multi.vir_network and tag_str == "network":
tmp.tag[vm_id] = tmp.multi.vir_network

+ # append pci_dev for vm
+ if tmp.multi.pci_dev and tag_str == "pci_dev":
+ tmp.tag[vm_id] = tmp.multi.pci_dev
+

def get_leaf_tag_map(config_file, branch_tag, tag_str=''):
"""
@@ -421,3 +429,15 @@ def num2int(str_value):
def get_vm_types():
global VM_TYPES
VM_TYPES = get_leaf_tag_map(SCENARIO_INFO_FILE, "load_order")
+
+
+def get_avl_dev_info(bdf_desc_map, pci_sub_class):
+
+ tmp_pci_desc = []
+ for sub_class in pci_sub_class:
+ for pci_desc_value in bdf_desc_map.values():
+ pci_desc_sub_class = ' '.join(pci_desc_value.strip().split(':')[1].split()[1:])
+ if sub_class == pci_desc_sub_class:
+ tmp_pci_desc.append(pci_desc_value.strip())
+
+ return tmp_pci_desc
diff --git a/misc/acrn-config/library/launch_cfg_lib.py b/misc/acrn-config/library/launch_cfg_lib.py
index 82cb7cb9..a9df3de8 100644
--- a/misc/acrn-config/library/launch_cfg_lib.py
+++ b/misc/acrn-config/library/launch_cfg_lib.py
@@ -184,18 +184,6 @@ def get_post_vm_cnt():
return (launch_vm_count, post_vm_count)


-def get_avl_dev_info(bdf_desc_map, pci_sub_class):
-
- tmp_pci_desc = []
- for sub_class in pci_sub_class:
- for pci_desc_value in bdf_desc_map.values():
- pci_desc_sub_class = ' '.join(pci_desc_value.strip().split(':')[1].split()[1:])
- if sub_class == pci_desc_sub_class:
- tmp_pci_desc.append(pci_desc_value.strip())
-
- return tmp_pci_desc
-
-
def is_config_file_match():

match = True
diff --git a/misc/acrn-config/library/scenario_cfg_lib.py b/misc/acrn-config/library/scenario_cfg_lib.py
index f4fa3f37..81dc57fb 100644
--- a/misc/acrn-config/library/scenario_cfg_lib.py
+++ b/misc/acrn-config/library/scenario_cfg_lib.py
@@ -25,8 +25,6 @@ AVALIBLE_COM2_BASE = ['INVALID_COM_BASE', 'COM2_BASE'] VUART_IRQ = ['SOS_COM1_IRQ', 'SOS_COM2_IRQ', 'COM1_IRQ', 'COM2_IRQ', 'COM3_IRQ',
'COM4_IRQ', 'CONFIG_COM_IRQ', '3', '4', '6', '7']

-PCI_DEV_NUM_LIST = ['SOS_EMULATED_PCI_DEV_NUM', 'VM0_CONFIG_PCI_DEV_NUM', 'VM1_CONFIG_PCI_DEV_NUM'] -PCI_DEVS_LIST = ['sos_pci_devs', 'vm0_pci_devs', 'vm1_pci_devs'] # Support 512M, 1G, 2G # pre launch less then 2G, sos vm less than 24G START_HPA_SIZE_LIST = ['0x20000000', '0x40000000', '0x80000000', 'CONFIG_SOS_RAM_SIZE'] @@ -36,6 +34,43 @@ COMMUNICATE_VM_ID = [] ERR_LIST = {}

KATA_VM_COUNT = 0
+PT_SUB_PCI = {}
+PT_SUB_PCI['ethernet'] = ['Ethernet controller', 'Network controller', '802.1a controller',
+ '802.1b controller', 'Wireless controller']
+PT_SUB_PCI['sata'] = ['SATA controller'] PT_SUB_PCI['nvme'] =
+['Non-Volatile memory controller']
+
+
+def get_pci_devs(pci_items):
+
+ pci_devs = {}
+ for vm_i,pci_descs in pci_items.items():
+ bdf_list = []
+ for pci_des in pci_descs:
+ if not pci_des:
+ continue
+ bdf = pci_des.split()[0]
+ bdf_list.append(bdf)
+
+ pci_devs[vm_i] = bdf_list
+
+ return pci_devs
+
+
+def get_pci_num(pci_devs):
+
+ pci_devs_num = {}
+ for vm_i,pci_devs_list in pci_devs.items():
+ # vhostbridge
+ cnt_dev = 1
+ for pci_dev in pci_devs_list:
+ if not pci_dev:
+ continue
+ cnt_dev += 1
+
+ pci_devs_num[vm_i] = cnt_dev
+
+ return pci_devs_num


def check_board_private_info():
@@ -362,37 +397,18 @@ def os_kern_root_dev_check(id_kern_rootdev_dic, prime_item, item):
ERR_LIST[key] = "VM os config kernel root device should not empty"


-def pci_dev_num_check(id_dev_num_dic, item):
- """
- Check vm pci device number
- :param item: vm pci_dev_num item in xml
- :return: None
- """
-
- for vm_i,vm_type in common.VM_TYPES.items():
- if vm_i not in id_dev_num_dic.keys():
- continue
- pci_dev_num = id_dev_num_dic[vm_i]
- if vm_type != "POST_LAUNCHED_VM" and pci_dev_num:
- if pci_dev_num not in PCI_DEV_NUM_LIST:
- key = "vm:id={},{}".format(vm_i, item)
- ERR_LIST[key] = "VM pci device number shoud be one of {}".format(PCI_DEV_NUM_LIST)
-
-def pci_devs_check(id_devs_dic, item):
+def pci_devs_check(pci_bdf_devs, branch_tag, tag_str):
"""
Check vm pci devices
:param item: vm pci_devs item in xml
:return: None
"""
-
- for vm_i,vm_type in common.VM_TYPES.items():
- if vm_i not in id_devs_dic.keys():
- continue
- pci_dev = id_devs_dic[vm_i]
- if vm_type != "POST_LAUNCHED_VM" and pci_dev:
- if pci_dev not in PCI_DEVS_LIST:
- key = "vm:id={},{}".format(vm_i, item)
- ERR_LIST[key] = "VM pci device shoud be one of {}".format(PCI_DEVS_LIST)
+ (bdf_desc_map, bdf_vpid_map) = board_cfg_lib.get_pci_info(common.BOARD_INFO_FILE)
+ for id_key, pci_bdf_devs_list in pci_bdf_devs.items():
+ for pci_bdf_dev in pci_bdf_devs_list:
+ if pci_bdf_dev and pci_bdf_dev not in bdf_desc_map.keys():
+ key = "vm:id={},{},{}".format(id_key, branch_tag, tag_str)
+ ERR_LIST[key] = "The {} is unkonw device of
+ PCI".format(pci_bdf_dev)


def get_vuart1_vmid(vm_vuart1):
@@ -497,3 +513,48 @@ def get_first_post_vm():
break

return (err_dic, i)
+
+
+def avl_pci_devs():
+
+ pci_dev_list = []
+ (bdf_desc_map, bdf_vpid_map) = board_cfg_lib.get_pci_info(common.BOARD_INFO_FILE)
+ pci_dev_list = common.get_avl_dev_info(bdf_desc_map, PT_SUB_PCI['ethernet'])
+ tmp_pci_list = common.get_avl_dev_info(bdf_desc_map, PT_SUB_PCI['sata'])
+ pci_dev_list.extend(tmp_pci_list)
+ tmp_pci_list = common.get_avl_dev_info(bdf_desc_map, PT_SUB_PCI['nvme'])
+ pci_dev_list.extend(tmp_pci_list)
+
+ return pci_dev_list
+
+
+def check_vuart(v0_vuart, v1_vuart):
+
+ vm_target_id_dic = {}
+ for vm_i,vuart_dic in v1_vuart.items():
+ # check target vm id
+ if 'base' not in vuart_dic.keys():
+ key = "vm:id={},vuart:id=1,base".format(vm_i)
+ ERR_LIST[key] = "base should be in xml"
+ return
+
+ if not vuart_dic['base'] or vuart_dic['base'] not in VUART_BASE:
+ key = "vm:id={},vuart:id=1,base".format(vm_i)
+ ERR_LIST[key] = "base should be SOS/COM BASE"
+
+ if vuart_dic['base'] == "INVALID_COM_BASE":
+ continue
+
+ if 'target_vm_id' not in vuart_dic.keys():
+ key = "vm:id={},vuart:id=1,target_vm_id".format(vm_i)
+ ERR_LIST[key] = "target_vm_id should be in xml"
+
+ if not vuart_dic['target_vm_id'] or not vuart_dic['target_vm_id'].isnumeric():
+ key = "vm:id={},vuart:id=1,target_vm_id".format(vm_i)
+ ERR_LIST[key] = "target_vm_id should be numeric of vm id"
+ vm_target_id_dic[vm_i] = vuart_dic['target_vm_id']
+
+ for vm_i,t_vm_id in vm_target_id_dic.items():
+ if t_vm_id.isnumeric() and int(t_vm_id) not in common.VM_TYPES.keys():
+ key = "vm:id={},vuart:id=1,target_vm_id".format(vm_i)
+ ERR_LIST[key] = "target_vm_id which specified does not exist"
diff --git a/misc/acrn-config/scenario_config/pci_dev_c.py b/misc/acrn-config/scenario_config/pci_dev_c.py
index f4eafffb..f6629b0b 100644
--- a/misc/acrn-config/scenario_config/pci_dev_c.py
+++ b/misc/acrn-config/scenario_config/pci_dev_c.py
@@ -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)
diff --git a/misc/acrn-config/scenario_config/scenario_cfg_gen.py b/misc/acrn-config/scenario_config/scenario_cfg_gen.py
index 9896c40e..da6f7384 100755
--- a/misc/acrn-config/scenario_config/scenario_cfg_gen.py
+++ b/misc/acrn-config/scenario_config/scenario_cfg_gen.py
@@ -47,6 +47,7 @@ def get_scenario_item_values(board_info, scenario_info):
scenario_item_values["vm,guest_flags"] = guest_flags
scenario_item_values["vm,clos"] = hw_info.get_clos_val()
scenario_item_values["vm,severity"] = scenario_cfg_lib.VM_SEVERITY
+ scenario_item_values["vm,pci_devs,pci_dev"] =
+ scenario_cfg_lib.avl_pci_devs()
scenario_item_values["vm,os_config,kern_type"] = scenario_cfg_lib.KERN_TYPE_LIST
scenario_item_values.update(scenario_cfg_lib.avl_vuart_ui_select(scenario_info))

@@ -187,7 +188,7 @@ def main(args):
# generate pci_dev.c
if scenario_items['vm'].load_order_cnt.pre_vm >= 2:
with open(pci_config_c, 'w') as config:
- pci_dev_c.generate_file(config)
+ pci_dev_c.generate_file(scenario_items['vm'], config)

if not err_dic:
print("Scenario configurations for {} is generated successfully.".format(scenario)) diff --git a/misc/acrn-config/scenario_config/scenario_item.py b/misc/acrn-config/scenario_config/scenario_item.py
index 6a7d149c..bb7ab08a 100644
--- a/misc/acrn-config/scenario_config/scenario_item.py
+++ b/misc/acrn-config/scenario_config/scenario_item.py
@@ -142,8 +142,14 @@ class VuartInfo:
"""
self.v0_vuart = board_cfg_lib.get_vuart_info_id(self.scenario_info, 0)
self.v1_vuart = board_cfg_lib.get_vuart_info_id(self.scenario_info, 1)
- scenario_cfg_lib.check_board_private_info()

+ def check_item(self):
+ """
+ Check all items in this class
+ :return: None
+ """
+ scenario_cfg_lib.check_board_private_info()
+ scenario_cfg_lib.check_vuart(self.v0_vuart, self.v1_vuart)

class MemInfo:
""" This is Abstract of class of memory setting information """
@@ -193,14 +199,15 @@ class CfgPci:
Get pci device number items
:return: None
"""
- self.pci_dev_num = common.get_leaf_tag_map(self.scenario_info, "pci_dev_num")
+ self.pci_dev_num = scenario_cfg_lib.get_pci_num(self.pci_devs)

def get_pci_devs(self):
"""
Get pci devices items
:return: None
"""
- self.pci_devs = common.get_leaf_tag_map(self.scenario_info, "pci_devs")
+ pci_items = common.get_leaf_tag_map(self.scenario_info, "pci_devs", "pci_dev")
+ self.pci_devs = scenario_cfg_lib.get_pci_devs(pci_items)


def get_info(self):
@@ -208,15 +215,14 @@ class CfgPci:
Get all items which belong to this class
:return: None
"""
- self.get_pci_dev_num()
self.get_pci_devs()
+ self.get_pci_dev_num()

def check_item(self):
""" Check all items in this class
:return: None
"""
- scenario_cfg_lib.pci_dev_num_check(self.pci_dev_num, "pci_dev_num")
- scenario_cfg_lib.pci_devs_check(self.pci_devs, "pci_devs")
+ scenario_cfg_lib.pci_devs_check(self.pci_devs, "pci_devs",
+ "pci_dev")


class EpcSection:
@@ -316,3 +322,4 @@ class VmInfo:
self.mem_info.check_item()
self.os_cfg.check_item()
self.cfg_pci.check_item()
+ self.vuart.check_item()
diff --git a/misc/acrn-config/scenario_config/vm_configurations_c.py b/misc/acrn-config/scenario_config/vm_configurations_c.py
index 4ee8c055..f1961c73 100644
--- a/misc/acrn-config/scenario_config/vm_configurations_c.py
+++ b/misc/acrn-config/scenario_config/vm_configurations_c.py
@@ -139,13 +139,6 @@ def vuart_output(vm_type, i, vm_info, config):
vuart1_output(i, vm_type, vuart1_vmid_dic, vm_info, config)
print("\t\t},", file=config)

- # pci_dev_num/pci_devs only for SOS_VM or logical_partition pre_launched_vm
- if vm_type == "SOS_VM" or vm_type == "PRE_LAUNCHED_VM":
- if vm_info.cfg_pci.pci_dev_num[i] and vm_info.cfg_pci.pci_dev_num[i] != None:
- print("\t\t.pci_dev_num = {},".format(vm_info.cfg_pci.pci_dev_num[i]), file=config)
- if vm_info.cfg_pci.pci_devs[i] and vm_info.cfg_pci.pci_devs[i] != None:
- print("\t\t.pci_devs = {},".format(vm_info.cfg_pci.pci_devs[i]), file=config)
-

def is_need_epc(epc_section, i, config):
"""
@@ -281,6 +274,8 @@ def gen_sos_vm(vm_type, vm_i, vm_info, config):
err_dic = vuart_output(vm_type, vm_i, vm_info, config)
if err_dic:
return err_dic
+ print("\t\t.pci_dev_num = {},".format("SOS_EMULATED_PCI_DEV_NUM"), file=config)
+ print("\t\t.pci_devs = {},".format("sos_pci_devs"), file=config)

print("\t},", file=config)

@@ -337,6 +332,10 @@ def gen_pre_launch_vm(vm_type, vm_i, vm_info, config):
if err_dic:
return err_dic

+ if vm_info.cfg_pci.pci_devs[vm_i] and vm_info.cfg_pci.pci_devs[vm_i] != None:
+ print("\t\t.pci_dev_num = {}U,".format(vm_info.cfg_pci.pci_dev_num[vm_i]), file=config)
+ print("\t\t.pci_devs = vm{}_pci_devs,".format(vm_i),
+ file=config)
+
print("\t},", file=config)


@@ -387,7 +386,7 @@ def pre_launch_definiation(vm_info, config):
if vm_type != "PRE_LAUNCHED_VM":
continue
print("extern struct acrn_vm_pci_dev_config " +
- "vm{0}_pci_devs[VM{1}_CONFIG_PCI_DEV_NUM];".format(vm_i, vm_i), file=config)
+ "vm{}_pci_devs[{}];".format(vm_i,
+ vm_info.cfg_pci.pci_dev_num[vm_i]), file=config)
print("", file=config)

def generate_file(vm_info, config):
--
2.20.1

Join acrn-dev@lists.projectacrn.org to automatically receive all group messages.