From nobody Mon Feb 9 00:54:08 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1592468763; cv=none; d=zohomail.com; s=zohoarc; b=aS6lx3FAWWMBa61ize2yYp+KuTYk6lzxnm5IRtza1HrcGMxD23e6+/2OrvVDzSh2NV5pomtpYz6ZSVN8SsFsxVtLpu7flxjtm63KQw7Fv0meKIGpNeiu2X6fKaUIJI7SJmFNzzsRBEq1s2WqDUdweZcEILMostOgvWynPk/74lA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592468763; 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=VmJC7D+xRhkfQxLKIly/NERbQUGrHxWxRp6aGSf3jZU=; b=ZZA9tfVM0Jjox8w2bqRuuqCnaVakaAp48wHW8VnuwmcR+lrf9foxGxrNjS64x5m8XKYAC+z2EwWrMig27ZgOCAJCOWB+cmn6qHfzWiWjRqa4+di7JthVIwWooq5R2hX7mKgUOJJLjnmtA4jJa/9hQ2O8T+ffdttmZuy+cIMkxR8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1592468763837614.3929558207692; Thu, 18 Jun 2020 01:26:03 -0700 (PDT) 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-130-EFH2gEDsMTKu2SKJAgpIaQ-1; Thu, 18 Jun 2020 04:25:59 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id EFC11184519D; Thu, 18 Jun 2020 08:25:52 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CC7265D9E5; Thu, 18 Jun 2020 08:25:52 +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 9F1DB833CB; Thu, 18 Jun 2020 08:25:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05I8PodR022131 for ; Thu, 18 Jun 2020 04:25:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5C08E118DF5A; Thu, 18 Jun 2020 08:25:50 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 576F5118DF56 for ; Thu, 18 Jun 2020 08:25:50 +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 3ECB0811768 for ; Thu, 18 Jun 2020 08:25:50 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-486-e9rwpBMcNpqFrLAT8eWafg-1; Thu, 18 Jun 2020 04:25:48 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 05I82LMR007933 for ; Thu, 18 Jun 2020 04:25:47 -0400 Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 31r338uf03-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 18 Jun 2020 04:25:46 -0400 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 05I8PiDv001341 for ; Thu, 18 Jun 2020 08:25:44 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma03ams.nl.ibm.com with ESMTP id 31quax8q32-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 18 Jun 2020 08:25:44 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 05I8ONlv64028934 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 18 Jun 2020 08:24:23 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E5EF5A4057; Thu, 18 Jun 2020 08:25:40 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C46BEA404D; Thu, 18 Jun 2020 08:25:40 +0000 (GMT) Received: from m46lp68.lnxne.boe (unknown [9.152.108.100]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 18 Jun 2020 08:25:40 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592468762; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=VmJC7D+xRhkfQxLKIly/NERbQUGrHxWxRp6aGSf3jZU=; b=MJOZBobMKP2HqE1pmbHVQRl4OaPX9OuAeO8nadtgOSmIFFj+rMmyYfhAGcHP3DrOglI3GJ lYllu0bUIpneb9r1E3+B0OdFej5MoMY7foPsDgKzGVtfEce5KuRXQXd3CCU3aLsF1noDF9 poiJcZ3A2F/Nb3KNyGwpiOD6GnpzlX0= X-MC-Unique: EFH2gEDsMTKu2SKJAgpIaQ-1 X-MC-Unique: e9rwpBMcNpqFrLAT8eWafg-1 From: Shalini Chellathurai Saroja To: libvir-list@redhat.com Subject: [PATCH libvirt v2 3/5] qemu: move ZPCI uid validation into device validation Date: Thu, 18 Jun 2020 10:25:16 +0200 Message-Id: <20200618082518.98780-4-shalini@linux.ibm.com> In-Reply-To: <20200618082518.98780-1-shalini@linux.ibm.com> References: <20200618082518.98780-1-shalini@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216, 18.0.687 definitions=2020-06-18_04:2020-06-17, 2020-06-18 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 bulkscore=0 impostorscore=0 clxscore=1015 malwarescore=0 phishscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 suspectscore=1 mlxlogscore=999 cotscore=-2147483648 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006180057 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Shalini Chellathurai Saroja 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.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The ZPCI device validation is specific to qemu. So, let us move the ZPCI uid validation out of domain xml parsing into qemu domain device validation. Signed-off-by: Shalini Chellathurai Saroja Reviewed-by: Bjoern Walk Reviewed-by: Boris Fiuczynski Reviewed-by: Andrea Bolognani --- src/conf/device_conf.c | 3 --- src/libvirt_private.syms | 1 - src/qemu/qemu_validate.c | 18 +++++++++++++++++- src/util/virpci.c | 20 -------------------- src/util/virpci.h | 1 - 5 files changed, 17 insertions(+), 26 deletions(-) diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index 21398e90..a641f3ce 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -77,9 +77,6 @@ virZPCIDeviceAddressParseXML(xmlNodePtr node, def.fid.isSet =3D true; } =20 - if (!virZPCIDeviceAddressIsValid(&def)) - return -1; - addr->zpci =3D def; =20 return 0; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index a4a09cf9..f0543bcc 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2839,7 +2839,6 @@ virPCIStubDriverTypeFromString; virPCIStubDriverTypeToString; virZPCIDeviceAddressIsIncomplete; virZPCIDeviceAddressIsPresent; -virZPCIDeviceAddressIsValid; =20 =20 # util/virperf.h diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 0372ae7d..37c59416 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -1018,7 +1018,9 @@ static int qemuValidateDomainDeviceDefZPCIAddress(virDomainDeviceInfoPtr info, virQEMUCapsPtr qemuCaps) { - if (virZPCIDeviceAddressIsPresent(&info->addr.pci.zpci) && + virZPCIDeviceAddressPtr zpci =3D &info->addr.pci.zpci; + + if (virZPCIDeviceAddressIsPresent(zpci) && !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_ZPCI)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -1026,6 +1028,20 @@ qemuValidateDomainDeviceDefZPCIAddress(virDomainDevi= ceInfoPtr info, return -1; } =20 + /* We don't need to check fid because fid covers + * all range of uint32 type. + */ + if (zpci->uid.isSet && + (zpci->uid.value > VIR_DOMAIN_DEVICE_ZPCI_MAX_UID || + zpci->uid.value =3D=3D 0)) { + virReportError(VIR_ERR_XML_ERROR, + _("Invalid PCI address uid=3D'0x%.4x', " + "must be > 0x0000 and <=3D 0x%.4x"), + zpci->uid.value, + VIR_DOMAIN_DEVICE_ZPCI_MAX_UID); + return -1; + } + return 0; } =20 diff --git a/src/util/virpci.c b/src/util/virpci.c index 40ae5aec..3685f901 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -2167,26 +2167,6 @@ virPCIDeviceAddressParse(char *address, } =20 =20 -bool -virZPCIDeviceAddressIsValid(virZPCIDeviceAddressPtr zpci) -{ - /* We don't need to check fid because fid covers - * all range of uint32 type. - */ - if (zpci->uid.isSet && - (zpci->uid.value > VIR_DOMAIN_DEVICE_ZPCI_MAX_UID || - zpci->uid.value =3D=3D 0)) { - virReportError(VIR_ERR_XML_ERROR, - _("Invalid PCI address uid=3D'0x%.4x', " - "must be > 0x0000 and <=3D 0x%.4x"), - zpci->uid.value, - VIR_DOMAIN_DEVICE_ZPCI_MAX_UID); - return false; - } - - return true; -} - bool virZPCIDeviceAddressIsIncomplete(const virZPCIDeviceAddress *addr) { diff --git a/src/util/virpci.h b/src/util/virpci.h index f198df5d..b3322ba6 100644 --- a/src/util/virpci.h +++ b/src/util/virpci.h @@ -254,7 +254,6 @@ int virPCIDeviceAddressParse(char *address, virPCIDevic= eAddressPtr bdf); =20 bool virZPCIDeviceAddressIsIncomplete(const virZPCIDeviceAddress *addr); bool virZPCIDeviceAddressIsPresent(const virZPCIDeviceAddress *addr); -bool virZPCIDeviceAddressIsValid(virZPCIDeviceAddressPtr zpci); =20 int virPCIGetVirtualFunctionInfo(const char *vf_sysfs_device_path, int pfNetDevIdx, --=20 2.25.4