QEMU / KVM does not run gives permission error

APTI

Well-Known Member
Joined
Dec 20, 2022
Messages
699
Reaction score
526
Credits
5,947
I am trying to set up a VM using directions because I am attempting to set up a VM for mac OSX Catalina. I have it all hopefully ready but when I try to start the VM using virtual machine manager I get an error. tell me I do not have permission to access the ESP.qcow2 file. I checked it and it is set so that the owner is me and the same as other working VM files. The permissions I set to 0777 and it made no difference. copy the files, move the files all gives the same error.

I used this tutorial to set it up..

I am running on fedora 40 and have multiple other VM for various windows and linux installs that all work fine. This is the only one, of course the only one set up special because of the availability of mac OS. I use VM to develop software and or to test things for clients. This is the only one that eludes me.
 


I don't know if yours is setup different, but normally qemu owns my qcow2 files.

root@absTower:~# cd /var/lib/libvirt/images/
root@absTower:/var/lib/libvirt/images# ls -l
total 21536344
-rw-------. 1 qemu qemu 53695545344 Jan 7 15:39 centOs10.qcow2
-rw-------. 1 qemu qemu 53695545344 Jan 4 02:02 fedora.qcow2
-rw-------. 1 qemu qemu 53695545344 Jan 4 09:44 ubuntu24.10.qcow2
 
I don't know if yours is setup different, but normally qemu owns my qcow2 files.

root@absTower:~# cd /var/lib/libvirt/images/
root@absTower:/var/lib/libvirt/images# ls -l
total 21536344
-rw-------. 1 qemu qemu 53695545344 Jan 7 15:39 centOs10.qcow2
-rw-------. 1 qemu qemu 53695545344 Jan 4 02:02 fedora.qcow2
-rw-------. 1 qemu qemu 53695545344 Jan 4 09:44 ubuntu24.10.qcow2
mine is different. my ownership is my account but otherwise the rest is the same. I did try changing the ownership to qemu and yes did confirm that is the correct user. Nothing changed still got the permission denied error.
 
Another whom might have ideas is Maarten @f33dm3bits - IIRC he has extensive experience with QEMU/KVM.

He should swing through in 6-8 hours (Netherlands)

Wiz
 
mine is different. my ownership is my account but otherwise the rest is the same. I did try changing the ownership to qemu and yes did confirm that is the correct user. Nothing changed still got the permission denied error.
Please post your permissions of images directory and qcow2 files within it.

Verify you're in libvirt group with groups, if not run sudo adduser <your_username> libvirt then reboot.
 
I have it all hopefully ready but when I try to start the VM using virtual machine manager I get an error.
I was messing around with my Qemu/KVM setup and I ran into I think the same problem you are having. It's most like what @CaffeineAddict is asking about.
Please post your permissions of images directory and qcow2 files within it.

mine is different. my ownership is my account but otherwise the rest is the same.
Ownership should be qemu on the qcow2 files, the only difference is that I have set a custom location, which is not /var/lib/libvirt/images but in my homedirectory. So the other option you could do is the following.

1. Go to: Edit -> Storage
2. Stop Pool and Delete Pool (the "default" one that is).
3. Add a new storage pool by clicking on the "plus" sign(bottom left)
4. Give it the name "default" and select the actual default images directory or a custom directory. If you do the latter and you are using Fedora you will have to configure the selinux context(virt_image_t) for that custom directory as well.
5. Click "Finish". If the ownerhship or/and permissions aren't correct, it will ask if if it's okay if you want libvirt to correct and set the correct permissions.

This has worked for me every single time. Another tip, add your login user to the libvirt group and then logout and backing again. This will prevent you from having to type your user's sudo password each time you want to use virt-manager to manage your virtual machines.

This is how my custom directory looks.
Code:
ls -lZ Qemu                                                                                                                                          
drwxr-xr-x. qemu    libvirt unconfined_u:object_r:virt_image_t:s0 60 B Sun Jan  5 13:02:36 2025
drwxr-xr-x. maarten maarten unconfined_u:object_r:virt_image_t:s0  0 B Sun Jan  5 13:56:42 2025

ls -lZ Qemu/images                                                                                                                                       
.rw-rw-r--. qemu qemu    unconfined_u:object_r:virt_image_t:s0 30 GB Tue Jan  7 23:03:54 2025 ansible.qcow2
.rw-rw-r--. qemu libvirt unconfined_u:object_r:virt_image_t:s0 30 GB Tue Jan  7 20:50:29 2025 workstation.qcow2

This is how my default images directory looks.
Code:
ls -lZ /var/lib/libvirt | grep images
drwx--x--x. 1 root root system_u:object_r:virt_image_t:s0     0 dec 14 01:00 images
 
Last edited:
Just reinstalling a new vm to test something so will change my permissions again of my custom storage location and post the output here.
 
Just reinstalling a new vm to test something so will change my permissions again of my custom storage location and post the output here.
Quite odd I can't get my libvirt to get that permission error again, but I do remember my steps in posts #6 help me solve it when I ran into it, to have it set the permissions set correctly for me.
 
After having redone my custome storage location these permissions seem to work for me and my user is still in the libvirt group.
Code:
ls -lZ Qemu                                                                                                                                                        

drwxr-xr-x. maarten maarten unconfined_u:object_r:virt_image_t:s0 60 B Wed Jan  8 09:17:30 2025 images
drwxr-xr-x. maarten maarten unconfined_u:object_r:user_home_t:s0   0 B Wed Jan  8 09:15:00 2025  isos

ls -lZ Qemu/images                                                                                                                                                                                                                                                  
.rw-------. qemu qemu system_u:object_r:svirt_image_t:s0:c354,c938 30 GB Wed Jan  8 09:52:11 2025  ansible.qcow2
.rw-------. qemu qemu system_u:object_r:svirt_image_t:s0:c161,c597 30 GB Wed Jan  8 09:52:05 2025 workstation.qcow2
 
The permissions I set to 0777 and it made no difference. copy the files, move the files all gives the same error.

I am running on fedora 40 and have multiple other VM for various windows and linux installs that all work fine. This is the only one, of course the only one set up special because of the availability of mac OS. I use VM to develop software and or to test things for clients. This is the only one that eludes me.
This makes me think it could me an selinux issue so you can ignore my other replies since I am still in the process of waking up and missed the other comments you mad here. Any chance you moved that file over to that location instead of copying it over to that location? Try running "sudo restorecon -v ESP.qcow2" on that file?
 
Last edited:
This makes me think it could me an selinux issue so you can ignore my other replies since I am still in the process of waking up and missed the other comments you mad here. Any chance you moved that file over to that location instead of copying it over to that location? Try running "sudo restorecon -v ESP.qcow2" on that file?
let me put some answers for you here.
1.. I have selinux disabled (PITA). so that should not be issue
2.. I am using the qcow2 file in the place it was created. I did try copy and move but ended up going back to original
3.. The qcow2 file is in my personal home folder, well a sub folder of it.

basically I have already tried the norms. All other vm work fine. this is the only one and it has to be something to do with how it was created using the video in the original post.

I will add myself to the qemu group and try again tho. I am leery of changing too much because I don't want to break the working stuff. So I would like to keep my fix specific to this VM and not change qemu which seems fine otherwise. Like I said, don't want to break something else.

and for caffieneaddict... this is the folder view. I do not think it will help you much.
Screenshot from 2025-01-08 10-02-01.png
 
3.. The qcow2 file is in my personal home folder, well a sub folder of it.
From your screenshot it looks like that ESP.qcow2 file is located in a different location than your other images under: /var/libvirt/images. Is that location even listed under your storage pools? Under: Connection Details -> Storage?

Run the following in a terminal.
Code:
sudo -u qemu -s /bin/bash
Then see if you can access the location of where that file ESP.qcow2 is located, if at any point you get a perimission denied, you will know that you will have to fix some permissions there.
 
From your screenshot it looks like that ESP.qcow2 file is located in a different location than your other images under: /var/libvirt/images. Run the following in a terminal.
Code:
sudo -u qemu -s /bin/bash
Then see if you can access the location of where that file ESP.qcow2 is located, if at any point you get a perimission denied, you will know that you will have to fix some permissions there.
I have copied the file to the libvirt/images and still same issue. That was the 3rd thing I tried. My other images are in /home/pos/.local/share/gnome-boxes/images/ which seems to be the default when I installed. I tried putting it all there and no help either.

UPDATE: Attention update: my VM blew up. so no longer a worry. Now I am going to change my request.

The reason for all this is because I need a VM with mac osx sonoma or better. I have not been able to do this and when I posted for help it was the furthest I have gotten and got my hopes up. Anybody gotten mac osx installed to a vm? how do I do it?
 
The reason for all this is because I need a VM with mac osx sonoma or better. I have not been able to do this and when I posted for help it was the furthest I have gotten and got my hopes up. Anybody gotten mac osx installed to a vm? how do I do it?
I found a recent Github repo that gives you instructions on how to do it, except the instructions are for Debian/Ubuntu but you should be able to translate that to Fedora packages.
 
Anybody gotten mac osx installed to a vm?

I'm reluctant to comment, for reasons that will become obvious.

The answer to that question is, "Yes, I have."

how do I do it?

I used VirtualBox.

This was quite some time ago and I don't know the specifics. It did involve some settings tweaking. I didn't figure it out on my own, I followed someone's tutorial that I found online.

And, again, this was quite a while ago. If asked to remember even a scintilla of the process, I'd be hard pressed to recall it. So, I'd just look for a recent tutorial.

HOWEVER... (And this is why I did reply.)

If you check in the newest versions of VirtualBox, it actually offers MacOS as an option when creating a new virtual machine. I haven't tried it. I can't vouch for it. I am not even sure how long it has been an option. It was not an option the last time I did this, I had to do it via a different route.
 
I found a recent Github repo that gives you instructions on how to do it, except the instructions are for Debian/Ubuntu but you should be able to translate that to Fedora packages.
that was the one I used and followed that got me into all this.
 

Members online


Top