Image based provisioning on KVM (Libvirt)

I’m trying to create a new VM on Libvirt from the image. Unfortunately, I get this error:
Failed to save: Failed to create a compute am2-infravmhost001 (Libvirt) instance am2-testapi016.dc.egnyte.lan: ERF42-3305 [Foreman::Exception]: Unable to find template /var/lib/libvirt/images/am2-testapi016
I configured a path to this image in Compute Resources -> am2-infravmhost001 -> Images.
I tried to change permission to this file but without success. I tried also convert image to qcow2 format using qemu-img convert. Without success as well.

Thank you for your help.

I tried to use image on gateway as well and path to the image was: http://am2-gateway01/kvm-images/kvm-medium_latest and still I get the same error.

Hello, you put an absolute path to the image file, including the extension and everything. Make sure that libvirt (not foreman) can access the file. Check permissions, group, SELinux etc.

Path to the file is correct in 100%. I tried with permissions but without success. SELinux is disabled. I don’t have idea what else I can check.

Show me screenshot of the form with the image path and then do:

ls -laZ /path/to/the/image

And pastebin the output.

Also google found: ERF42-3305 - Foreman

When launching a libvirt host using a template, the “image” has to have the full path to the base template.

First go to Infrastructure > Compute resources > libvirt CR > Images and check that the image in use has the full path to the base image file on the hypervisor. Check with “ls -l PATH” that it’s correct.

You may need to refresh libvirt’s view of the images available using virsh pool-refresh default (or the appropriate pool name from virsh pool-list ).

# ls -laZ /var/lib/libvirt/images/am2-testapi016

-rwxrwxrwx qemu qemu ?                                /var/lib/libvirt/images/am2-testapi016

I tried all of this stuff as well.

Are you sure you are creating the VM in the “default” storage domain which has path set to /var/lib/libvirt/images? Our compute resource provider is only tested with “default” storage and network domains.

Ok, I solved this issue with changing permissions to 0744.

That’s weird because now I can use other images with various permissions as well. No idea what happened because I didn’t change anything.

Maybe your pool got refreshed.

I ran into ERF42-3305 shortly after manually putting an image file in my pool directory (basically just the time it took me to define the image in the Compute Resource).

After virsh pool-refresh guest-image-pool (on the libvirt machine), I could use the image from foreman (Satellite 6.7 to be precise) just fine. Obviously adjust to your pool name.

1 Like