From nobody Sat Feb 7 18:46:28 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1607466091; cv=none; d=zohomail.com; s=zohoarc; b=NBQ2GY+KgyxLF0RM4AxNBwEL1o2qBbhlzk2R+b8cHuLHxj3dDD1BC4wfH1jwR+aDE6/+0ssxAjL869/5G264Ft7Of++h5rvsp3R4qFAfIMpzJjLxRqbu7RWrNl24dB7Tm1u2IDMgAIRgvz06pldMOovn9Ddr4IubP8GoRtIhO8A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607466091; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0GwHzxdJBscHZJnWnV+ycgSfzRIzxR7LF4BHZZ6F/70=; b=VqZFOtQOr4FKXDqKn+vu1RsEIyE7O4j6BcZ1yjDsIKBSV5rvpPqG9xswfWlZ1Sujhw73OVu/Ak77UQbaWFh21IsC436ykzqwWqgLKwLlz3jE1j20PcgauNT2uDxvMaY2HR5asbjzizZ07NU6gSsvl+yZxuUu8Yzu61Q4tLkQAaY= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1607466091684290.3676129764656; Tue, 8 Dec 2020 14:21:31 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-351-S-OVHgqQNlaFceXW0U6zBQ-1; Tue, 08 Dec 2020 17:21:27 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 86A4B107ACF7; Tue, 8 Dec 2020 22:21:21 +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 61D3A5D6D5; Tue, 8 Dec 2020 22:21:21 +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 2F7901809CA2; Tue, 8 Dec 2020 22:21:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0B8MLJ38017424 for ; Tue, 8 Dec 2020 17:21:19 -0500 Received: by smtp.corp.redhat.com (Postfix) id 26E5DA9FDE; Tue, 8 Dec 2020 22:21:19 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1FD71AB404 for ; Tue, 8 Dec 2020 22:21:15 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E8CC2858284 for ; Tue, 8 Dec 2020 22:21:14 +0000 (UTC) Received: from mail-qk1-f196.google.com (mail-qk1-f196.google.com [209.85.222.196]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-322-S36zoZBvNUW2J7RuIEjJHQ-1; Tue, 08 Dec 2020 17:21:12 -0500 Received: by mail-qk1-f196.google.com with SMTP id h20so236896qkk.4 for ; Tue, 08 Dec 2020 14:21:12 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:c1a:69c1:2b22:e880:fc49]) by smtp.gmail.com with ESMTPSA id c14sm75057qtg.85.2020.12.08.14.21.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Dec 2020 14:21:11 -0800 (PST) X-MC-Unique: S-OVHgqQNlaFceXW0U6zBQ-1 X-MC-Unique: S36zoZBvNUW2J7RuIEjJHQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=0GwHzxdJBscHZJnWnV+ycgSfzRIzxR7LF4BHZZ6F/70=; b=tkWDx3KFBfPxNUsg04KyltQS48AKo6LAu8STh6QkXFkG7X9qfBsdoTyWsmtX+Yhp26 LeNb7Q24nn8ZPF/GI7EBl10LScYfKpM5GbyDBYmCRnzsjEB8v0vSnuWo4UkbRwL6Mf/Q HOlwPAatmaidg6dy/n2z+s2sNj3iNR5ebtG1z54juCCBea4GG+kSKRrOxvKKLZ6LiQ8X F/0+Okbwy6BKWjD5hDqYD/oU5UW5bG5wnZtd5j4SIxgA5jje8Rc8I/m2Mzx1yrGN4xLp /Qhny2R9McstyotvOsxfMm2LQLte3kYWRI1GZ8Ez0ti+r36y9Yzt3EiCC3Q1sLqGc2v+ sgDA== X-Gm-Message-State: AOAM530uulWAJo5ck3H+7ewTlJodGEj1EDzyr5mOXvqImHJC3HGZmYAc IhGZ7alk5hB3C1gE9CfXBKROdtyhgkQ= X-Google-Smtp-Source: ABdhPJy9uHfd2GyhASYTZ8G64HRlAQVC1f9QYvafIPHd5g410xK4jYrgcnyvfCiRMmKS6oOGSHROsQ== X-Received: by 2002:a05:620a:1101:: with SMTP id o1mr5502795qkk.489.1607466072129; Tue, 08 Dec 2020 14:21:12 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 11/14] domain_conf.c: move virDomainControllerDefValidate() to domain_validate.c Date: Tue, 8 Dec 2020 19:20:27 -0300 Message-Id: <20201208222030.1302229-12-danielhb413@gmail.com> In-Reply-To: <20201208222030.1302229-1-danielhb413@gmail.com> References: <20201208222030.1302229-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Next patch will add more validations to this function. Let's move it to domain_validate.c beforehand. Signed-off-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 37 ------------------------------------- src/conf/domain_validate.c | 37 +++++++++++++++++++++++++++++++++++++ src/conf/domain_validate.h | 1 + 3 files changed, 38 insertions(+), 37 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 064d77d933..453dc6cf6a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6211,43 +6211,6 @@ virDomainNetDefValidate(const virDomainNetDef *net) } =20 =20 -static int -virDomainControllerDefValidate(const virDomainControllerDef *controller) -{ - if (controller->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI) { - const virDomainPCIControllerOpts *opts =3D &controller->opts.pciop= ts; - - if (controller->idx > 255) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("PCI controller index %d too high, maximum is= 255"), - controller->idx); - return -1; - } - - /* Only validate the target index if it's been set */ - if (opts->targetIndex !=3D -1) { - - if (opts->targetIndex < 0 || opts->targetIndex > 30) { - virReportError(VIR_ERR_XML_ERROR, - _("PCI controller target index '%d' out of " - "range - must be 0-30"), - opts->targetIndex); - return -1; - } - - if ((controller->idx =3D=3D 0 && opts->targetIndex !=3D 0) || - (controller->idx !=3D 0 && opts->targetIndex =3D=3D 0)) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Only the PCI controller with index 0 can= " - "have target index 0, and vice versa")); - return -1; - } - } - } - return 0; -} - - static int virDomainHostdevDefValidate(const virDomainHostdevDef *hostdev) { diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 09ab908ea3..416c24f97b 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -517,3 +517,40 @@ virDomainDefTunablesValidate(const virDomainDef *def) =20 return 0; } + + +int +virDomainControllerDefValidate(const virDomainControllerDef *controller) +{ + if (controller->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI) { + const virDomainPCIControllerOpts *opts =3D &controller->opts.pciop= ts; + + if (controller->idx > 255) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("PCI controller index %d too high, maximum is= 255"), + controller->idx); + return -1; + } + + /* Only validate the target index if it's been set */ + if (opts->targetIndex !=3D -1) { + + if (opts->targetIndex < 0 || opts->targetIndex > 30) { + virReportError(VIR_ERR_XML_ERROR, + _("PCI controller target index '%d' out of " + "range - must be 0-30"), + opts->targetIndex); + return -1; + } + + if ((controller->idx =3D=3D 0 && opts->targetIndex !=3D 0) || + (controller->idx !=3D 0 && opts->targetIndex =3D=3D 0)) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Only the PCI controller with index 0 can= " + "have target index 0, and vice versa")); + return -1; + } + } + } + return 0; +} diff --git a/src/conf/domain_validate.h b/src/conf/domain_validate.h index 2bd9e71073..e8004e358d 100644 --- a/src/conf/domain_validate.h +++ b/src/conf/domain_validate.h @@ -43,3 +43,4 @@ int virDomainRNGDefValidate(const virDomainRNGDef *rng, int virDomainSmartcardDefValidate(const virDomainSmartcardDef *smartcard, const virDomainDef *def); int virDomainDefTunablesValidate(const virDomainDef *def); +int virDomainControllerDefValidate(const virDomainControllerDef *controlle= r); --=20 2.26.2