]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
sync_qemu_models_i386: Support adding models to an empty group
authorJiri Denemark <jdenemar@redhat.com>
Thu, 6 Nov 2025 09:55:10 +0000 (10:55 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Fri, 7 Nov 2025 14:54:56 +0000 (15:54 +0100)
When adding a new CPU vendor, we create a new empty group in
src/cpu_map/index.xml and want to use the sync_qemu_models_i386.py
script to add models there.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/cpu_map/sync_qemu_models_i386.py

index 7ae329cb999cdc806adf6a1a99068cd9a44c7c00..0f43d9e14a67d1a4dbcb96ad6e6505ada6d92e41 100755 (executable)
@@ -592,10 +592,16 @@ def update_index(outdir, models):
             continue
 
         group = groups[-1]
-        last = group.getchildren()[-1]
-        group_indent = last.tail
-        indent = f"{group_indent}  "
-        last.tail = indent
+        children = group.getchildren()
+        if children:
+            last = children()[-1]
+            group_indent = last.tail
+            indent = f"{group_indent}  "
+            last.tail = indent
+        else:
+            group_indent = f"{group.tail}  "
+            indent = f"{group_indent}  "
+            group.text = f"{group_indent}  "
 
         for file in files:
             include = lxml.etree.SubElement(group, "include", filename=file)