package main
import "fmt"
// You may think that you want to rewrite to proper golang structures.
// Believe me, you shouldn't.
func generateXML(vmName string, network networkModel, gui bool,
vmNixPath, reginfo, img, sharedDir string) string {
devices := ""
if gui {
devices = guiDevices
}
qemuParams := qemuParamsDefault
if network == networkQemu {
qemuParams = qemuParamsWithNetwork
} else if network == networkLibvirt {
devices += netDevices
}
return fmt.Sprintf(xmlTmpl, vmName, vmNixPath, vmNixPath, vmNixPath,
reginfo, img, sharedDir, sharedDir, sharedDir, devices, qemuParams)
}
var qemuParamsDefault = `
`
var qemuParamsWithNetwork = `
`
var netDevices = `
`
var guiDevices = `
`
var xmlTmpl = `
%s
2
1
4
hvm
%s/kernel
%s/initrd
loglevel=4 init=%s/init %s
destroy
restart
destroy
%s
%s
`