acrn-hypervisor/misc/config_tools/configurator/pyodide/updateSchema.py
dongpingx 56108c0a1f misc: Configurator Main VM Support
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
2024-07-18 10:41:48 +08:00

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()