Add all newly generated CPU models to the appropriate section of index.xml. Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> --- src/cpu_map/sync_qemu_models_i386.py | 40 ++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/cpu_map/sync_qemu_models_i386.py b/src/cpu_map/sync_qemu_models_i386.py index 75d86144d0..40d71e66be 100755 --- a/src/cpu_map/sync_qemu_models_i386.py +++ b/src/cpu_map/sync_qemu_models_i386.py @@ -534,6 +534,35 @@ def output_model(f, extra, model): f.write("</cpus>\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[@vendor='{vendor}']") + 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.") @@ -574,6 +603,8 @@ def main(): for model in models_json: models.extend(expand_model(model)) + files = dict() + for model in models: base = os.path.join(args.outdir, f"x86_{model['name']}") name = f"{base}.xml" @@ -582,9 +613,18 @@ def main(): # Ignore existing models as CPU models in libvirt should never # change once released. continue + + vendor = model['vendor'] + if vendor: + if vendor not in files: + files[vendor] = [] + files[vendor].append(name) + with open(name, "wt") as f: output_model(f, f"{base}.extra", model) + update_index(args.outdir, files) + features = set() for model in models: features.update(model["features"]) -- 2.47.0