创建流浪虚拟机libvirt提供程序时不支持的配置错误



我正在为arm64平台的libvirt提供程序创建一个Ubuntu 20.04服务器流浪基础箱。我已经从一个qcow2映像文件创建了一个基盒。

当尝试用vagrant up命令创建流浪箱时,我在输出的末尾得到错误:

Bringing machine 'ubuntu-vm' up with 'libvirt' provider...
==> ubuntu-vm: Creating image (snapshot of base box volume).
==> ubuntu-vm: Creating domain with the following settings...
==> ubuntu-vm:  -- Name:              vagrant-vm_ubuntu-vm
==> ubuntu-vm:  -- Domain type:       kvm
==> ubuntu-vm:  -- Cpus:              1
==> ubuntu-vm:  -- Memory:            512M
==> ubuntu-vm:  -- Management MAC:    
==> ubuntu-vm:  -- Loader:            
==> ubuntu-vm:  -- Nvram:             
==> ubuntu-vm:  -- Base box:          ubuntu20.04-arm64
==> ubuntu-vm:  -- Storage pool:      default
==> ubuntu-vm:  -- Image:             /var/lib/libvirt/images/vagrant-vm_ubuntu-vm.img (10G)
==> ubuntu-vm:  -- Volume Cache:      default
==> ubuntu-vm:  -- Kernel:            
==> ubuntu-vm:  -- Initrd:            
==> ubuntu-vm:  -- Graphics Type:     vnc
==> ubuntu-vm:  -- Graphics Port:     -1
==> ubuntu-vm:  -- Graphics IP:       127.0.0.1
==> ubuntu-vm:  -- Graphics Password: Not defined
==> ubuntu-vm:  -- Video Type:        cirrus
==> ubuntu-vm:  -- Video VRAM:        9216
==> ubuntu-vm:  -- Sound Type:  
==> ubuntu-vm:  -- Keymap:            en-us
==> ubuntu-vm:  -- TPM Path:          
==> ubuntu-vm:  -- INPUT:             type=mouse, bus=ps2
==> ubuntu-vm: Creating shared folders metadata...
==> ubuntu-vm: Starting domain.
There was an error talking to Libvirt. The error message is shown below:
Call to virDomainCreateWithFlags failed: unsupported configuration: CPU mode 'host-model' for aarch64 kvm domain on aarch64 host is not supported by hypervisor

我的Vagrantfile是:

UbuARM = "ubuntu20.04-arm64"
Vagrant.configure("2") do |config|
config.vm.define "ubuntu-vm" do |nodeconfig|
nodeconfig.vm.box = UbuARM
nodeconfig.vm.hostname = "ubuntu-vm"
nodeconfig.vm.network :public_network,
bridge: "br0",
dev: "br0",
mode: "bridge",
type: "bridge"
nodeconfig.vm.provider :libvirt do |libvirt|
libvirt.uri="qemu:///system"
libvirt.storage_pool_name = "default"
libvirt.storage_pool_path = "/var/lib/libvirt/images"
libvirt.features = [] # had to put this to solve some error
end
end 
end

在大多数情况下,ARM64的qemu不支持vagrant的默认选项。

在这种情况下,cpu_mode的默认值是'host-model',该架构不支持。您可以使用'host-passthrough'。

提示:对于任何试图在ARM64中使用vagrant-libvirt进行虚拟化的人,我建议转储libvirt XML域定义,并使用vagrant-libvirt插件选项复制它。

这些选项对我很有用:

libvirt.features = ["apic", "gic version='2'"]
libvirt.machine_type = "virt-5.2"
libvirt.machine_arch = "aarch64"    
libvirt.loader = "/usr/share/AAVMF/AAVMF_CODE.fd" 
libvirt.cpu_mode = "host-passthrough" 

libvirt.input :type => "mouse", :bus => "usb"
libvirt.input :type => "keyboard", :bus => "usb"
libvirt.usb_controller :model => "qemu-xhci"
libvirt.video_type = "vga"
libvirt.channel :type => 'unix', :target_type => 'virtio', :target_name => 'org.qemu.guest_agent.0', :target_port => '1', :source_path => '/var/lib/libvirt/qemu/channel/target/domain-1-ubuntu20.04/org.qemu.guest_agent.0', :source_mode => 'bind'

最新更新