使用libvirt创建快照时提示权限不足

问题

在ubuntu20.04上使用virt-manager安装了一个fedora虚拟机,在创建快照时提示权限不足:

image

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下的文件的访问权限:

image

重新加载规则:

sudo systemctl reload apparmor

posted @ 2024-03-25 19:54  摩斯电码  阅读(115)  评论(0编辑  收藏  举报