From a98c0a2fef11fc2206f8ee151d518cfdad535d6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Tue, 15 Jan 2019 15:33:10 +0100 Subject: [PATCH] qemu: move out legacy USB controller formatting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move out the code formatting "-usb" on the QEMU command line. Signed-off-by: Ján Tomko Reviewed-by: Cole Robinson --- src/qemu/qemu_command.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) 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;