提交 8f5e50e0 编写于 作者: J Ján Tomko

qemu: separate counting of USB controllers

qemuBuildLegacyUSBControllerCommandLine is the only place where
we need to count the USB controllers.

Count them again instead of keeping track in a variable passed to
qemuBuildControllerDevStr.

This removes the need for another variable in the loop in
qemuBuildControllerDevCommandLine.
Signed-off-by: NJán Tomko <jtomko@redhat.com>
Reviewed-by: NCole Robinson <crobinso@redhat.com>
上级 dab3d5d3
...@@ -3063,11 +3063,11 @@ qemuBuildDomainForbidLegacyUSBController(const virDomainDef *def) ...@@ -3063,11 +3063,11 @@ qemuBuildDomainForbidLegacyUSBController(const virDomainDef *def)
static int static int
qemuBuildLegacyUSBControllerCommandLine(virCommandPtr cmd, qemuBuildLegacyUSBControllerCommandLine(virCommandPtr cmd,
const virDomainDef *def, const virDomainDef *def)
int usbcontroller)
{ {
size_t i; size_t i;
size_t nlegacy = 0; size_t nlegacy = 0;
size_t nusb = 0;
for (i = 0; i < def->ncontrollers; i++) { for (i = 0; i < def->ncontrollers; i++) {
virDomainControllerDefPtr cont = def->controllers[i]; virDomainControllerDefPtr cont = def->controllers[i];
...@@ -3081,6 +3081,8 @@ qemuBuildLegacyUSBControllerCommandLine(virCommandPtr cmd, ...@@ -3081,6 +3081,8 @@ qemuBuildLegacyUSBControllerCommandLine(virCommandPtr cmd,
if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT) if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT)
nlegacy++; nlegacy++;
else
nusb++;
} }
if (nlegacy > 1) { if (nlegacy > 1) {
...@@ -3090,7 +3092,7 @@ qemuBuildLegacyUSBControllerCommandLine(virCommandPtr cmd, ...@@ -3090,7 +3092,7 @@ qemuBuildLegacyUSBControllerCommandLine(virCommandPtr cmd,
return -1; return -1;
} }
if (usbcontroller == 0 && if (nusb == 0 &&
!qemuBuildDomainForbidLegacyUSBController(def) && !qemuBuildDomainForbidLegacyUSBController(def) &&
!ARCH_IS_S390(def->os.arch)) { !ARCH_IS_S390(def->os.arch)) {
/* We haven't added any USB controller yet, but we haven't been asked /* We haven't added any USB controller yet, but we haven't been asked
...@@ -3227,7 +3229,7 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd, ...@@ -3227,7 +3229,7 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd,
} }
} }
if (qemuBuildLegacyUSBControllerCommandLine(cmd, def, usbcontroller) < 0) if (qemuBuildLegacyUSBControllerCommandLine(cmd, def) < 0)
goto cleanup; goto cleanup;
ret = 0; ret = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册