mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-04-01 20:05:19 +00:00
qemu: Validate PCI controller options (targetIndex)
https://bugzilla.redhat.com/show_bug.cgi?id=1483816 Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Laine Stump <laine@laine.org>
This commit is contained in:
parent
68b1491e89
commit
dd8a8f1df3
@ -4401,12 +4401,6 @@ qemuDomainDeviceDefValidateControllerPCIOld(const virDomainControllerDef *contro
|
||||
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;
|
||||
@ -4637,6 +4631,46 @@ qemuDomainDeviceDefValidateControllerPCI(const virDomainControllerDef *cont,
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* targetIndex */
|
||||
switch ((virDomainControllerModelPCI) cont->model) {
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT:
|
||||
/* PHBs for pSeries guests must have been assigned a targetIndex */
|
||||
if (pciopts->targetIndex == -1 &&
|
||||
pciopts->modelName == VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_SPAPR_PCI_HOST_BRIDGE) {
|
||||
virReportControllerMissingOption(cont, model, modelName, "targetIndex");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* targetIndex only applies to PHBs, so for any other pci-root
|
||||
* controller it being present is an error */
|
||||
if (pciopts->targetIndex != -1 &&
|
||||
pciopts->modelName != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_SPAPR_PCI_HOST_BRIDGE) {
|
||||
virReportControllerInvalidOption(cont, model, modelName, "targetIndex");
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE:
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE:
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT:
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT:
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT:
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS:
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS:
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
|
||||
if (pciopts->targetIndex != -1) {
|
||||
virReportControllerInvalidOption(cont, model, modelName, "targetIndex");
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_DEFAULT:
|
||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST:
|
||||
default:
|
||||
virReportEnumRangeError(virDomainControllerModelPCI, cont->model);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return qemuDomainDeviceDefValidateControllerPCIOld(cont, def, qemuCaps);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user