From: Ján Tomko Date: Tue, 15 Jan 2019 14:33:10 +0000 (+0100) Subject: qemu: move out legacy USB controller formatting X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=a98c0a2fef11fc2206f8ee151d518cfdad535d6a;p=libvirt.git qemu: move out legacy USB controller formatting Move out the code formatting "-usb" on the QEMU command line. Signed-off-by: Ján Tomko Reviewed-by: Cole Robinson --- diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 9873c96c2d..4ff526df3e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -3049,6 +3049,26 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef, } +static int +qemuBuildLegacyUSBControllerCommandLine(virCommandPtr cmd, + const virDomainDef *def, + int usbcontroller) +{ + if (usbcontroller == 0 && + !qemuDomainIsQ35(def) && + !qemuDomainIsARMVirt(def) && + !qemuDomainIsRISCVVirt(def) && + !ARCH_IS_S390(def->os.arch)) { + /* We haven't added any USB controller yet, but we haven't been asked + * not to add one either. Add a legacy USB controller, unless we're + * creating a kind of guest we want to keep legacy-free */ + virCommandAddArg(cmd, "-usb"); + } + + return 0; +} + + /** * qemuBuildSkipController: * @controller: Controller to check @@ -3184,16 +3204,8 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd, } } - if (usbcontroller == 0 && - !qemuDomainIsQ35(def) && - !qemuDomainIsARMVirt(def) && - !qemuDomainIsRISCVVirt(def) && - !ARCH_IS_S390(def->os.arch)) { - /* We haven't added any USB controller yet, but we haven't been asked - * not to add one either. Add a legacy USB controller, unless we're - * creating a kind of guest we want to keep legacy-free */ - virCommandAddArg(cmd, "-usb"); - } + if (qemuBuildLegacyUSBControllerCommandLine(cmd, def, usbcontroller) < 0) + goto cleanup; ret = 0;