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

View File

@ -12,6 +12,7 @@ var argv args
type args struct { type args struct {
Xml []string `arg:"--libvirt" help:"import qemu xml files: --libvirt /etc/libvirt/qemu/*.xml"` 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"` Save bool `arg:"--save" default:"false" help:"save protobuf config after import"`
Config string `arg:"env:VIRTIGO_HOME" help:"defaults to ~/.config/virtigo/"` Config string `arg:"env:VIRTIGO_HOME" help:"defaults to ~/.config/virtigo/"`
Port int `arg:"--port" default:"8080" help:"allow droplet events via http"` Port int `arg:"--port" default:"8080" help:"allow droplet events via http"`

View File

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