os.firmware="efi" silently clears firmware path

Software environment

  • Operating system: linux
  • Architecture: x86_64
  • kernel version: all
  • libvirt version: 8.4.0
  • Hypervisor and version: qemu 7.0.0

Description of problem

when <os firmware='efi'> is set, the default firmware path overrides the path in the XML, erasing it.

Steps to reproduce

  1. edit a domain xml
  2. alter os entry to:
<os firmware='efi'>
    <type arch='x86_64' machine='pc-q35-7.0'>hvm</type>
    <loader>/opt/OVMF/OVMF_CODE.fd</loader>
    <boot dev='hd'>
</os>
  1. Upon saving, loader path is removed.
  2. after removing firmware='efi' attribute from os everything behaves as expected.

Additional information

The xml configuration passes checks, and other XML changes made at the same time are saved.

I suggest either throwing an error if os.firmware="efi" and the loader path is set, or only setting the default if the entry is empty.