我试图使用qemu的ivshmem设备,运行服务器之后,我可以用命令成功创建一个vm:

sudo qemu-system-x86_64 -m 1024 -hda testvm01.img -enable-kvm \
-device ivshmem-doorbell,vectors=1,chardev=ivshmem \
-chardev socket,path=/tmp/ivshmem_socket,id=ivshmem

然后我想用libvirt来启动vm,我的配置文件如下:

<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
  <name>testlinux1</name>
  <memory unit='KiB'>1048576</memory>
  <currentMemory unit='KiB'>1048576</currentMemory>
  <vcpu placement='static'>1</vcpu>
  <os>
    <type arch='x86_64' machine='pc-i440fx-bionic'>hvm</type>
  </os>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='raw'/>
      <source file='/home/gavin/vms/testvm01.img'/>
      <target dev='hda' bus='ide'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
  </devices>
  <qemu:commandline>
    <qemu:arg value='-device'/>
    <qemu:arg value='ivshmem-doorbell,vectors=2,chardev=ivshmem'/>
    <qemu:arg value='-chardev'/>
    <qemu:arg value='socket,path=/tmp/ivshmem_socket,id=ivshmem'/>
  </qemu:commandline>
</domain>

当我尝试使用命令 virsh create testlinux1.xml 创建vm时,我收到错误:

error: Failed to start domain testlinux1
error: internal error: process exited while connecting to monitor: 2018-07-19T22:12:52.443682Z qemu-system-x86_64: -chardev socket,path=/tmp/ivshmem_socket,id=ivshmem: Failed to connect socket /tmp/ivshmem_socket: Permission denied

我在以下网址看过同样的问题:Using IVSHMEM with libvirt virt-manager

因为我无法创建vm,所以无法按照解决方案进行操作, /etc/apparmor.d/libvirt 下没有 libvirt-<uuid> 文件,我无法将AppArmor模式更改为 sudo aa-complain libvirt-<uuid> //replace <uuid> with uuid of vm 抱怨 .

任何人都可以帮我弄清楚如何在创建文件之前将模式更改为抱怨?非常感谢你!