diff options
| author | Jeff Carr <[email protected]> | 2024-10-25 16:40:05 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-10-25 16:40:05 -0500 |
| commit | 4d43c36db5d87fcd8a30242e424017468a7c48c0 (patch) | |
| tree | 3f546b5ab89b30561487138a703070cee80459eb /libvirtxml.go | |
| parent | 15f48a01ab043a996b72460358ffca2e47b3d88f (diff) | |
more xml checks
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'libvirtxml.go')
| -rw-r--r-- | libvirtxml.go | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/libvirtxml.go b/libvirtxml.go index f872c75..b40c3a1 100644 --- a/libvirtxml.go +++ b/libvirtxml.go @@ -351,11 +351,19 @@ func dumpNonStandardXML(domcfg *libvirtxml.Domain) (string, error) { var secnormal bool = true if len(domcfg.SecLabel) != 0 { for _, sec := range domcfg.SecLabel { - if sec.Model == "apparmor" { - // this should be configured in dom0 - } else { - fmt.Printf("? SecLabel: %+v\n", sec) - fmt.Printf("? SecLabel.Model: %+v\n", sec.Model) + switch sec.Model { + case "apparmor": + // log.Info("ignoring SecLabel apparmor. not supported yet") + // log.Info("you must set this later if you need this") + // xmlAny(sec) + case "dac": + // log.Info("ignoring SecLabel dac. not supported yet") + // log.Info("you must set this later if you need this") + // xmlAny(sec) + default: + fmt.Printf("unknown SecLabel: %+v\n", sec) + fmt.Printf("unknown SecLabel.Model: %+v\n", sec.Model) + xmlAny(sec) secnormal = false } } @@ -371,6 +379,7 @@ func dumpNonStandardXML(domcfg *libvirtxml.Domain) (string, error) { fmt.Printf("Not saving Domain.Metadata: %+v\n", domcfg.Metadata) domcfg.Metadata = nil } + // ignore Resource if domcfg.Resource != nil { if domcfg.Resource.Partition == "/machine" { @@ -380,6 +389,12 @@ func dumpNonStandardXML(domcfg *libvirtxml.Domain) (string, error) { } } + // ignore Resource + if domcfg.ID != nil { + // ignore domain id + domcfg.ID = nil + } + // this will move elsewhere in the protobuf someday // ignore all these for now if domcfg.OnPoweroff != "" { // normally "destroy" @@ -677,6 +692,23 @@ func finalEmptyCheck(domcfg *libvirtxml.Domain) (string, error) { return final, nil } +func xmlAny(a any) (string, error) { + updatedXML, err := xml.MarshalIndent(a, "", " ") + if err != nil { + fmt.Printf("Failed to marshal updated XML: %v\n", err) + return "", err + } + final := string(updatedXML) + if final == "" { + // everything seems to have been parsed pretty standard + return "", nil + } + log.Info("Non-Standard XML Start") + fmt.Println(final) + log.Info("Non-Standard XML End") + return final, nil +} + func warnUserOfNonStandardXML(domcfg *libvirtxml.Domain) (string, error) { updatedXML, err := xml.MarshalIndent(domcfg, "", " ") if err != nil { @@ -832,7 +864,7 @@ func libvirtxmlDomainEmpty(mydom libvirtxml.Domain) bool { } case reflect.Struct: if IsStructEmptyOrNil(value) { - fmt.Printf("XML Field ignore empty Struct %s\n", field) + // fmt.Printf("XML Field ignore empty Struct %s\n", field) } else { fmt.Printf("Field Struct is not empty %s is %+v\n", field, value) empty = false |
