KVM can't access qcow2 images storend on an external HDD

546

Solution 1

The problem I was having was that my system (Fedora 27) automatically mounts new drives (external HDDs, USB, SD) to

/run/media/(username)/(device name)

For whatever reason this causes the permissions issue. What I did to fix the issue was unmount the drive from that location as root, and then mount it to /mnt. My USB thumb drive is /dev/sdc1 on my system so I did the following.

# su  -     (then enter root password)
# umount  /run/media/yourusername/devicename
# mount  /dev/sdc1 /mnt        (mount usb to /mnt)

After that I just made sure to have symbolic links from the original location of the qcow2 drives to the new location (still as root)

# cd  /var/lib/libvirt/images
# ln  -s  (new target)  (link name)   

so if your vm is named MyVM

# ln  -s  /mnt/Myvm.qcow2  MyVm.qcow2

Once I saw that my VMs were now working, I edited /etc/fstab to automatically mount the drive at /mnt. The folders and qcow2 drives were owned by my standard user account and group. I am sure there are better ways to do it, but this is what worked for me.

Solution 2

This is because the Qemu requires execution permission along the image file's path. If the image is in the mounted disk, it requires +x permission in the /media/$username

For me, I fixed this issue by this command:

sudo chmod a+x /media/houcheng/

For rest of the detail, please see this.

Solution 3

Solution: Run Virtmanager as root, choose create a new VM -> select 'Import existing disk image' and browse it. After clicking continue it will ask whether you want it to fix permission issues or not for that path. After choosing 'Yes', it fixes the permission issue and will work when it's running as a normal user too.

Solution 4

This a permission issue for qemu accessing the folder where VMs are stored.

I had an issue who looks like this, I resolved it by giving qemu access permissions to the folder (it was /home/mos in my case):

$ sudo setfacl -m u:qemu:x /home/mos
Share:
546

Related videos on Youtube

Mateusz
Author by

Mateusz

Updated on September 18, 2022

Comments

  • Mateusz
    Mateusz almost 2 years

    What is a correct notation of these two instructions?

     lw $t1, array($t2) 
     la $t3, address
    

    I think that it would be

    Reg[t1] := Memory[array + t2]
    Reg[t3] := address
    

    But I am not sure. Because if lw loads content of memory, then la will load only address, am I right?

    lw $t1, address # Reg[t1] = Memory[address]
    
    • Peter Cordes
      Peter Cordes over 2 years
      Note that la is only a pseudo-instruction, the machine never even sees it directly. Same for lw with a label address, unless that label happens to be in the low 16 bits of address space so the assembler can use a single lw imm16($zero) instruction without lui.
  • Mateusz
    Mateusz over 8 years
    so can the la be written is notation similiar to this one I provided?
  • George Moralis
    George Moralis over 8 years
    in special cases probably. Look here : cs.umd.edu/class/sum2003/cmsc311/Notes/Mips/pseudo.html
  • Weylyn Savan
    Weylyn Savan over 7 years
    virsh pool-dumpxml default > new_pool.xml error: failed to get pool 'default' error: Storage pool not found: no storage pool with matching name 'default' Also virsh pool-list list shows no pools.
  • Weylyn Savan
    Weylyn Savan over 7 years
    Ok, default pool created and is active. It points to the directory where i store the images. Permissions: mode: 0777, owner: 119, group: 128. Still access denied.
  • RobotJohnny
    RobotJohnny over 7 years
    The above has worked for me in the past. I'm not sure what the issue could be other than ownership without seeing your setup. an alternate method you could try, is a symlink on the additional storage directory to /var/lib/libvirt/images directory: ln -sf /path/to/additional/storage /var/lib/libvirt/images Permissions/ownership will need to be identical for that to work, but I can't vouch for that working definitely, as I haven't tested it myself
  • Weylyn Savan
    Weylyn Savan over 7 years
    It's still not working. There's a video link in the question so you can see this part of my setup. For some reason it won't play from Google Drive so you have to download it but don't worry, it's only 17,1 MB.
  • haidarvm
    haidarvm almost 5 years
    no one seeing this ? it's works great on my RHEL 8 system just move any qcow2 & iso to /home folder. Thanks a lot :)
  • annahri
    annahri over 3 years
    Turning off selinux is not an actual answer. It's like when you want to shutdown your machine by pulling off the power plug.
  • poleguy
    poleguy over 3 years
    Well, not quite "not an actual answer".... Running this command did allow me to access the images... so it is technically an answer. However, I agree you really should only do this to debug the issue and then put in an actual fix. I'll add a note to this affect.
  • Peter Cordes
    Peter Cordes over 2 years
    George (and @Mateusz): lw $reg, address is also a pseudo-instruction, using lui / lw. (Unless you're using MARS or something configured with the data section starting at a low address, so lw $t1, address can assemble to lw $t1, address($zero), i.e. the full address fitting in the 16-bit-sign-extended displacement in the I-type lw instruction.) So the question is correct about the first lw, but the second lw is the same as the la, whether you consider that right or wrong. Note that $at isn't needed here; you can lui / ori both into $t3