.. since it is able to generate configs now. Also remove 'Config' suffix from Cell and System class names as the config module itself declares them as such.
Signed-off-by: Andrej Utz <[email protected]> --- pyjailhouse/{config_parser.py => config.py} | 22 ++++++++++----------- tools/jailhouse-config-check | 6 +++--- 2 files changed, 14 insertions(+), 14 deletions(-) rename pyjailhouse/{config_parser.py => config.py} (97%) diff --git a/pyjailhouse/config_parser.py b/pyjailhouse/config.py similarity index 97% rename from pyjailhouse/config_parser.py rename to pyjailhouse/config.py index eaec4fa2..ff1c676b 100644 --- a/pyjailhouse/config_parser.py +++ b/pyjailhouse/config.py @@ -251,7 +251,7 @@ class Console(CStruct): _BIN_FMT = struct.Struct('=QIHHIIQ') -class CellConfig(CStruct): +class Cell(CStruct): # slots with a '_' prefix in name are private __slots__ = 'name', 'flags', 'cpu_set', \ 'memory_regions', 'cache_regions', 'irqchips', 'pio_regions', \ @@ -488,7 +488,7 @@ class PlattformInfo(CStruct): return self -class SystemConfig(CStruct): +class System(CStruct): __slots__ = 'flags', _BIN_FIELD_NUM = len(__slots__) _BIN_FMT = struct.Struct('I') @@ -503,10 +503,10 @@ class SystemConfig(CStruct): self.hypervisor_memory = MemRegion() self.debug_console = Console() self.platform_info = PlattformInfo() - self.root_cell = CellConfig() + self.root_cell = Cell() def save(self, stream): - hdr_fmt = CellConfig._BIN_FMT_HDR + hdr_fmt = Cell._BIN_FMT_HDR stream.write(hdr_fmt.pack(self._BIN_SIGNATURE, _CONFIG_REVISION)) super(self.__class__, self).save(stream) self.hypervisor_memory.save(stream) @@ -522,13 +522,13 @@ class SystemConfig(CStruct): self.debug_console = Console.parse(stream) self.platform_info = PlattformInfo.parse(stream) # skip header inside rootcell - stream.seek(CellConfig._BIN_FMT_HDR.size, io.SEEK_CUR) - self.root_cell = CellConfig.parse(stream) + stream.seek(Cell._BIN_FMT_HDR.size, io.SEEK_CUR) + self.root_cell = Cell.parse(stream) return self def parse(stream, config_expect=None): - fmt = CellConfig._BIN_FMT_HDR + fmt = Cell._BIN_FMT_HDR try: (signature, revision) = fmt.unpack_from(stream.read(fmt.size)) @@ -537,10 +537,10 @@ def parse(stream, config_expect=None): if config_expect == None: # Try probing - if signature == CellConfig._BIN_SIGNATURE: - config_expect = CellConfig - elif signature == SystemConfig._BIN_SIGNATURE: - config_expect = SystemConfig + if signature == Cell._BIN_SIGNATURE: + config_expect = Cell + elif signature == System._BIN_SIGNATURE: + config_expect = System else: raise RuntimeError('Not a Jailhouse configuration') elif config_expect._BIN_SIGNATURE != signature: diff --git a/tools/jailhouse-config-check b/tools/jailhouse-config-check index 224c5fb5..9f767cb8 100755 --- a/tools/jailhouse-config-check +++ b/tools/jailhouse-config-check @@ -22,7 +22,7 @@ import sys # Imports from directory containing this must be done before the following sys.path[0] = os.path.dirname(os.path.abspath(__file__)) + "/.." -import pyjailhouse.config_parser as config_parser +import pyjailhouse.config as config # pretend to be part of the jailhouse tool sys.argv[0] = sys.argv[0].replace('-', ' ') @@ -44,7 +44,7 @@ except IOError as e: print("Reading configuration set:") try: - sysconfig = config_parser.parse(args.syscfg, config_parser.SystemConfig) + sysconfig = config.parse(args.syscfg, config.System) root_cell = sysconfig.root_cell except RuntimeError as e: print(str(e) + ": " + args.syscfg.name, file=sys.stderr) @@ -56,7 +56,7 @@ print(" Root cell: %s (%s)" % (root_cell.name, args.syscfg.name)) non_root_cells = [] for cfg in args.cellcfgs: try: - cell = config_parser.parse(cfg, config_parser.CellConfig) + cell = config.parse(cfg, config.Cell) except RuntimeError as e: print(str(e) + ": " + cfg.name, file=sys.stderr) exit(1) -- 2.27.0 -- You received this message because you are subscribed to the Google Groups "Jailhouse" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jailhouse-dev/20200630064730.7210-3-andrej.utz%40st.oth-regensburg.de.
