Using ivshmem in qemu requires the following steps.
./ivshmem_server which will create a unix domain socket /tmp/ivshmem_socket-chardev socket,path=/tmp/ivshmem_socket,id=ivshmem_socket -device ivshmem,chardev=ivshmem_socket,size=1mNow if we do lspci in guest, the ivshmem pci device is shown in it.
How can I do the same in virt-manager? Specifically, I want to do 2 things.
/tmp/ivshmem_socket is not denied to the VM ?Passing command line options
Passing command line option to qemu from virt-manager requires the following steps.
virsh edit <name of vm> , or directly modify the file using vim /etc/libvirt/qemu/<name of virtual machine>.xml<domain type='kvm'> to <domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'><qemu:commandline> <qemu:arg value='-chardev'/> <qemu:arg value='socket,path=/tmp/ivshmem_socket,id=ivshmem_socket'/> <qemu:arg value='-device'/> <qemu:arg value='ivshmem,chardev=ivshmem_socket,size=1m'/> </qemu:commandline>
After doing this, qemu will try to access /tmp/ivshmem_socket, and because of apparmor (libvirt was using apparmor in my case, it may as well use SeLinux), the access will be denied, and an error similar to the following will be shown.
error starting domain: internal error: process exited while connecting to monitor:
...
virt-manager Failed to connect socket: Permission denied
AppArmor
To fix this error, the following two steps are required.
1. Make qemu run as root (This step is optional, and may not be required for you, continue to second step)
/etc/libvirt/qemu.confuser =, and group = , to the followinguser = "root"
group = "root"
Restart PC or libvirt daemon.
2. AppArmor
/etc/apparmor.d/libvirtlibvirt-<uuid> file is present, replace <uuid> with uuid of vmChange AppArmor mode to complain, instead of enforcing, which will allow all actions of the VM, and log those which should have been blocked.
sudo aa-complain libvirt-<uuid> //replace <uuid> with uuid of vm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With