diff --git a/addDroplet.go b/addDroplet.go index 1d95510..d9912c9 100644 --- a/addDroplet.go +++ b/addDroplet.go @@ -251,14 +251,14 @@ func updateNetwork(d *DropletT, domcfg *libvirtxml.Domain) bool { } /* from vm3-with-nvme-1.5GB-sec.xml - - - - - - -
- + + + + + + +
+ */ // returns false if something went wrong diff --git a/configfiles.go b/configfiles.go index 5c2b0f6..4ea72e0 100644 --- a/configfiles.go +++ b/configfiles.go @@ -84,16 +84,37 @@ func readConfigFile(filename string) error { } func writeConfigFile() { + test := time.Now().Format("YYYYMMDD-HH-MM") + if !writeConfigFileTmp("virtigo.json.new." + test) { + log.Println("config file write error") + os.Exit(-1) + } + if !writeConfigFileTmp("virtigo.json") { + log.Println("config file write error") + os.Exit(-1) + } + + origname := filepath.Join(os.Getenv("VIRTIGO_HOME"), "virtigo.json") + newname := filepath.Join(os.Getenv("VIRTIGO_HOME"), "virtigo.json.old") + err := os.Rename(origname, newname) + if err != nil { + log.Printf("rename fail: %s", err) + os.Exit(-1) + } +} + +func writeConfigFileTmp(filename string) bool { fullname := filepath.Join(os.Getenv("VIRTIGO_HOME"), "virtigo.json") cfgfile, err := os.OpenFile(fullname, os.O_RDWR|os.O_CREATE, 0666) defer cfgfile.Close() if err != nil { log.Info("open config file :", err) - return + return false } json := me.cluster.FormatJSON() fmt.Fprintln(cfgfile, json) log.Info("Write:", fullname, "OK") + return true } func writeConfigFileDroplets() { diff --git a/xml.go b/xml.go index 03aad82..b100b14 100644 --- a/xml.go +++ b/xml.go @@ -328,7 +328,13 @@ func dumpNonStandardXML(domcfg *libvirtxml.Domain) { domcfg.CPU = nil case "host-model": domcfg.CPU = nil + case "custom": + fmt.Printf("? CPU: %+v\n", domcfg.CPU) + fmt.Printf("? CPU Model: %+v\n", domcfg.CPU.Model) + domcfg.CPU = nil default: + fmt.Printf("? CPU: %+v\n", domcfg.CPU) + fmt.Printf("? CPU Model: %+v\n", domcfg.CPU.Model) fmt.Printf("? CPU Mode: %+v\n", domcfg.CPU.Mode) } } @@ -518,8 +524,10 @@ func dumpNonStandardXML(domcfg *libvirtxml.Domain) { domcfg.Devices.Emulator = "" case "/usr/bin/kvm": domcfg.Devices.Emulator = "" + case "/usr/bin/kvm-spice": + domcfg.Devices.Emulator = "" default: - fmt.Printf("Unknown Emulator: %s\n", domcfg.Devices.Emulator) + fmt.Printf("Unknown Emulator: %s\n", domcfg.Devices.Emulator) } // ignore Channels == SpiceVMC