Description of problem: 'ports' element in virtio-serial controller is not match with the device quantity supported. If " ports='3' ", only 2 devices can connect to the controller. And suggest to improve the error message when there is no available virtio-serial address during hotplug. Version-Release number of selected component (if applicable): libvirt-3.9.0-7.el7.x86_64 How reproducible: 100% Steps to Reproduce: 1. start a guest with virtio-serial with ports='3', and 2 of them, port 1 and 2 have been used (no virtio console) # virsh dumpxml pc ... <controller type='virtio-serial' index='0' ports='3'> <alias name='virtio-serial0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> </controller> ... <channel type='spicevmc'> <target type='virtio' name='com.redhat.spice.0' state='disconnected'/> <alias name='channel1'/> <address type='virtio-serial' controller='0' bus='0' port='2'/> </channel> <channel type='unix'> <source mode='bind' path='/var/lib/libvirt/qemu/channel/target/domain-87-pc/org.qemu.guest_agent.0'/> <target type='virtio' name='org.qemu.guest_agent.0' state='connected'/> <alias name='channel2'/> <address type='virtio-serial' controller='0' bus='0' port='1'/> </channel> ... 2. hotplug a char device using virtio-serial address, it will fail # cat channel.xml <channel type='pty'> <target type='virtio'/> </channel> # virsh attach-device pc channel.xml error: Failed to attach device from channel.xml error: internal error: Device alias was not set for virtio-serial controller with index 1 3. # cat channel3.xml <channel type='pty'> <target type='virtio'/> <address type='virtio-serial' controller='0' bus='0' port='3'/> </channel> # virsh attach-device pc channel3.xml error: Failed to attach device from channel3.xml error: XML error: virtio serial controller 0 does not have port 3 # cat channel0.xml <channel type='pty'> <target type='virtio'/> <address type='virtio-serial' controller='0' bus='0' port='0'/> </channel> # virsh attach-device pc channel0.xml error: Failed to attach device from channel0.xml error: XML error: Unable to find a free port on virtio-serial controller 0 Actual results: in step 2, hotplug fail with unclear error message Expected results: As the "ports='3' ", in step 2, the hotplug should succeed with the device assigned to port 0 or port 3.(only 1 and 2 are ocuppied) And suggest to improve the error message like "Unable to find a free port on virtio-serial controller 0" when all the 3 ports are occupied, as virtio-serial controller do not support hotplug Additional info:
one more scenario: 1. when guest has no virtio console, and 2 of 3 ports are occupid # virsh dumpxml pc | grep virtio-serial <controller type='virtio-serial' index='0' ports='3'> <alias name='virtio-serial0'/> <address type='virtio-serial' controller='0' bus='0' port='1'/> <address type='virtio-serial' controller='0' bus='0' port='2'/> 2. attach a virtio console: # cat console.xml <console type='pty'> <target type='virtio'/> </console> # virsh attach-device pc console.xml Device attached successfully 3. attach the 2nd virtio console: # virsh attach-device pc console.xml error: Failed to attach device from console.xml error: internal error: unable to execute QEMU command 'device_add': virtio-serial-bus: Out-of-range port id specified, max. allowed: 2
The problem with virtio consoles described in comment 2 is tracked by bug 1447505 The error in step two shows two problems 1. we pretend to be able to add a virtio-serial controller, so we choose an address from a new one, but we don't actually add it 2. 0 is not allowed to be used as a port number. I do not remember the reason why I only let virtio consoles use port 0, or why their addresses are not stored, but that's tracked by the bug mentioned above.
This bug was closed deferred as a result of bug triage. Please reopen if you disagree and provide justification why this bug should get enough priority. Most important would be information about impact on customer or layered product. Please indicate requested target release.