From nobody Mon Dec 15 01:46:19 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 1539921999232751.5056674313367; Thu, 18 Oct 2018 21:06:39 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2ABBD3084294; Fri, 19 Oct 2018 04:06:37 +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 A70A6884E1; Fri, 19 Oct 2018 04:06:36 +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 33DD8180B5B7; Fri, 19 Oct 2018 04:06:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w9J3f2V5031993 for ; Thu, 18 Oct 2018 23:41:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 035FC60CD6; Fri, 19 Oct 2018 03:41:02 +0000 (UTC) Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EF01A60C68 for ; Fri, 19 Oct 2018 03:41:00 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 34EB230F5589 for ; Fri, 19 Oct 2018 03:40:59 +0000 (UTC) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w9J3dr1b187694 for ; Thu, 18 Oct 2018 23:40:58 -0400 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0b-001b2d01.pphosted.com with ESMTP id 2n73y2qkp8-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 18 Oct 2018 23:40:58 -0400 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 18 Oct 2018 21:40:57 -0600 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e33.co.us.ibm.com (192.168.1.133) 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:40:54 -0600 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w9J3eqwB47710370 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 18 Oct 2018 20:40:52 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A36C66E05B; Fri, 19 Oct 2018 03:40:52 +0000 (GMT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 771456E053; Fri, 19 Oct 2018 03:40:50 +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:50 +0000 (GMT) From: Yi Min Zhao To: libvir-list@redhat.com Date: Fri, 19 Oct 2018 11:40:13 +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-0036-0000-0000-00000A4D1864 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.00571940; IPR=6.00884797; MB=3.00023816; MTD=3.00000008; XFM=3.00000015; UTC=2018-10-19 03:40:55 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18101903-0037-0000-0000-0000495643BD Message-Id: <20181019034020.4757-8-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=810 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.45]); Fri, 19 Oct 2018 03:40:59 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 19 Oct 2018 03:40:59 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-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.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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 07/14] conf: use virXMLFormatElement() in virDomainDeviceInfoFormat() 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 19 Oct 2018 04:06:37 +0000 (UTC) X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" In order to add zPCI child element for PCI address, we update virDomainDeviceInfoFormat() to format device info by helper function virXMLFormatElement(). Then we could simply format zPCI address into child buffer later. Signed-off-by: Yi Min Zhao Reviewed-by: Boris Fiuczynski Reviewed-by: Andrea Bolognani --- src/conf/domain_conf.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e8e0adc819..88964f10c6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6400,6 +6400,8 @@ virDomainDeviceInfoFormat(virBufferPtr buf, virDomainDeviceInfoPtr info, unsigned int flags) { + virBuffer attrBuf =3D VIR_BUFFER_INITIALIZER; + if ((flags & VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT) && info->bootIndex) { virBufferAsprintf(buf, "bootIndex); =20 @@ -6444,13 +6446,13 @@ virDomainDeviceInfoFormat(virBufferPtr buf, info->type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) return; =20 - virBufferAsprintf(buf, "
type)); =20 switch ((virDomainDeviceAddressType) info->type) { case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: if (!virPCIDeviceAddressIsEmpty(&info->addr.pci)) { - virBufferAsprintf(buf, " domain=3D'0x%.4x' bus=3D'0x%.2x' " + virBufferAsprintf(&attrBuf, " domain=3D'0x%.4x' bus=3D'0x%.2x'= " "slot=3D'0x%.2x' function=3D'0x%.1x'", info->addr.pci.domain, info->addr.pci.bus, @@ -6458,13 +6460,13 @@ virDomainDeviceInfoFormat(virBufferPtr buf, info->addr.pci.function); } if (info->addr.pci.multi) { - virBufferAsprintf(buf, " multifunction=3D'%s'", - virTristateSwitchTypeToString(info->addr.pci.= multi)); + virBufferAsprintf(&attrBuf, " multifunction=3D'%s'", + virTristateSwitchTypeToString(info->addr.pci= .multi)); } break; =20 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE: - virBufferAsprintf(buf, " controller=3D'%d' bus=3D'%d' target=3D'%d= ' unit=3D'%d'", + virBufferAsprintf(&attrBuf, " controller=3D'%d' bus=3D'%d' target= =3D'%d' unit=3D'%d'", info->addr.drive.controller, info->addr.drive.bus, info->addr.drive.target, @@ -6472,34 +6474,34 @@ virDomainDeviceInfoFormat(virBufferPtr buf, break; =20 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL: - virBufferAsprintf(buf, " controller=3D'%d' bus=3D'%d' port=3D'%d'", + virBufferAsprintf(&attrBuf, " controller=3D'%d' bus=3D'%d' port=3D= '%d'", info->addr.vioserial.controller, info->addr.vioserial.bus, info->addr.vioserial.port); break; =20 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID: - virBufferAsprintf(buf, " controller=3D'%d' slot=3D'%d'", + virBufferAsprintf(&attrBuf, " controller=3D'%d' slot=3D'%d'", info->addr.ccid.controller, info->addr.ccid.slot); break; =20 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB: - virBufferAsprintf(buf, " bus=3D'%d'", info->addr.usb.bus); + virBufferAsprintf(&attrBuf, " bus=3D'%d'", info->addr.usb.bus); if (virDomainUSBAddressPortIsValid(info->addr.usb.port)) { - virBufferAddLit(buf, " port=3D'"); - virDomainUSBAddressPortFormatBuf(buf, info->addr.usb.port); - virBufferAddLit(buf, "'"); + virBufferAddLit(&attrBuf, " port=3D'"); + virDomainUSBAddressPortFormatBuf(&attrBuf, info->addr.usb.port= ); + virBufferAddLit(&attrBuf, "'"); } break; =20 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO: if (info->addr.spaprvio.has_reg) - virBufferAsprintf(buf, " reg=3D'0x%llx'", info->addr.spaprvio.= reg); + virBufferAsprintf(&attrBuf, " reg=3D'0x%llx'", info->addr.spap= rvio.reg); break; =20 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW: - virBufferAsprintf(buf, " cssid=3D'0x%x' ssid=3D'0x%x' devno=3D'0x%= 04x'", + virBufferAsprintf(&attrBuf, " cssid=3D'0x%x' ssid=3D'0x%x' devno= =3D'0x%04x'", info->addr.ccw.cssid, info->addr.ccw.ssid, info->addr.ccw.devno); @@ -6510,15 +6512,15 @@ virDomainDeviceInfoFormat(virBufferPtr buf, =20 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA: if (info->addr.isa.iobase > 0) - virBufferAsprintf(buf, " iobase=3D'0x%x'", info->addr.isa.ioba= se); + virBufferAsprintf(&attrBuf, " iobase=3D'0x%x'", info->addr.isa= .iobase); if (info->addr.isa.irq > 0) - virBufferAsprintf(buf, " irq=3D'0x%x'", info->addr.isa.irq); + virBufferAsprintf(&attrBuf, " irq=3D'0x%x'", info->addr.isa.ir= q); break; =20 case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM: - virBufferAsprintf(buf, " slot=3D'%u'", info->addr.dimm.slot); + virBufferAsprintf(&attrBuf, " slot=3D'%u'", info->addr.dimm.slot); if (info->addr.dimm.base) - virBufferAsprintf(buf, " base=3D'0x%llx'", info->addr.dimm.bas= e); + virBufferAsprintf(&attrBuf, " base=3D'0x%llx'", info->addr.dim= m.base); =20 break; =20 @@ -6528,7 +6530,9 @@ virDomainDeviceInfoFormat(virBufferPtr buf, break; } =20 - virBufferAddLit(buf, "/>\n"); + virXMLFormatElement(buf, "address", &attrBuf, NULL); + + virBufferFreeAndReset(&attrBuf); } =20 static int --=20 Yi Min -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list