[libvirt] [PATCH v5 05/12] qemu: Validate PCI controller options (targetIndex)
Laine Stump
laine at laine.org
Fri Mar 2 22:08:14 UTC 2018
On 03/02/2018 10:13 AM, Andrea Bolognani wrote:
> https://bugzilla.redhat.com/show_bug.cgi?id=1483816
>
> Signed-off-by: Andrea Bolognani <abologna at redhat.com>
> ---
> src/qemu/qemu_domain.c | 52 ++++++++++++++++++++++++++++++++++++++++++++------
> 1 file changed, 46 insertions(+), 6 deletions(-)
>
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index 3ef5d74e7a..54e47acd99 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -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;
> @@ -4645,6 +4639,52 @@ 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) {
> + virReportError(VIR_ERR_INTERNAL_ERROR,
> + _("Option '%s' not set for '%s' controller"),
> + "targetIndex", model);
This is the option I was talking about in the review for 03/12. As it
is, the message is going to say:
Option 'targetIndex' not set for 'pci-root' controller
It would be better if it were something like
Required option 'targetIndex' not set for
'spapr-pci-host-bridge' controller
(Maybe there's a way to work in 'pci-root' to the message too. It's too
late on Friday afternoon for me to try and figure it out).
Otherwise it fits with the pattern of everything else, so
Reviewed-by: Laine Stump <laine at laine.org>
> + 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) {
> + virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> + _("Option '%s' is not valid for '%s' controller"),
> + "targetIndex", model);
> + 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) {
> + virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> + _("Option '%s' is not valid for '%s' controller"),
> + "targetIndex", model);
> + 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);
> }
>
More information about the libvir-list
mailing list