Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

virt-install error [closed]

I have setup kvm, libvirt on one of Dell poweredge1000m blades. I am using the following syntax for installing a virtual machine from an existing image (executing as root).

virt-install --name=vm_test --ram=1024 --arch=i686 --vcpus=1 --os-type=linux --import --disk path=/root/shared.qcow2,bus=virtio,format=qcow2 --graphics vnc,port=5901,listen=0.0.0.0,password=newone --noautoconsole --description --autostart

I am getting the following error.

Starting install...
ERROR    internal error process exited while connecting to monitor: char device redirected to /dev/pts/1
open /dev/kvm: Permission denied
failed to initialize KVM: Operation not permitted

Domain installation does not appear to have been successful.
If it was, you can restart your domain by running:
  virsh --connect qemu:///system start vm_test
otherwise, please restart your installation.

I have used exactly the same command with one of other desktop hosts and it works there. I can install a VM from virt-manager using an ISO image with virt-manager storing the disk image at default location.

It seems like a file permissions error to me as it is not working with /vms directory but is working with some other /home/vm directory.

Thanks for help in advance

like image 241
Jatin Kumar Avatar asked Jun 10 '11 14:06

Jatin Kumar


3 Answers

I got the same error message on a server, which has libvirt up for weeks. Setting libvirt to run as root (as mentioned in the link) didn't work for me. However, granting read & execute access to /var/lib/libvirt/images solved my problem.

chmod go+rx /var/lib/libvirt/images
chmod o-rwx /var/lib/libvirt/images/*
like image 51
clifflu Avatar answered Oct 18 '22 12:10

clifflu


If you follow all the instructions on creating vm using libvirt, you may still meet the error message above. The root cause is AppArmor which can be found on recent Ubuntu distributions. The easiest way is to remove AppArmor if security is not a concern.

The official documentation of Ubuntu gives many advice on disable AppArmor:

Disable AppArmor

like image 27
Lei Yang Avatar answered Oct 18 '22 11:10

Lei Yang


I had found the solution to my problem, here it is.

The real reason was that /vms was an NFS mount and its configuration(no_root_squash + rw) was such that it was required to be accessed over root.

By default libvirt runs a virtual machine with the user and group permissions of libvirt-qemu:kvm which would create trouble even if you run it with sudo privileges. So we need to set qemu process's user & group to root in /etc/libvirt/qemu.conf.

Also as others have pointed out, there can be multiple other reasons for this error and its sad that libvirt throws such a generic error.

The least frustrating solution is to give all permissions, disable selinux and make sure that it runs. Now one by one revoke the permissions testing that it works at each step and finally understanding why you were required to give the final set of permissions.

like image 2
Jatin Kumar Avatar answered Oct 18 '22 12:10

Jatin Kumar