Bug 1248514

Summary: cannot hotplug device with <boot order=X/> to VM with no devices, because XML defaults to <boot dev='hd'/>
Product: [Community] Virtualization Tools Reporter: infernix
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED DEFERRED QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: crobinso, dyuan, lmen, mzhan
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-03 17:11:54 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description infernix 2015-07-30 12:40:07 UTC
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:

Comment 1 infernix 2015-07-30 12:55:55 UTC
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.

Comment 3 Cole Robinson 2016-04-19 18:45:27 UTC
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

Comment 4 Daniel Berrangé 2020-11-03 17:11:54 UTC
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.