veewee: qemu-kvm: could not open disk image ' ': Permission denied
Following the KVM documentation I stumbled across this permissions error.
Running as root on Centos 6.5
[root@dev1 veewee]# bundle exec veewee kvm build 'bamboo-agent' --pool-name=default --network-name=default --force
Building Box bamboo-agent with Definition bamboo-agent:
- debug : false
- cwd : /root/veewee
- force : true
- nogui : false
- auto : false
- checksum : false
- postinstall_include : []
- postinstall_exclude : []
- skip_to_postinstall : false
- use_emulation : false
- network_name : default
- pool_name : default
The isofile CentOS-6.5-x86_64-netinstall.iso already exists.
/usr/local/rvm/gems/ruby-1.9.3-p547@veewee/gems/fog-1.24.0/lib/fog/libvirt/requests/compute/vm_action.rb:7:in `create': Call to virDomainCreateWithFlags failed: Unable to read from monitor: Connection reset by peer (Libvirt::Error)
internal error process exited while connecting to monitor: char device redirected to /dev/pts/19
qemu-kvm: -drive file=/root/veewee/iso/CentOS-6.5-x86_64-netinstall.iso,if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw: could not open disk image /root/veewee/iso/CentOS-6.5-x86_64-netinstall.iso: Permission denied
from /usr/local/rvm/gems/ruby-1.9.3-p547@veewee/gems/fog-1.24.0/lib/fog/libvirt/requests/compute/vm_action.rb:7:in `vm_action'
from /usr/local/rvm/gems/ruby-1.9.3-p547@veewee/gems/fog-1.24.0/lib/fog/libvirt/models/compute/server.rb:69:in `start'
from /root/veewee/lib/veewee/provider/kvm/box/up.rb:8:in `up'
from /root/veewee/lib/veewee/provider/core/box/build.rb:50:in `kickstart'
from /root/veewee/lib/veewee/provider/core/box/build.rb:111:in `build'
from /root/veewee/lib/veewee/provider/kvm/box/build.rb:6:in `build'
from /root/veewee/lib/veewee/command/kvm.rb:25:in `build'
from /usr/local/rvm/gems/ruby-1.9.3-p547@veewee/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
from /usr/local/rvm/gems/ruby-1.9.3-p547@veewee/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
from /usr/local/rvm/gems/ruby-1.9.3-p547@veewee/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
from /usr/local/rvm/gems/ruby-1.9.3-p547@veewee/gems/thor-0.19.1/lib/thor/invocation.rb:115:in `invoke'
from /usr/local/rvm/gems/ruby-1.9.3-p547@veewee/gems/thor-0.19.1/lib/thor.rb:235:in `block in subcommand'
from /usr/local/rvm/gems/ruby-1.9.3-p547@veewee/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
from /usr/local/rvm/gems/ruby-1.9.3-p547@veewee/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
from /usr/local/rvm/gems/ruby-1.9.3-p547@veewee/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
from /usr/local/rvm/gems/ruby-1.9.3-p547@veewee/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
from /root/veewee/bin/veewee:24:in `<top (required)>'
from /usr/local/rvm/gems/ruby-1.9.3-p547@veewee/bin/veewee:23:in `load'
from /usr/local/rvm/gems/ruby-1.9.3-p547@veewee/bin/veewee:23:in `<main>'
from /usr/local/rvm/gems/ruby-1.9.3-p547@veewee/bin/ruby_executable_hooks:15:in `eval'
from /usr/local/rvm/gems/ruby-1.9.3-p547@veewee/bin/ruby_executable_hooks:15:in `<main>'
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Reactions: 6
- Comments: 40
Links to this issue
Commits related to this issue
- drop sudo on virt commands ERROR internal error: qemu unexpectedly closed the monitor: 2020-05-14T17:31:41.184108Z qemu-system-x86_64: -drive file=/home/travis/build/williamcroberts/selinux/Fedora... — committed to williamcroberts/selinux by deleted user 4 years ago
- extra warning for libwirt error, closes #996 — committed to pigram86/veewee by mpapis 10 years ago
SOLVED: found a way. Changing /etc/libvirt/qemu.conf to make things work. Uncomment user/group to work as root. Then restart libvirtd
Using Terraform with the libvirt Provider, I got the same error. But the problem was Apparmour: https://github.com/dmacvicar/terraform-provider-libvirt/issues/97
For testing purpose, I simply set
security_driver = "none"in/etc/libvirt/qemu.confand restart the serviceservice libvirtd restart.Encountered same issue, after digging ACL issue, I have to grant supplementary right on my HOME
If you copy your ISO image to
/var/lib/libvirt/images(and access it from there) all the problems will go away.I don’t think it is wise to make such edits letting qemu running as root. You should put the ISO file in a directory that is readable by qemu user, for example
/tmpSimply add your username to libvirt group and then instead of root replace with your username and group in
/etc/libvirt/qemu.conffile.No need to mess with acl or run it as root. After making necessary changes simply execute
systemctl restart libvirtdand ta-daThe qemu user needs search permissions all the way up the path, that means
chmod a+x. For me the issue was I had ACL’s set which blocked qemu… to remove them run “setfacl -b offending-dir/”You can tell if that’s your problem when unix permissions are correct but you can’t
lsevery upstream dir withsudo su -s /bin/bash qemuandlswith an account that does have access yields a result with a permission line that contains a dot such asdrwxrwxr-x.meaning extended ACL permissions.Tnx @codingenesis . Exactly what i needed! 😃
I have my images in a drive mounted in /media/user/Data
sudo setfacl -m u:libvirt-qemu:rx /media/userfixed it.Murlock’s suggestions fixed the same issue for me as well. Only difference was the user was named “qemu” instead of “libvirt-qemo”
If none above worked for you (not even having qemu run as
root:root; crazy uh?), here’s another workaround that did the trick for me: instead of using the libvirt volume provider for your disks, in your machine XMLs, use plain files instead.E.g., instead of this:
<disk type='volume' device='disk'> ... </disk>Use this:<disk type='file' device='disk'> .... </disk>Edit: turns out it was AppArmour, denying accessing the volume through the libvirt pool interface as stated here https://github.com/jedi4ever/veewee/issues/996#issuecomment-497976612
After trying almost all of the above, a very simple “chmod all” fix appeared when someone over at StackExchange explain what kind of perms Qemu needs.
sudo chmod a+x [path_to_volume_pool]Explanation given:
Thanks friend, I managed to solve it by changing the user and group to root in the
/etc/libvirt/qemu.conffile and also changing the permissions of the folder where the disks are withchmod a+xhttps://github.com/jedi4ever/veewee/issues/996#issuecomment-536519623
mrcloudhacker had the best an easiest solution.
If anybody is still looking to fix this and it’s neither acl, perms or apparmor, Ubuntu 22.04 now has selinux. So disabling security_driver here is mandatory
@vap0rtranz In my case file was /media/username/4TBBackup/testMech.raw
setfaclorsecurity_driver = "none"did not resolve it butIndeed solved it libvirtd needs execution permissions along the path
But … Why the hell it needs it ?
This is what worked for me. Thanks.
then,reboot