diff --git a/internal/codegen/parser/libvirtxml.go b/internal/codegen/parser/libvirtxml.go index 4fd32b905..66ca41d02 100644 --- a/internal/codegen/parser/libvirtxml.go +++ b/internal/codegen/parser/libvirtxml.go @@ -85,6 +85,17 @@ func (r *LibvirtXMLReflector) ReflectStruct(structType reflect.Type) (*generator continue } + if field.Anonymous { + if field.Type.Kind() == reflect.Struct { + embeddedIR, err := r.ReflectStruct(field.Type) + if err != nil { + return nil, fmt.Errorf("analyzing embedded struct %s: %w", field.Type.Name(), err) + } + ir.Fields = append(ir.Fields, embeddedIR.Fields...) + } + continue + } + fieldIR, err := r.analyzeField(typeName, field) if err != nil { return nil, fmt.Errorf("analyzing field %s: %w", field.Name, err) @@ -248,11 +259,6 @@ func (r *LibvirtXMLReflector) analyzeField(structName string, field reflect.Stru return nil, nil } - // Skip embedded/anonymous fields - if field.Anonymous { - return nil, nil - } - xmlTag := field.Tag.Get("xml") if xmlTag == "" { // Skip fields without XML tags