mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-05-06 07:26:56 +00:00
This patch is to support Main VM, i.e., the Main VM scenario is similar to paritioned scenario, which select one VM as Main VM and owns the physical resources. I extracted all pcis from the board, substracted them with dispatched ones and then make an assignment to replace the old enums. This is implemented through two methods called updateSchema which is to update schema on the current VM and updateLoadSchema which is to maintain pcis, i.e. removed the pcis listed on the pre-launched VM, while loading scenario.xml. I tested locally and confirmed the functionalties above are implemented. Signed-off-by: dongpingx <dongpingx.wu@intel.com> Tracked-On: #8657
52 lines
1.2 KiB
Python
52 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
__package__ = 'configurator.pyodide'
|
|
|
|
from .pyodide import convert_result, nuc11_board, nuc11_scenario
|
|
|
|
import re
|
|
from lxml import etree
|
|
|
|
|
|
class GenerateSchema:
|
|
|
|
def __init__(self, board, scenario):
|
|
parser = etree.XMLParser(remove_blank_text=True)
|
|
self.board_etree = etree.fromstring(board, parser)
|
|
self.scenario = scenario
|
|
|
|
@property
|
|
def pcis(self):
|
|
line = self.board_etree.xpath('/acrn-config/PCI_DEVICE/text()')[0]
|
|
cnt = []
|
|
for line in line.replace('\t', '').split('\n'):
|
|
re_cpi = re.compile(r'^([0-9A-Fa-f]{1,2}:[0-1][0-9A-Fa-f]\.[0-7].*)\(')
|
|
ret_ = re_cpi.search(line)
|
|
if ret_:
|
|
ret = ret_.group(1).strip()
|
|
if re.search(r'^00:00.0', ret): # omit 00:00.0
|
|
continue
|
|
cnt.append(ret)
|
|
return cnt
|
|
|
|
@property
|
|
def schemas(self):
|
|
return self.scenario
|
|
|
|
def update(self):
|
|
return sorted(list(set(self.pcis) - set(self.schemas)))
|
|
|
|
|
|
def updateSchema(board, scenario):
|
|
return convert_result(GenerateSchema(board, scenario).update())
|
|
|
|
|
|
main = updateSchema
|
|
|
|
|
|
def test():
|
|
main(nuc11_board, nuc11_scenario)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
test()
|