From e87ec5ac82baeacf1e74549327ea780fe547505e Mon Sep 17 00:00:00 2001 From: dongpingx Date: Fri, 30 Aug 2024 14:21:34 +0800 Subject: [PATCH] misc: fail to save config_summary.rst while changing board.xml This patch is to fix the bug which will report while changing board.xml. The issue was that all data structures were class variables, Data will be accumulated when calling main(board_xml, scenario_xml, config_summary). This patch moved all shared data to instance variables in __init__(). self.io_port = {} self.io_description = [] self.pci_vuart = {} self.pci_ivshmem = {} self.amount_l3_cache = {} self.service_vm_used_pcpu_list = [] Tracked-On: #8718 Signed-off-by: dongpingx Signed-off-by: Zhangwei6 --- .../scenario_config/config_summary.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/misc/config_tools/scenario_config/config_summary.py b/misc/config_tools/scenario_config/config_summary.py index 1a36ba49a..689b98a60 100644 --- a/misc/config_tools/scenario_config/config_summary.py +++ b/misc/config_tools/scenario_config/config_summary.py @@ -91,13 +91,6 @@ class Doc: class GenerateRst: - io_port = {} - io_description = [] - pci_vuart = {} - pci_ivshmem = {} - amount_l3_cache = {} - service_vm_used_pcpu_list = [] - # Class initialization def __init__(self, board_file_name, scenario_file_name, rst_file_name) -> None: self.board_etree = parse(board_file_name) @@ -105,6 +98,14 @@ class GenerateRst: self.file = open(rst_file_name, 'w') self.doc = Doc(self.file) + # Initialize instance variables to avoid data persistence across instances + self.io_port = {} + self.io_description = [] + self.pci_vuart = {} + self.pci_ivshmem = {} + self.amount_l3_cache = {} + self.service_vm_used_pcpu_list = [] + # The rst content is written in three parts according to the first level title # 1. Hardware Resource Allocation 2. Inter-VM Connections 3. VM info def write_configuration_rst(self): @@ -448,7 +449,8 @@ class GenerateRst: # Close the Rst file after all information is written. def close_file(self): - self.file.close() + if self.file: + self.file.close() def main(board_xml, scenario_xml, config_summary):