mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
qemu: Move more PCI command checks to controller def validate
Excluding the qemuCaps checks, move the remainder of the checks that validate whether the PCI definition is valid or not into qemuDomainControllerDefValidatePCI.
This commit is contained in:
parent
13b2083c42
commit
2461476022
@ -2719,20 +2719,6 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
|
||||
|
||||
switch ((virDomainControllerModelPCI) def->model) {
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE:
|
||||
if (pciopts->chassisNr == -1) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("autogenerated pci-bridge options not set"));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (pciopts->modelName
|
||||
!= VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCI_BRIDGE) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("PCI controller model name '%s' "
|
||||
"is not valid for a pci-bridge"),
|
||||
modelName);
|
||||
goto error;
|
||||
}
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PCI_BRIDGE)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("the pci-bridge controller "
|
||||
@ -2744,20 +2730,6 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
|
||||
def->info.alias);
|
||||
break;
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS:
|
||||
if (pciopts->busNr == -1) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("autogenerated pci-expander-bus options not set"));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (pciopts->modelName
|
||||
!= VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("PCI controller model name '%s' "
|
||||
"is not valid for a pci-expander-bus"),
|
||||
modelName);
|
||||
goto error;
|
||||
}
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PXB)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("the pxb controller "
|
||||
@ -2772,14 +2744,6 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
|
||||
pciopts->numaNode);
|
||||
break;
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE:
|
||||
if (pciopts->modelName
|
||||
!= VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_I82801B11_BRIDGE) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("PCI controller model name '%s' "
|
||||
"is not valid for a dmi-to-pci-bridge"),
|
||||
modelName);
|
||||
goto error;
|
||||
}
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("the dmi-to-pci-bridge (i82801b11-bridge) "
|
||||
@ -2789,21 +2753,6 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
|
||||
virBufferAsprintf(&buf, "%s,id=%s", modelName, def->info.alias);
|
||||
break;
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT:
|
||||
if (pciopts->chassis == -1 || pciopts->port == -1) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("autogenerated pcie-root-port options not set"));
|
||||
goto error;
|
||||
}
|
||||
if ((pciopts->modelName !=
|
||||
VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420) &&
|
||||
(pciopts->modelName !=
|
||||
VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCIE_ROOT_PORT)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("PCI controller model name '%s' "
|
||||
"is not valid for a pcie-root-port"),
|
||||
modelName);
|
||||
goto error;
|
||||
}
|
||||
if ((pciopts->modelName ==
|
||||
VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420) &&
|
||||
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_IOH3420)) {
|
||||
@ -2826,14 +2775,6 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
|
||||
pciopts->chassis, def->info.alias);
|
||||
break;
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT:
|
||||
if (pciopts->modelName
|
||||
!= VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_X3130_UPSTREAM) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("PCI controller model name '%s' "
|
||||
"is not valid for a pcie-switch-upstream-port"),
|
||||
modelName);
|
||||
goto error;
|
||||
}
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_X3130_UPSTREAM)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("the pcie-switch-upstream-port (x3130-upstream) "
|
||||
@ -2844,22 +2785,6 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
|
||||
virBufferAsprintf(&buf, "%s,id=%s", modelName, def->info.alias);
|
||||
break;
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT:
|
||||
if (pciopts->chassis == -1 ||
|
||||
pciopts->port == -1) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("autogenerated pcie-switch-downstream-port "
|
||||
"options not set"));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (pciopts->modelName
|
||||
!= VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_XIO3130_DOWNSTREAM) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("PCI controller model name '%s' "
|
||||
"is not valid for a pcie-switch-downstream-port"),
|
||||
modelName);
|
||||
goto error;
|
||||
}
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_XIO3130_DOWNSTREAM)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("The pcie-switch-downstream-port "
|
||||
@ -2872,20 +2797,6 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
|
||||
pciopts->chassis, def->info.alias);
|
||||
break;
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS:
|
||||
if (pciopts->busNr == -1) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("autogenerated pcie-expander-bus options not set"));
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (pciopts->modelName
|
||||
!= VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB_PCIE) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("PCI controller model name '%s' "
|
||||
"is not valid for a pcie-expander-bus"),
|
||||
modelName);
|
||||
goto error;
|
||||
}
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PXB_PCIE)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("the pxb-pcie controller "
|
||||
@ -2900,22 +2811,10 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
|
||||
pciopts->numaNode);
|
||||
break;
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT:
|
||||
if (pciopts->targetIndex == -1) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("autogenerated pci-root options not set"));
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Skip the implicit one */
|
||||
if (pciopts->targetIndex == 0)
|
||||
goto done;
|
||||
|
||||
if (pciopts->modelName != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_SPAPR_PCI_HOST_BRIDGE) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("PCI controller model name '%s' is not valid for a pci-root"),
|
||||
modelName);
|
||||
goto error;
|
||||
}
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("the spapr-pci-host-bridge controller "
|
||||
|
@ -4126,6 +4126,8 @@ qemuDomainDeviceDefValidateControllerPCI(const virDomainControllerDef *controlle
|
||||
controller->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT)
|
||||
return 0;
|
||||
|
||||
/* First pass - just check the controller index for the model's
|
||||
* that we care to check... */
|
||||
switch (model) {
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE:
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE:
|
||||
@ -4168,6 +4170,143 @@ qemuDomainDeviceDefValidateControllerPCI(const virDomainControllerDef *controlle
|
||||
}
|
||||
}
|
||||
|
||||
/* Second pass - now the model specific checks */
|
||||
switch (model) {
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE:
|
||||
if (pciopts->chassisNr == -1) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("autogenerated pci-bridge options not set"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pciopts->modelName != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCI_BRIDGE) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("PCI controller model name '%s' is not valid "
|
||||
"for a pci-bridge"),
|
||||
modelName);
|
||||
return -1;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS:
|
||||
if (pciopts->busNr == -1) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("autogenerated pci-expander-bus options not set"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pciopts->modelName != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("PCI controller model name '%s' is not valid "
|
||||
"for a pci-expander-bus"),
|
||||
modelName);
|
||||
return -1;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE:
|
||||
if (pciopts->modelName != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_I82801B11_BRIDGE) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("PCI controller model name '%s' is not valid "
|
||||
"for a dmi-to-pci-bridge"),
|
||||
modelName);
|
||||
return -1;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT:
|
||||
if (pciopts->chassis == -1 || pciopts->port == -1) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("autogenerated pcie-root-port options not set"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((pciopts->modelName != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420) &&
|
||||
(pciopts->modelName != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCIE_ROOT_PORT)) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("PCI controller model name '%s' is not valid "
|
||||
"for a pcie-root-port"),
|
||||
modelName);
|
||||
return -1;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT:
|
||||
if (pciopts->modelName != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_X3130_UPSTREAM) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("PCI controller model name '%s' is not valid "
|
||||
"for a pcie-switch-upstream-port"),
|
||||
modelName);
|
||||
return -1;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT:
|
||||
if (pciopts->chassis == -1 || pciopts->port == -1) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("autogenerated pcie-switch-downstream-port "
|
||||
"options not set"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pciopts->modelName != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_XIO3130_DOWNSTREAM) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("PCI controller model name '%s' is not valid "
|
||||
"for a pcie-switch-downstream-port"),
|
||||
modelName);
|
||||
return -1;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS:
|
||||
if (pciopts->busNr == -1) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("autogenerated pcie-expander-bus options not set"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pciopts->modelName != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB_PCIE) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("PCI controller model name '%s' is not valid "
|
||||
"for a pcie-expander-bus"),
|
||||
modelName);
|
||||
return -1;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT:
|
||||
if (pciopts->targetIndex == -1) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("autogenerated pci-root options not set"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Skip the implicit one */
|
||||
if (pciopts->targetIndex == 0)
|
||||
return 0;
|
||||
|
||||
if (pciopts->modelName != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_SPAPR_PCI_HOST_BRIDGE) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("PCI controller model name '%s' is not valid "
|
||||
"for a pci-root"),
|
||||
modelName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user