// Copyright 2024 WIT.COM Inc Licensed GPL 3.0 package main import ( "errors" pb "go.wit.com/lib/protobuf/virtbuf" "go.wit.com/lib/virtigolib" "go.wit.com/log" "libvirt.org/go/libvirtxml" ) func newStart(start string, d *pb.Droplet) error { if d == nil { log.Info("log.Info: droplet is unknown:", start) return errors.New("droplet is unknown: " + start) } log.Info("start droplet here:", d.Hostname) domcfg := &libvirtxml.Domain{} mergeXMLresource(domcfg, "standard.x86") // ignore spice if it's not set if d.SpicePort == 0 { log.Info("spice port was not set. spice disabled") } else { mergeXMLresource(domcfg, "spice") if err := virtigolib.SetSpicePort(d, domcfg); err != nil { return err } } mergeXMLresource(domcfg, "qcow") return virtigolib.GenerateDropletXml(me.dirs, d, domcfg, start) } func mergeXMLresource(domcfg *libvirtxml.Domain, filename string) error { fullname := "resources/xml/" + filename + ".xml" pfile, err := resources.ReadFile(fullname) if err != nil { log.Println("ERROR:", err) return err } return virtigolib.MergeXml(domcfg, string(pfile)) }