Invalid libvirt xml - unknown driver format value

Problem:
If I try to create a new host via Foreman on a libvirt kvm hypervisor I get the following error message:

Unable to save
Failed to create a compute srv01-02 (Libvirt) instance test01-03: Error saving the server: Call to virDomainDefineXML failed: unsupported configuration: unknown driver format value '' 

in the debug log of libvirtd you can see that the type field in the disk driver is empty. I guess this could be related to the switch to the Nokogiri::XML::Builder which @ekohl has done.

Expected outcome:

Foreman should be able to generate a correct xml definition for the libvirt vm and create the new host.

Foreman and Proxy versions:

Foreman and Proxy version: 3.14.0

Foreman and Proxy plugin versions:

none or not relevant

Distribution and version:

Debian 12 (Bookworm)

Other relevant data:
libvirtd debug log snippet

2025-04-26 21:00:53.070+0000: 232708: debug : virNetServerProgramDispatch:280 : prog=536903814 ver=1 type=0 status=0 serial=114 proc=11
2025-04-26 21:00:53.070+0000: 232708: debug : virThreadJobSet:93 : Thread 232708 (rpc-libvirtd) is now running job remoteDispatchDomainDefineXML
2025-04-26 21:00:53.070+0000: 232708: debug : remoteDispatchDomainDefineXMLHelper:5246 : server=0x556ab6350080 client=0x556ab6370150 msg=0x556ab6373b10 rerr=0x7f9d68bfc9f0 args=0x7f9d54000e30 ret=0x7f9d54019af0
2025-04-26 21:00:53.070+0000: 232708: debug : virDomainDefineXML:6611 : conn=0x7f9d1c014990, xml=<?xml version="1.0"?>
<domain type="kvm">
  <name>test01-03</name>
  <memory>524288</memory>
  <vcpu>1</vcpu>
  <os>
    <type arch="x86_64" machine="q35">hvm</type>
    <boot dev="network"/>
    <boot dev="hd"/>
  </os>
  <features>
    <acpi/>
    <apic/>
  </features>
  <cpu mode="host-passthrough" check="none" migratable="on"/>
  <clock offset="utc">
    <timer name="rtc" tickpolicy="catchup"/>
    <timer name="pit" tickpolicy="delay"/>
    <timer name="hpet" present="no"/>
  </clock>
  <devices>
    <disk type="block" device="disk">
      <driver name="qemu" type=""/>                                           <---- type is empty
      <source dev="/dev/vg01/test01-03-disk1"/>
      <target dev="vda" bus="virtio"/>
    </disk>
    <interface type="bridge">
      <source bridge="br91"/>
      <model type="virtio"/>
    </interface>
    <channel type="unix">
      <target type="virtio" name="org.qemu.guest_agent.0"/>
    </channel>
    <rng model="virtio">
      <backend model="random"/>
    </rng>
    <serial type="pty">
      <target port="0"/>
    </serial>
    <console type="pty">
      <target port="0"/>
    </console>
    <input type="tablet" bus="usb"/>
    <input type="mouse" bus="ps2"/>
    <graphics type="vnc" port="-1" autoport="yes" listen="0.0.0.0"/>
    <video>
      <model type="cirrus" vram="9216" heads="1"/>
    </video>
  </devices>
</domain>

2025-04-26 21:00:53.070+0000: 232708: info : virObjectRef:400 : OBJECT_REF: obj=0x7f9d1c06e130
2025-04-26 21:00:53.070+0000: 232708: info : virObjectNew:256 : OBJECT_NEW: obj=0x7f9cf4014690 classname=qemuDomainVcpuPrivate
2025-04-26 21:00:53.070+0000: 232708: info : virObjectNew:256 : OBJECT_NEW: obj=0x7f9d5401c0a0 classname=virStorageSource
2025-04-26 21:00:53.070+0000: 232708: info : virObjectNew:256 : OBJECT_NEW: obj=0x7f9ca8003870 classname=qemuDomainDiskPrivate
2025-04-26 21:00:53.070+0000: 232708: error : virDomainDiskDefDriverSourceParseXML:7750 : unsupported configuration: unknown driver format value ''
2025-04-26 21:00:53.070+0000: 232708: info : vir_object_finalize:319 : OBJECT_DISPOSE: obj=0x7f9d5401c0a0
2025-04-26 21:00:53.070+0000: 232708: info : virObjectUnref:378 : OBJECT_UNREF: obj=0x7f9d5401c0a0
2025-04-26 21:00:53.070+0000: 232708: info : vir_object_finalize:319 : OBJECT_DISPOSE: obj=0x7f9ca8003870
2025-04-26 21:00:53.070+0000: 232708: info : virObjectUnref:378 : OBJECT_UNREF: obj=0x7f9ca8003870
2025-04-26 21:00:53.070+0000: 232708: info : vir_object_finalize:319 : OBJECT_DISPOSE: obj=0x7f9cf4014690
2025-04-26 21:00:53.070+0000: 232708: info : virObjectUnref:378 : OBJECT_UNREF: obj=0x7f9cf4014690
2025-04-26 21:00:53.070+0000: 232708: info : virObjectUnref:378 : OBJECT_UNREF: obj=0x7f9d1c06e130
2025-04-26 21:00:53.070+0000: 232708: debug : virThreadJobClear:118 : Thread 232708 (rpc-libvirtd) finished job remoteDispatchDomainDefineXML with ret=-1

I think this is the same issue as reported here: Bug #38081: Error 422 "unsupported configuration: unknown driver format value '' " while creating VM in Call to virDomainDefineXML - Foreman

Thank you for the hint, I did not discover this bug. I was able to reproduce the problem as described in the issue Volume loses its format_type when saved · Issue #169 · fog/fog-libvirt · GitHub.
@evgeni do you know why the problem does not affect more foreman users?

Ran Into this same issue. Has a fix been released?

Version 3.14.0

Error from Libvirt hypervisor logs:

libvirtd: 2025-05-12 19:34:42.113+0000: 1887: error : virDomainDiskDefDriverParseXML:9656 : unsupported configuration: unknown driver format value ‘’

I posted a patch on Sunday, but I haven’t had a chance to verify it yet: Deal with missing volume_type by ekohl · Pull Request #172 · fog/fog-libvirt · GitHub

So I pulled down the compute provider for Libvirt on Monday and the volume.rb has been updated to reflect the changes you made - still seeing same errors.

You only mention volume.rb, but the more critical part is in server.rb. Did you also patch that? In case you’re unaware, you can add .patch to a PR URL so https://github.com/fog/fog-libvirt/pull/172.patch gives you the patch. Then can easily apply it with curl $url | patch -p1.

Ah! Thanks thats a good tip.

Unfortunately - still same issues:

2025-05-13T09:40:19 [W|app|0a50ab62] Rolling back due to a problem: [#<Orchestration::Task:0x00007fd42995e458 @name="Set up compute instance hope-schilder.cheeky.local", @id="Set up compute instance hope-schilder.cheeky.local", @status="failed", @priority=3, @action=[#<Host::Managed id: nil, name: "hope-schilder.cheeky.local", last_compile: nil, last_report: nil, updated_at: nil, created_at: nil, root_pass: [FILTERED], architecture_id: 1, operatingsystem_id: 2, ptable_id: 142, medium_id: nil, build: false, comment: "", disk: "", installed_at: nil, model_id: nil, hostgroup_id: nil, owner_id: 4, owner_type: "User", enabled: true, puppet_ca_proxy_id: nil, managed: true, use_image: nil, image_file: nil, uuid: nil, compute_resource_id: 1, puppet_proxy_id: nil, certname: nil, image_id: nil, organization_id: 1, location_id: 2, type: "Host::Managed", otp: nil, realm_id: nil, compute_profile_id: nil, provision_method: "build", grub_pass: nil, global_status: 0, lookup_value_matcher: [FILTERED], pxe_loader: "PXELinux BIOS", initiated_at: nil, build_errors: nil, creator_id: nil>, :setCompute], @created=1747147219.3897247, @timestamp=2025-05-13 14:40:19.509838123 UTC>]
2025-05-13T09:40:19 [I|app|0a50ab62] Processed 1 tasks from queue 'Host::Managed Main', completed 0/9
2025-05-13T09:40:19 [E|app|0a50ab62] Task 'Set up compute instance hope-schilder.cheeky.local' *failed*
2025-05-13T09:40:19 [E|app|0a50ab62] Task 'Query instance details for hope-schilder.cheeky.local' *canceled*
2025-05-13T09:40:19 [E|app|0a50ab62] Task 'Create DHCP Settings for hope-schilder.cheeky.local' *canceled*
2025-05-13T09:40:19 [E|app|0a50ab62] Task 'Create Reverse IPv4 DNS record for hope-schilder.cheeky.local' *canceled*
2025-05-13T09:40:19 [E|app|0a50ab62] Task 'Deploy TFTP PXELinux config for hope-schilder.cheeky.local' *canceled*
2025-05-13T09:40:19 [E|app|0a50ab62] Task 'Deploy TFTP PXEGrub2 config for hope-schilder.cheeky.local' *canceled*
2025-05-13T09:40:19 [E|app|0a50ab62] Task 'Deploy TFTP PXEGrub config for hope-schilder.cheeky.local' *canceled*
2025-05-13T09:40:19 [E|app|0a50ab62] Task 'Deploy TFTP iPXE config for hope-schilder.cheeky.local' *canceled*
2025-05-13T09:40:19 [E|app|0a50ab62] Task 'Power up compute instance hope-schilder.cheeky.local' *canceled*
2025-05-13T09:40:19 [E|app|0a50ab62] Failed to save: Failed to create a compute wrangler.cheeky.local (Libvirt) instance hope-schilder.cheeky.local: Error saving the server: Call to virDomainDefineXML failed: unsupported configuration: unknown driver format value ''
 0a50ab62 |

Just to check off the boxes: you did restart the foreman service after with systemctl restart foreman?

Ah! That did the trick! Thank you sir!