使用libvirt创建快照时提示权限不足
问题
在ubuntu20.04上使用virt-manager安装了一个fedora虚拟机,在创建快照时提示权限不足:
Error creating snapshot: internal error: Child process (/usr/local/bin/qemu-img snapshot -c snapshot1 /vol_8t/fedora39_kvm/fedora39.qcow2) unexpected exit status 126: libvirt: error : cannot execute binary /usr/local/bin/qemu-img: Permission denied
Traceback (most recent call last):
File "/usr/share/virt-manager/virtManager/asyncjob.py", line 75, in cb_wrapper
callback(asyncjob, *args, **kwargs)
File "/usr/share/virt-manager/virtManager/details/snapshots.py", line 239, in _do_create_snapshot
self.vm.create_snapshot(xml)
File "/usr/share/virt-manager/virtManager/object/domain.py", line 1057, in create_snapshot
self._backend.snapshotCreateXML(xml, flags)
File "/usr/lib/python3/dist-packages/libvirt.py", line 2800, in snapshotCreateXML
if ret is None:raise libvirtError('virDomainSnapshotCreateXML() failed', dom=self)
libvirt.libvirtError: internal error: Child process (/usr/local/bin/qemu-img snapshot -c snapshot1 /vol_8t/fedora39_kvm/fedora39.qcow2) unexpected exit status 126: libvirt: error : cannot execute binary /usr/local/bin/qemu-img: Permission denied
解决
参考下面的博客:
https://unix.stackexchange.com/questions/471345/changing-libvirt-emulator-permission-denied
修改/etc/apparmor.d/usr.sbin.libvirtd,照猫画虎,添加对/usr/local/bin下的文件的访问权限:
重新加载规则:
sudo systemctl reload apparmor
完
本文来自博客园,作者:摩斯电码,未经同意,禁止转载