[libvirt] [PATCH] conf: validate that PCI controller index is < 256

Martin Kletzander mkletzan at redhat.com
Mon Mar 27 07:41:58 UTC 2017


On Sun, Mar 26, 2017 at 08:49:28PM -0400, Laine Stump wrote:
>This is the maximum for many reasons, for starters because index ==
>bus number, and a controller's bus number is 8 bits.
>
>This incidentally resolves: https://bugzilla.redhat.com/1329090
>---
> src/conf/domain_conf.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
>diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>index 6bbc6a2..2139ab0 100644
>--- a/src/conf/domain_conf.c
>+++ b/src/conf/domain_conf.c
>@@ -4846,6 +4846,24 @@ virDomainNetDefValidate(const virDomainNetDef *net)
>
>
> static int
>+virDomainControllerDefValidate(const virDomainControllerDef *controller)
>+{
>+    if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) {
>+        if (controller->idx > 255) {
>+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
>+                           _("PCI controller index %d too high, or too many "

The first line might be enough, maybe adding the max value there.

>+                             "PCI controllers. A maximum of 256 PCI "
>+                             "controllers is allowed, and the maximum value "
>+                             "of the index attribute is 255"),
>+                           controller->idx);
>+            return -1;
>+        }
>+    }
>+    return 0;
>+}
>+
>+
>+static int
> virDomainDeviceDefValidateInternal(const virDomainDeviceDef *dev,
>                                    const virDomainDef *def)
> {
>@@ -4867,6 +4885,7 @@ virDomainDeviceDefValidateInternal(const virDomainDeviceDef *dev,
>     case VIR_DOMAIN_DEVICE_HOSTDEV:
>     case VIR_DOMAIN_DEVICE_WATCHDOG:
>     case VIR_DOMAIN_DEVICE_CONTROLLER:
>+        return virDomainControllerDefValidate(dev->data.controller);

Do you really mean to fall-through from hostdev, watchdog and so on? ;)

>     case VIR_DOMAIN_DEVICE_GRAPHICS:
>     case VIR_DOMAIN_DEVICE_HUB:
>     case VIR_DOMAIN_DEVICE_SMARTCARD:
>--
>2.9.3
>
>--
>libvir-list mailing list
>libvir-list at redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170327/990ea20e/attachment-0001.sig>


More information about the libvir-list mailing list