kickstart libvirt-go选项中选择的文件,自动选择图标。
要创建新的虚拟机,我需要在libvirt-go-xml包中生成的XML-Config。
这是我生成域结构的函数,稍后将其解析为XML-Dom。
func defineDomain(domainName string, vcpu *libvirtxml.DomainVCPU, disks []libvirtxml.DomainDisk, interfaces []libvirtxml.DomainInterface, memory *libvirtxml.DomainMemory) *libvirtxml.Domain {
domainId := 10
domain := &libvirtxml.Domain{
XMLName: xml.Name{
Space: "Hello",
Local: "World",
},
Type: "kvm",
ID: &domainId,
Name: domainName,
UUID: uuid.Must(uuid.NewV4()).String(),
Title: domainName,
Description: domainName,
Metadata: &libvirtxml.DomainMetadata{
XML: "",
},
Memory: memory,
VCPU: vcpu,
OS: &libvirtxml.DomainOS{
BootDevices: []libvirtxml.DomainBootDevice{
libvirtxml.DomainBootDevice{
Dev: "hd",
},
},
Kernel: "",
Initrd: "/home/markus/workspace/worker-management/centos/kvm-centos.ks",
Cmdline: "ks=file:/home/markus/workspace/worker-management/centos/kvm-centos.ks method=http://repo02.agfa.be/CentOS/7/os/x86_64/",
Type: &libvirtxml.DomainOSType{
Arch: "x86_64",
Type: "hvm",
},
},
OnCrash: "restart",
OnPoweroff: "destroy",
OnReboot: "restart",
Devices: &libvirtxml.DomainDeviceList{
Emulator: "/usr/bin/kvm-spice",
Disks: disks,
Interfaces: interfaces,
Graphics: []libvirtxml.DomainGraphic{
libvirtxml.DomainGraphic{
VNC: &libvirtxml.DomainGraphicVNC{
AutoPort: "yes",
Listen: "127.0.0.1",
Keymap: "de",
Listeners: []libvirtxml.DomainGraphicListener{
libvirtxml.DomainGraphicListener{
Address: &libvirtxml.DomainGraphicListenerAddress{
Address: "127.0.0.1",
},
},
},
},
},
},
},
}
return domain
}
当我想用XML-Dom创建新的虚拟机时,出现以下错误。
2018/09/25 08:12:45 virError(Code=1, Domain=10, Message='internal error: process exited while connecting to monitor: 2018-09-25T06:12:45.683418Z qemu-system-x86_64: -append only allowed with -kernel option')
我将一个空字符串定义为内核选项,因为我不知道要炫耀什么。
答案 0 :(得分:1)
您提供了错误的Initrd
:
Initrd: "/home/markus/workspace/worker-management/centos/kvm-centos.ks",
这不是initrd,而是您的kickstart文件(已在Cmdline
中正确指定。
不建议指定Kernel
和Initrd
。这旨在用于从VM实例本身外部的内核引导VM。在几乎所有情况下,您都不希望这样做。
相反,这也应该是空字符串,与Kernel
相同。然后,VM将从您将提供的虚拟启动媒体(硬盘,ISO映像等)启动。