libvirt qemu 無法存取我的主目錄中的映像,即使是 root 也是如此?

libvirt qemu 無法存取我的主目錄中的映像,即使是 root 也是如此?

我在透過 libvirt 運行虛擬機器時遇到問題。這是我的設定:

  • 我將 qcow2 映像和網域 XML(名為win7.xml)放在 下$HOME/vm,所有檔案和目錄都使用我的使用者、我的群組和權限位元0644

  • 我取消註解了,user = "root"中 的行,期望將以 root 身分運行,因此可以完全存取 下的目錄和檔案。group = "root"dynamic_ownership = 1/etc/libvirt/qemu.confqemu-system-x86_64$HOME/vm

但是,virsh create win7.xml以 root 身分呼叫失敗:

error: Failed to create domain from win7.xml
error: internal error: early end of file from monitor, possible problem: 2016-10-01T03:36:02.049418Z qemu-system-x86_64: -drive file=/home/naitree/vm/win7/win7.qcow2,format=qcow2,if=none,id=drive-virtio-disk0: Could not open '/home/naitree/vm/win7/win7.qcow2': Permission denied

登入時出現以下錯誤/var/log/libvirt/qemu/win7.log

2016-10-01T03:36:02.049418Z qemu-system-x86_64: -drive file=/home/naitree/vm/win7/win7.qcow2,format=qcow2,if=none,id=drive-virtio-disk0: Could not open '/home/naitree/vm/win7/win7.qcow2': Permission denied
2016-10-01 03:36:02.080+0000: shutting down

看起來 qemu 無法存取我的虛擬機器磁碟檔案。但為什麼?沒有qemu-system-x86_64 以 root 身分運行?應該做什麼來確保 libvirt-qemu 能夠存取駐留在$HOME目錄中的磁碟映像?

附加版本資訊:

  • libvirt、virsh 版本:1.3.3.2
  • QEMU 版本:QEMU 模擬器版本 2.6.1 (qemu-2.6.1-1.fc24)
  • 發行版:Fedora 24
  • 核心:4.7.4-200.fc24.x86_64

答案1

您很可能會被 Selinux 阻止,請檢查您的 /var/log/audit.log

相關內容