當我定義新域時_, err = v.conn.DomainDefineXMLFlags(domainXml, libvirt.DOMAIN_DEFINE_VALIDATE)xml 看起來像:<domain type='kvm'> <name>{{.name}}</name> <memory unit='KiB'>{{.memory}}</memory> <currentMemory unit='KiB'>{{.current_memory}}</currentMemory> <vcpu>{{.count_cpu}}</vcpu> <os> <type arch='x86_64' machine='pc-i440fx-disco'>hvm</type> <boot dev='hd'/> </os> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> <emulator>/usr/bin/kvm-spice</emulator> <disk type='block' device='disk'> <driver name='qemu' type='raw' cache='none'/> <source dev='{{.lvm_path}}'/> <target dev='vda' bus='virtio'/> </disk> <disk type='file' device='cdrom'> <driver name='qemu' type='raw'/> <source file='{{.config_file}}'/> <target dev='sda' bus='sata'/> <readonly/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </disk> <interface type='bridge'> <source bridge='virbr0'/> <model type='virtio'/> <mac address='{{.mac_address}}'/> </interface> <serial type='pty'> <target port='0'/> </serial> <console type='pty'> <target type='serial' port='0'/> </console> </devices></domain>go-libvirt 制作了一個新的persistent domain. 但該域名已被關閉。$ virsh list --all Id Name State--------------------------- - new_domain shut off在源代碼https://github.com/libvirt/libvirt-go/blob/master/domain.go中,我沒有找到解決方案如何使用 golang 運行此域?
1 回答

慕碼人2483693
TA貢獻1860條經驗 獲得超9個贊
您需要在從 返回的對象Create
上使用該方法。例如Domain
DomainDefineXMLFlags
dom, err := v.conn.DomainDefineXMLFlags(domainXml, libvirt.DOMAIN_DEFINE_VALIDATE)
if err != nil {
? ? return err
}
err = dom.Create()
if err != nil {
? ? return err
}
- 1 回答
- 0 關注
- 134 瀏覽
添加回答
舉報
0/150
提交
取消