Description of problem: When a domain with no devices is created, libvirt explicitly adds "<boot dev='hd'>" to the domain definition. If one then tries to attach a device with a "<boot index='1'>", this fails. When one tries to redefine the domain XML without the "<boot dev='hd'>" element, libvirt simply readds it, so it cannot be removed before calling virDomainAttachDeviceFlags. This causes the problem where a domain created with no NICs and no drives cannot have any devices attached with a boot index definition through virDomainAttachDeviceFlags. Version-Release number of selected component (if applicable): Tested on 1.2.16 How reproducible: 100% of the time Steps to Reproduce: 1. echo '<domain type="kvm"> <name>myvm</name><memory unit="KiB">200000</memory><os><type arch="x86_64">hvm</type></os></domain>' > /tmp/myvm.yml 2. virsh create /tmp/myvm.yml 3. echo "<interface type='network'><source network='default'/><target dev='vnet0'/><alias name='net0'/><model type='virtio'/><boot order='1'/></interface>" > /tmp/myvm-nic.xml 4. virsh attach-device myvm /tmp/myvm-nic.xml 5. virsh dumpxml --inactive --security-info myvm | grep -v 'boot dev' > /tmp/myvm-nobootdev.xml 6. virsh define /tmp/myvm-nobootdev.xml 7. virsh attach-device myvm /tmp/myvm-nic.xml Actual results: error: unsupported configuration: per-device boot elements cannot be used together with os/boot elements Expected results: The explicitly added "<boot dev='hd'>" gets removed and an interface gets added with "<boot index='1'>" Additional info:
These are some possible solutions: - Allow the removal of "<os><boot dev='foo'/></os>" element through XML redefinition (detect that it was explicitly removed by the user) - Allow the removal of "<os><boot dev='foo'/></os>" element through an API method - Internally remove "<os><boot dev='foo'></os>" when a device gets attached with a defined "<boot order='foo'/>" (this assumes that whoever attaches that device takes responsibility for boot ordering) I do not see a use case where the device attachment should be refused (and the os boot element kept) when a device gets attached with a defined boot order, so that seems preferable to me, but I could be missing something.
We could probably special case it: when there's no other bootable devices attached to the VM, have <boot order=X/> override the default <boot dev='hd'/> setting
Thank you for reporting this issue to the libvirt project. Unfortunately we have been unable to resolve this issue due to insufficient maintainer capacity and it will now be closed. This is not a reflection on the possible validity of the issue, merely the lack of resources to investigate and address it, for which we apologise. If you none the less feel the issue is still important, you may choose to report it again at the new project issue tracker https://gitlab.com/libvirt/libvirt/-/issues The project also welcomes contribution from anyone who believes they can provide a solution.