From nobody Sun May 5 01:48:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1490576114095547.2404285043995; Sun, 26 Mar 2017 17:55:14 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 562E581245; Mon, 27 Mar 2017 00:55:13 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2937317C66; Mon, 27 Mar 2017 00:55:13 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5244818523C4; Mon, 27 Mar 2017 00:55:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2R0nZ7D006497 for ; Sun, 26 Mar 2017 20:49:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 130CF1751B; Mon, 27 Mar 2017 00:49:35 +0000 (UTC) Received: from vhost2.laine.org (ovpn-116-59.phx2.redhat.com [10.3.116.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4E4D1753B for ; Mon, 27 Mar 2017 00:49:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 562E581245 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=laine.org Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 562E581245 From: Laine Stump To: libvir-list@redhat.com Date: Sun, 26 Mar 2017 20:49:28 -0400 Message-Id: <20170327004928.9874-1-laine@laine.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] conf: validate that PCI controller index is < 256 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 27 Mar 2017 00:55:14 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This is the maximum for many reasons, for starters because index =3D=3D 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) =20 =20 static int +virDomainControllerDefValidate(const virDomainControllerDef *controller) +{ + if (controller->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI) { + if (controller->idx > 255) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("PCI controller index %d too high, or too man= y " + "PCI controllers. A maximum of 256 PCI " + "controllers is allowed, and the maximum valu= e " + "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 virDomainDev= iceDef *dev, case VIR_DOMAIN_DEVICE_HOSTDEV: case VIR_DOMAIN_DEVICE_WATCHDOG: case VIR_DOMAIN_DEVICE_CONTROLLER: + return virDomainControllerDefValidate(dev->data.controller); case VIR_DOMAIN_DEVICE_GRAPHICS: case VIR_DOMAIN_DEVICE_HUB: case VIR_DOMAIN_DEVICE_SMARTCARD: --=20 2.9.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list