On Wed, Jan 24, 2024 at 20:37:41 +0100, Andrea Bolognani wrote: > Mostly reduce the number of 'else if' and improve comments. > > Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx> > --- > src/qemu/qemu_domain.c | 62 ++++++++++++++++++++++++------------------ > 1 file changed, 36 insertions(+), 26 deletions(-) > > diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c > index d992b51877..dcf73c0e08 100644 > --- a/src/qemu/qemu_domain.c > +++ b/src/qemu/qemu_domain.c [...] > @@ -4200,50 +4198,62 @@ qemuDomainDefaultUSBControllerModel(const virDomainDef *def, [...] > - } else if (def->os.arch == VIR_ARCH_AARCH64) { > + > + /* For ppc64 specifically, returning -1 here will result in VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT > + * an attempt to use the legacy USB controller rather than an > + * outright failure */ > + return -1; VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT > + } > + > + if (def->os.arch == VIR_ARCH_AARCH64) { > + /* Prefer USB3 */ > if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QEMU_XHCI)) > return VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI; > - else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI)) > + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI)) > return VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI; > + > + /* We should probably return -1 here and avoid the VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT/VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE > + * possibility of falling back to piix3-uhci (USB1), but > + * historically we haven't done that and starting now might > + * cause backwards compatibility issues */ > } > > if (ARCH_IS_X86(def->os.arch)) { > if (qemuDomainIsQ35(def) && autoAdded) { > - /* Prefer adding a USB3 controller if supported, fall back > - * to USB2 if there is no USB3 available, and if that's > - * unavailable don't add anything. > - */ > + /* Prefer USB3 */ > if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_QEMU_XHCI)) > return VIR_DOMAIN_CONTROLLER_MODEL_USB_QEMU_XHCI; > if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI)) > return VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI; > + > + /* Fall back to USB2 */ > if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_ICH9_USB_EHCI1)) > return VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_EHCI1; > + > + /* If no suitable device is available, simply avoid > + * adding the controller */ > return -2; > } > } > > - /* Default USB controller is piix3-uhci if available. */ > + /* piix3-uhci (USB1) is the last ditch effort before giving up */ > if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX3_USB_UHCI)) > return VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI; > > + /* No suitable model could be found. This will return in either > + * an error or the use of the legacy USB controller */ The caller will report this as an error or use the legacy USB controller. > return -1; > } Reviewed-by: Peter Krempa <pkrempa@xxxxxxxxxx> _______________________________________________ Devel mailing list -- devel@xxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx