[libvirt] [PATCH v5 06/12] qemu: Validate PCI controller options (pcihole64)

Andrea Bolognani posted 12 patches 7 years, 2 months ago
There is a newer version of this series
[libvirt] [PATCH v5 06/12] qemu: Validate PCI controller options (pcihole64)
Posted by Andrea Bolognani 7 years, 2 months ago
https://bugzilla.redhat.com/show_bug.cgi?id=1483816

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
---
 src/qemu/qemu_domain.c | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 54e47acd99..9b8d2e864d 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4685,6 +4685,46 @@ qemuDomainDeviceDefValidateControllerPCI(const virDomainControllerDef *cont,
         return -1;
     }
 
+    /* pcihole64 */
+    switch ((virDomainControllerModelPCI) cont->model) {
+    case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT:
+    case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
+        /* The pcihole64 option only applies to x86 guests */
+        if ((pciopts->pcihole64 ||
+             pciopts->pcihole64size != 0) &&
+            !ARCH_IS_X86(def->os.arch)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("Option '%s' is not valid for '%s' controller "
+                             "on '%s' architecture or '%s' machine type"),
+                           "pcihole64", model,
+                           virArchToString(def->os.arch), def->os.machine);
+            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:
+        if (pciopts->pcihole64 ||
+            pciopts->pcihole64size != 0) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("Option '%s' is not valid for '%s' controller"),
+                           "pcihole64", 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);
 }
 
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v5 06/12] qemu: Validate PCI controller options (pcihole64)
Posted by Laine Stump 7 years, 2 months ago
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@redhat.com>

Reviewed-by: Laine Stump <laine@laine.org>

> ---
>  src/qemu/qemu_domain.c | 40 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 40 insertions(+)
>
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index 54e47acd99..9b8d2e864d 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -4685,6 +4685,46 @@ qemuDomainDeviceDefValidateControllerPCI(const virDomainControllerDef *cont,
>          return -1;
>      }
>  
> +    /* pcihole64 */
> +    switch ((virDomainControllerModelPCI) cont->model) {
> +    case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT:
> +    case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
> +        /* The pcihole64 option only applies to x86 guests */
> +        if ((pciopts->pcihole64 ||
> +             pciopts->pcihole64size != 0) &&
> +            !ARCH_IS_X86(def->os.arch)) {
> +            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> +                           _("Option '%s' is not valid for '%s' controller "
> +                             "on '%s' architecture or '%s' machine type"),
> +                           "pcihole64", model,
> +                           virArchToString(def->os.arch), def->os.machine);
> +            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:
> +        if (pciopts->pcihole64 ||
> +            pciopts->pcihole64size != 0) {
> +            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> +                           _("Option '%s' is not valid for '%s' controller"),
> +                           "pcihole64", 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);
>  }
>  


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list