
On Wed, 2017-09-06 at 21:36 -0400, Laine Stump wrote:
Unlike other controllers, PCI controller can plug into each other,
s/PCI controller/PCI controllers/
[...]
Add some logic to make sure PCI controller appear in the correct
s/PCI controller/PCI controllers/
Getthing it wrong once would be bad enough, but two times in a row? That's just inexcusable :( [...]
I haven't tried it, but it looks to me like this could all be fixed by simply changing the function virDomainDefAddController() to call virDomainControllerInsert() to add the new controller at the proper (sorted) place in the controller array instead of using VIR_APPEND_ELEMENT_COPY() (which is what it does now). That has the nice side effect of keeping the controllers listed in the XML in sorted order, and making sure that the XML doesn't magically change when you edit something unrelated.
I don't doubt that the code you've written below fixes the problem at the time the commandline is generated (haven't tried it either :-), but I think it's better to fix it back at its source, when the controllers are auto-added.
Sounds like a superior approach indeed. Thanks for the suggestion, I'll give it a go :) -- Andrea Bolognani / Red Hat / Virtualization