无法使用 virsh 将磁盘连接到虚拟机

无法使用 virsh 将磁盘连接到虚拟机

我正在尝试将 5 个磁盘连接到 Vagrant vm

virsh 附加磁盘 ansible_default --source /var/lib/libvirt/images/ansible_default.img --target vdb --cache none

但我收到以下错误:

“错误:无法连接磁盘错误:内部错误:无法执行 QEMU 命令‘device_add’:无法获取“写入”锁”

在 virsh 池中我有 2 个卷:


ansible_default.img /var/lib/libvirt/images/ansible_default.img generic-VAGRANTSLASH-centos9s_vagrant_box_image_4.2.16_box.img /var/lib/libvirt/images/generic-VAGRANTSLASH-centos9s_vagrant_box_image_4.2.16_box.img

这是我的 vagrantfile:

Vagrant.configure("2") do |config|
  # config.vm.provider :libvirt do |libvirt|
  #   libvirt.storage :file, :size => '20G', :device => 'vdb', :bus => 'scsi'
  #   libvirt.storage :file, :size => '20G', :device => 'vdc', :bus => 'scsi'
  #   libvirt.storage :file, :size => '20G', :device => 'vdd', :bus => 'scsi'
  #   libvirt.storage :file, :size => '20G', :device => 'vde', :bus => 'scsi'
  #   libvirt.storage :file, :size => '20G', :device => 'vdf', :bus => 'scsi'
  # end
  config.vm.box = "generic/centos9s"
  config.vm.provision "shell" do |s|
    ssh_pub_key = File.readlines("#{Dir.home}/.ssh/id_rsa.pub").first.strip
    s.inline = <<-SHELL
      echo #{ssh_pub_key} >> /home/vagrant/.ssh/authorized_keys
      echo #{ssh_pub_key} >> /root/.ssh/authorized_keys
    SHELL
  end

相关内容