From: Jiri Denemark Date: Mon, 21 Oct 2024 13:41:50 +0000 (+0200) Subject: sync_qemu_models_i386: Update index.xml X-Git-Tag: v10.10.0-rc1~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7133d72eff86cd3a619d2ade4ac67c420f10a694;p=thirdparty%2Flibvirt.git sync_qemu_models_i386: Update index.xml Add all newly generated CPU models to the appropriate section of index.xml. Signed-off-by: Jiri Denemark Reviewed-by: Daniel P. Berrangé --- diff --git a/src/cpu_map/sync_qemu_models_i386.py b/src/cpu_map/sync_qemu_models_i386.py index ce3c39de96..024bc92f07 100755 --- a/src/cpu_map/sync_qemu_models_i386.py +++ b/src/cpu_map/sync_qemu_models_i386.py @@ -533,6 +533,35 @@ def output_model(f, extra, model): f.write("\n") +def update_index(outdir, models): + index = os.path.join(outdir, "index.xml") + xml = lxml.etree.parse(index) + + for vendor, files in models.items(): + groups = xml.xpath(f"//arch[@name='x86']/group[@name='{vendor} CPU models']") + if not groups: + continue + + group = groups[-1] + last = group.getchildren()[-1] + group_indent = last.tail + indent = f"{group_indent} " + last.tail = indent + + for file in files: + include = lxml.etree.SubElement(group, "include", filename=file) + include.tail = indent + + group.getchildren()[-1].tail = group_indent + + out = lxml.etree.tostring(xml, encoding="UTF-8") + out = out.decode("UTF-8").replace('"', "'") + + with open(index, "w") as f: + f.write(out) + f.write("\n") + + def main(): parser = argparse.ArgumentParser( description="Synchronize x86 cpu models from QEMU i386 target.") @@ -573,6 +602,8 @@ def main(): for model in models_json: models.extend(expand_model(model)) + files = dict() + for model in models: name = f"x86_{model['name']}.xml" path = os.path.join(args.outdir, name) @@ -582,10 +613,18 @@ def main(): # change once released. continue + vendor = model['vendor'] + if vendor: + if vendor not in files: + files[vendor] = [] + files[vendor].append(name) + extra = os.path.join(args.outdir, f"x86_{model['name']}.extra") with open(path, "wt") as f: output_model(f, extra, model) + update_index(args.outdir, files) + features = set() for model in models: features.update(model["features"])