ignore 'custom' cpu settings from XML

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-10-25 14:52:28 -05:00
parent fbd0d35660
commit 7af7c876e4
2 changed files with 13 additions and 14 deletions

11
argv.go
View File

@ -11,11 +11,12 @@ import "go.wit.com/log"
var argv args
type args struct {
Xml []string `arg:"--libvirt" help:"import qemu xml files: --libvirt /etc/libvirt/qemu/*.xml"`
Save bool `arg:"--save" default:"false" help:"save protobuf config after import"`
Config string `arg:"env:VIRTIGO_HOME" help:"defaults to ~/.config/virtigo/"`
Port int `arg:"--port" default:"8080" help:"allow droplet events via http"`
Daemon bool `arg:"--daemon" help:"run in daemon mode"`
Xml []string `arg:"--libvirt" help:"import qemu xml files: --libvirt /etc/libvirt/qemu/*.xml"`
IgnoreCpu bool `arg:"--xml-ignore-cpu" default:"true" help:"ignore non-standard libvirt xml cpus"`
Save bool `arg:"--save" default:"false" help:"save protobuf config after import"`
Config string `arg:"env:VIRTIGO_HOME" help:"defaults to ~/.config/virtigo/"`
Port int `arg:"--port" default:"8080" help:"allow droplet events via http"`
Daemon bool `arg:"--daemon" help:"run in daemon mode"`
}
// Uptime bool `arg:"--uptime" default:"true" help:"allow uptime checks for things like Kuma"`

View File

@ -330,13 +330,14 @@ func dumpNonStandardXML(domcfg *libvirtxml.Domain) (string, error) {
case "host-model":
domcfg.CPU = nil
case "custom":
fmt.Printf("custom CPU: %+v\n", domcfg.CPU)
fmt.Printf("custom CPU Model: %+v\n", domcfg.CPU.Model)
// domcfg.CPU = nil
updatedXML, _ := xml.MarshalIndent(domcfg.CPU, "", " ")
log.Info("Non-Standard XML Start")
log.Info("Ignore custom CPU Start")
fmt.Println(string(updatedXML))
log.Info("Non-Standard XML End")
log.Info("Ignore custom CPU End")
log.Info("Add --xml-ignore-cpu to ignore this")
if argv.IgnoreCpu {
domcfg.CPU = nil
}
default:
fmt.Printf("unknown CPU: %+v\n", domcfg.CPU)
fmt.Printf("unknown CPU Model: %+v\n", domcfg.CPU.Model)
@ -348,10 +349,6 @@ func dumpNonStandardXML(domcfg *libvirtxml.Domain) (string, error) {
}
}
// this goes away if SecLabel is zero'd out?
//if domcfg.Metadata != nil {
// fmt.Printf("? Metadata: %+v\n", domcfg.Metadata)
//}
var secnormal bool = true
if len(domcfg.SecLabel) != 0 {
for _, sec := range domcfg.SecLabel {
@ -367,6 +364,7 @@ func dumpNonStandardXML(domcfg *libvirtxml.Domain) (string, error) {
if secnormal {
domcfg.SecLabel = nil
}
// ignore Metadata
// this is probably something about what kind of OS you might be running
// todo: get this directly from the disk image