stackhpc / ansible-role-libvirt-vm

This role configures and creates VMs on a KVM hypervisor.
128 stars 67 forks source link

VM created but it wont boot #25

Closed ognjen011 closed 4 years ago

ognjen011 commented 5 years ago

Hi i am having a problem using this module correctly, when i create a vm instance i am unable to actually get it to boot. I did check the xml and it seem to create storage in a completely different way which in might be ok but i noticed three things for me

  1. It wont boot permission error on storage create as pool instead of source file=. If manually fixed then i then hit the next problem
  2. No media is created by the module and it wont boot. If i manually fix xml then
  3. vnc part is set to /usr/bin/kvm and not to /usr/bin/kvm-spice.

Anyway deleting the whole instance and keeping the same storage created by the module i am able to manually create instance and boot with no problems. I am using just a basic example provided to create a vm in readme.

markgoddard commented 5 years ago

Perhaps you could provide some more info on what you changed in the XML?

ognjen011 commented 5 years ago

Sure here is an example of Manual instance:

    <devices>
   <emulator>/usr/bin/kvm-spice</emulator>
   <disk type='file' device='disk'>
    <driver name='qemu' type='qcow2'/>
    <source file='/var/lib/libvirt/images/123.img'/>
    <target dev='vda' bus='virtio'/>
    <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
   </disk>

created by the module:

  <emulator>/usr/bin/kvm</emulator>
   <disk type='volume' device='disk'>
     <driver name='qemu' type='qcow2'/>
     <source pool='host1' volume='122-pavm.img'/>
     <target dev='vdb' bus='virtio'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
   </disk>

Notice the source line target and address lines that are different.

Then this is missing but this could be me not doing this correctly and i am then not able to connect an image. I guess i could provide image inside module.

 <disk type='file' device='cdrom'>
     <driver name='qemu' type='raw'/>
    <source file='/var/lib/libvirt/images/ubuntu-18.04.1-live-server-amd64.iso'/>
    <target dev='hda' bus='ide'/>
     <readonly/>
    <address type='drive' controller='0' bus='1' target='0' unit='1'/>
   </disk>

Finally if i try to delete the instance by hand it says that i t cannot delete the storage. So there is something not right... any help would be great. Delete does work if i set instance to absent in the role.

markgoddard commented 5 years ago

I only see kvm and kvm-spice lines

ognjen011 commented 5 years ago

Added xml in that previous post.

markgoddard commented 5 years ago

It sounds a bit like your storage pool is setup differently than what we've tested with. Are you able to create volumes? e.g. can you run commands similar to those in https://github.com/stackhpc/ansible-role-libvirt-vm/blob/master/files/virt_volume.sh#L78 to create volumes?

For the emulator, you can configure this via libvirt_vm_emulator. If you don't set it the role will try to detect it.

For the CD ROM, we normally use preinstalled qcow2 disk images rather than installer ISOs. Adding CDROM support would probably need a code change.

ognjen011 commented 5 years ago

Ok thanks let me look into my storage, it is set to type DIR not a pool. The other parts are less important this is for the preconfigured image anyway. I will try out libvirt_vm_emulator

Running those commands does actually create volume fine no errors, i think the problem is when you reference the image as pool and volume in xml rather than source file things break.

ognjen011 commented 5 years ago

Got it working thanks for the help. Just made some edits to the template file.

goetzk commented 4 years ago

Looks like this issue is something I just spent several days debugging.

For the record, in our case it was due to Apparmour's lack of support for storage pools. https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1677398

In our case the following commit fixed it by moving us from pools to file - as it seems @ognjen011 did.

https://github.com/stackhpc/ansible-role-libvirt-vm/pull/48/commits/722d77af09457aa72add7eb15fb4c11584a29788

Wish I looked here in the issue list a week ago...!