mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 14:57:42 +00:00
qemu: Introduce qemuBuildSkipController
Move the non USB implicit controller checks into their own helper to reduce the cruft in qemuBuildControllerDevCommandLine.
This commit is contained in:
parent
984c534a3f
commit
ac0fb44afa
@ -3175,6 +3175,44 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* qemuBuildSkipController:
|
||||||
|
* @controller: Controller to check
|
||||||
|
* @def: Domain definition
|
||||||
|
*
|
||||||
|
* Returns true if this controller can be skipped for command line
|
||||||
|
* generation or device validation.
|
||||||
|
*/
|
||||||
|
static bool
|
||||||
|
qemuBuildSkipController(const virDomainControllerDef *controller,
|
||||||
|
const virDomainDef *def)
|
||||||
|
{
|
||||||
|
/* skip pcie-root */
|
||||||
|
if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
|
||||||
|
controller->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
/* Skip pci-root, except for pSeries guests (which actually
|
||||||
|
* support more than one PCI Host Bridge per guest) */
|
||||||
|
if (!qemuDomainIsPSeries(def) &&
|
||||||
|
controller->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
|
||||||
|
controller->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
/* first SATA controller on Q35 machines is implicit */
|
||||||
|
if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_SATA &&
|
||||||
|
controller->idx == 0 && qemuDomainIsQ35(def))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
/* first IDE controller is implicit on various machines */
|
||||||
|
if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE &&
|
||||||
|
controller->idx == 0 && qemuDomainHasBuiltinIDE(def))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuBuildControllerDevCommandLine(virCommandPtr cmd,
|
qemuBuildControllerDevCommandLine(virCommandPtr cmd,
|
||||||
const virDomainDef *def,
|
const virDomainDef *def,
|
||||||
@ -3217,6 +3255,9 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd,
|
|||||||
if (cont->type != contOrder[j])
|
if (cont->type != contOrder[j])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (qemuBuildSkipController(cont, def))
|
||||||
|
continue;
|
||||||
|
|
||||||
/* skip USB controllers with type none.*/
|
/* skip USB controllers with type none.*/
|
||||||
if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
|
if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
|
||||||
cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE) {
|
cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE) {
|
||||||
@ -3224,30 +3265,6 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* skip pcie-root */
|
|
||||||
if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
|
|
||||||
cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Skip pci-root, except for pSeries guests (which actually
|
|
||||||
* support more than one PCI Host Bridge per guest) */
|
|
||||||
if (!qemuDomainIsPSeries(def) &&
|
|
||||||
cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
|
|
||||||
cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* first SATA controller on Q35 machines is implicit */
|
|
||||||
if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_SATA &&
|
|
||||||
cont->idx == 0 && qemuDomainIsQ35(def))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* first IDE controller is implicit on various machines */
|
|
||||||
if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE &&
|
|
||||||
cont->idx == 0 && qemuDomainHasBuiltinIDE(def))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
|
if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
|
||||||
cont->model == -1 &&
|
cont->model == -1 &&
|
||||||
!qemuDomainIsQ35(def) &&
|
!qemuDomainIsQ35(def) &&
|
||||||
|
Loading…
Reference in New Issue
Block a user