5

I am trying to migrate a KVM guest from one Ubuntu 14.04 host to another by following the steps outlined here.

I now have the "state" file, xml configuration, and qcow2 img file in a single folder on the new host, and made sure to update the xml configuration to point to the new location of the qcow2 image file.

When I try to run virsh create [guest-id].xml I get the following error message:

error: internal error: process exited while connecting to monitor: 
qemu-system-x86_64: -drive file=/media/stuart/storage2/kvm/dns.technostu.com/dns.technostu.com.img,if=none,id=drive-virtio-disk0,format=raw: 
could not open disk image /media/stuart/storage2/kvm/dns.technostu.com/dns.technostu.com.img: 
Could not open '/media/stuart/storage2/kvm/dns.technostu.com/dns.technostu.com.img': Permission denied

Debugging and Attempted workarounds

  • I have already added myself to the libvirtd group and re-logged in.

  • I made sure the filepaths were correct

  • I changed the ownership of the .img file to myself, but after running the command with and without sudo, the ownership of the file keeps changing to root:root with permissions -rwxr-xr-x

  • I tried running

    sudo apt-get install apparmor-profiles apparmor-utils
    sudo aa-complain /usr/lib/libvirt/virt-aa-helper
    

    From this post, but that hasn't worked.

  • I tried changing the emulator in the xml file as specified here.

What do I need to do in order to "import" the guest on the new host on Ubuntu 14.04?

3 Answers 3

5

I had a similar problem.

Adding my user to the kvm group

sudo usermod -a -G kvm username

Then I made sure that /dev/kvm is owned by root and group kvm

Afterwards I changed the ownership of my existing VM (converted from VirtualBox) to username:kvm

Finally I set group=kvm user=username in my qemu.conf This fixed it for me

4

Turning the computer off and on again (I hadn't rebooted since installing kvm) changed the error message to:

error: internal error: process exited while connecting to monitor: qemu-system-x86_64

When Googling that error, I found this post which recommended adding the following to

user = "root"
group = "root"

to the /etc/libvirt/qemu.conf file. Be sure to include the quotes.

After another reboot, I was able to run virsh create [guest-id].xml successfully.

1
  • Similar problem solved after adding these lines. Then run sudo virt-manager without any reboot its work.
    – EsmaeelE
    Mar 8, 2020 at 3:04
0

Running QEMU with root privileges is not advised, as from version 6.0.0 it would not strip the Linux capabilities.

In my case it was AppArmor. I wanted to add an SSDT file for a battery to the VM. There are some folders which AppArmor allows access to, and others (like /home/something) are just not allowed. /var/lib/libvirt/images/ is one of the allowed folders. Although i placed my file there, it was still not allowed by AppArmor policy (as can be seen with sudo cat /var/log/kern.log | grep -C 10 apparmor | grep -C 10 qemu). What worked was adding /var/lib/libvirt/images/SSDT1.dat rk in /etc/apparmor.d/libvirt/TEMPLATE.qemu like this:

#
# This profile is for the domain whose UUID matches this file.
#

#include <tunables/global>

profile LIBVIRT_TEMPLATE flags=(attach_disconnected) {
  #include <abstractions/libvirt-qemu>
  /var/lib/libvirt/images/SSDT1.dat rk,
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .