我尝试使用 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>
当我尝试使用 command 创建 vm 时virsh create testlinux1.xml
,出现错误:
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, libvirt-<uuid>
下没有文件/etc/apparmor.d/libvirt
,而且我无法更改 AppArmor 模式来抱怨sudo aa-complain libvirt-<uuid> //replace <uuid> with uuid of vm
。
谁能帮我弄清楚如何在创建文件之前更改模式以进行投诉?非常感谢!