From nobody Wed May 14 12:37:30 2025 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.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1539920847120211.83213363188247; Thu, 18 Oct 2018 20:47:27 -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 42F0030026D9; Fri, 19 Oct 2018 03:47:25 +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 0ECCF6873C; Fri, 19 Oct 2018 03:47:25 +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 BEA0C18005B3; Fri, 19 Oct 2018 03:47:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9J3f9cQ032018 for ; Thu, 18 Oct 2018 23:41:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9339360150; Fri, 19 Oct 2018 03:41:09 +0000 (UTC) Received: from mx1.redhat.com (ext-mx17.extmail.prod.ext.phx2.redhat.com [10.5.110.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8C53C50F91 for ; Fri, 19 Oct 2018 03:41:06 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C75CC30F8C03 for ; Fri, 19 Oct 2018 03:41:05 +0000 (UTC) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w9J3eaBi100464 for ; Thu, 18 Oct 2018 23:41:05 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 2n77jm80ds-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 18 Oct 2018 23:41:05 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 18 Oct 2018 21:41:04 -0600 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 18 Oct 2018 21:41:01 -0600 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w9J3exQv51511358 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 18 Oct 2018 20:40:59 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CB41C6E04E; Fri, 19 Oct 2018 03:40:59 +0000 (GMT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A0CE16E05D; Fri, 19 Oct 2018 03:40:57 +0000 (GMT) Received: from zyimindembp.cn.ibm.com (unknown [9.115.192.238]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 19 Oct 2018 03:40:57 +0000 (GMT) From: Yi Min Zhao To: libvir-list@redhat.com Date: Fri, 19 Oct 2018 11:40:15 +0800 In-Reply-To: <20181019034020.4757-1-zyimin@linux.ibm.com> References: <20181019034020.4757-1-zyimin@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18101903-8235-0000-0000-00000E184ABD X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009898; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000268; SDB=6.01104747; UDB=6.00571939; IPR=6.00884797; MB=3.00023816; MTD=3.00000008; XFM=3.00000015; UTC=2018-10-19 03:41:03 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18101903-8236-0000-0000-0000430D7EB8 Message-Id: <20181019034020.4757-10-zyimin@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-10-18_11:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810190033 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 19 Oct 2018 03:41:06 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Fri, 19 Oct 2018 03:41:06 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'zyimin@linux.ibm.com' RCPT:'' X-RedHat-Spam-Score: 1.298 * (KHOP_DYNAMIC, RCVD_IN_DNSWL_LOW, SPF_PASS) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.46 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: fiuczy@linux.ibm.com, cohuck@redhat.com, abologna@redhat.com, bwalk@linux.ibm.com, jtomko@redhat.com, laine@laine.org Subject: [libvirt] [PATCH v7 09/14] qemu: Add zPCI address definition check 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.47]); Fri, 19 Oct 2018 03:47:25 +0000 (UTC) X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We should ensure that QEMU supports zPCI when a zPCI address is defined in XML and otherwise report an error. This patch introduces a generic validation function qemuDomainDeviceDefValidateAddress() which calls qemuDomainDeviceDefValidateZPCIAddress() if address type is PCI address. Signed-off-by: Yi Min Zhao Reviewed-by: Boris Fiuczynski Reviewed-by: Andrea Bolognani --- src/qemu/qemu_domain.c | 36 +++++++++++++++++++ .../hostdev-vfio-zpci-wrong-arch.xml | 34 ++++++++++++++++++ tests/qemuxml2argvtest.c | 2 ++ 3 files changed, 72 insertions(+) create mode 100644 tests/qemuxml2argvdata/hostdev-vfio-zpci-wrong-arch.xml diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 961755ef84..8bdc3f58e8 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5797,6 +5797,38 @@ qemuDomainDeviceDefValidateInput(const virDomainInpu= tDef *input, } =20 =20 +static int +qemuDomainDeviceDefValidateZPCIAddress(virDomainDeviceInfoPtr info, + virQEMUCapsPtr qemuCaps) +{ + if (!virZPCIDeviceAddressIsEmpty(&info->addr.pci.zpci) && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_ZPCI)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", + _("This QEMU binary doesn't support zPCI")); + return -1; + } + + return 0; +} + + +static int +qemuDomainDeviceDefValidateAddress(const virDomainDeviceDef *dev, + virQEMUCapsPtr qemuCaps) +{ + virDomainDeviceInfoPtr info; + + if (!(info =3D virDomainDeviceGetInfo((virDomainDeviceDef *)dev))) + return 0; + + if (info->type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) + return qemuDomainDeviceDefValidateZPCIAddress(info, qemuCaps); + + return 0; +} + + static int qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, const virDomainDef *def, @@ -5810,6 +5842,9 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef = *dev, def->emulator))) return -1; =20 + if ((ret =3D qemuDomainDeviceDefValidateAddress(dev, qemuCaps)) < 0) + goto cleanup; + switch ((virDomainDeviceType)dev->type) { case VIR_DOMAIN_DEVICE_NET: ret =3D qemuDomainDeviceDefValidateNetwork(dev->data.net); @@ -5885,6 +5920,7 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef = *dev, break; } =20 + cleanup: virObjectUnref(qemuCaps); return ret; } diff --git a/tests/qemuxml2argvdata/hostdev-vfio-zpci-wrong-arch.xml b/test= s/qemuxml2argvdata/hostdev-vfio-zpci-wrong-arch.xml new file mode 100644 index 0000000000..bfb2f83a3b --- /dev/null +++ b/tests/qemuxml2argvdata/hostdev-vfio-zpci-wrong-arch.xml @@ -0,0 +1,34 @@ + + QEMUGuest2 + c7a5fdbd-edaf-9466-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + +
+ + + + + +
+ +
+ +
+ + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 7b9e6bf2be..09c52f5f38 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1683,6 +1683,8 @@ mymain(void) DO_TEST_PARSE_ERROR("hostdev-mdev-display-missing-graphics", QEMU_CAPS_DEVICE_VFIO_PCI, QEMU_CAPS_VFIO_PCI_DISPLAY); + DO_TEST_PARSE_ERROR("hostdev-vfio-zpci-wrong-arch", + QEMU_CAPS_DEVICE_VFIO_PCI); DO_TEST("hostdev-vfio-zpci", QEMU_CAPS_DEVICE_VFIO_PCI, QEMU_CAPS_DEVICE_ZPCI); --=20 Yi Min -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list