From nobody Fri May 3 02:57:22 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.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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1501075795284466.2617082311268; Wed, 26 Jul 2017 06:29:55 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 16238285A8; Wed, 26 Jul 2017 13:29: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 CEEFC7765D; Wed, 26 Jul 2017 13:29:51 +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 7709F4A468; Wed, 26 Jul 2017 13:29:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6QDTiXn012003 for ; Wed, 26 Jul 2017 09:29:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8A4225D978; Wed, 26 Jul 2017 13:29:44 +0000 (UTC) Received: from dnr.brq.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 128E87812E for ; Wed, 26 Jul 2017 13:29:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 16238285A8 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Wed, 26 Jul 2017 15:29:29 +0200 Message-Id: <4de850d990f0f36300e410c8b9ed2caf19425ab6.1501075760.git.jtomko@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/8] Remove superfluous usage of virDomainDeviceInfoNeedsFormat 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 26 Jul 2017 13:29:52 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This function returns false if virDomainDeviceInfoFormat would not format anything. Using it as the sole condition to decide whether to call virDomainDeviceInfoFormat or not is pointless, since the conditions are repeated in virDomainDeviceInfoFormat. Reviewed-by: John Ferlan --- src/conf/domain_conf.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 34c8f45ed..73c4b55e9 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -21903,8 +21903,7 @@ virDomainControllerDefFormat(virBufferPtr buf, =20 virDomainControllerDriverFormat(&childBuf, def); =20 - if (virDomainDeviceInfoNeedsFormat(&def->info, flags) && - virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0) + if (virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0) return -1; =20 if (def->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI && @@ -23037,10 +23036,8 @@ virDomainChrDefFormat(virBufferPtr buf, break; } =20 - if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) { - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) - return -1; - } + if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) + return -1; =20 virBufferAdjustIndent(buf, -2); virBufferAsprintf(buf, "\n", elementName); @@ -23142,10 +23139,8 @@ virDomainTPMDefFormat(virBufferPtr buf, virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); =20 - if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) { - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) - return -1; - } + if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) + return -1; =20 virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); @@ -23227,8 +23222,7 @@ virDomainMemballoonDefFormat(virBufferPtr buf, if (def->period) virBufferAsprintf(&childrenBuf, "\n", def->p= eriod); =20 - if (virDomainDeviceInfoNeedsFormat(&def->info, flags) && - virDomainDeviceInfoFormat(&childrenBuf, &def->info, flags) < 0) { + if (virDomainDeviceInfoFormat(&childrenBuf, &def->info, flags) < 0) { virBufferFreeAndReset(&childrenBuf); return -1; } @@ -23267,8 +23261,7 @@ virDomainNVRAMDefFormat(virBufferPtr buf, { virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, 2); - if (virDomainDeviceInfoNeedsFormat(&def->info, flags) && - virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) + if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) return -1; =20 virBufferAdjustIndent(buf, -2); @@ -23427,10 +23420,8 @@ virDomainRNGDefFormat(virBufferPtr buf, virBufferAddLit(buf, "/>\n"); } =20 - if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) { - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) - return -1; - } + if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) + return -1; =20 virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); @@ -23548,10 +23539,8 @@ virDomainMemoryDefFormat(virBufferPtr buf, =20 virDomainMemoryTargetDefFormat(buf, def); =20 - if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) { - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) - return -1; - } + if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) + return -1; =20 virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 02:57:22 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.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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1501075793708576.6276283446294; Wed, 26 Jul 2017 06:29:53 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A7384C0B2C47; Wed, 26 Jul 2017 13:29:50 +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 651A0784B2; Wed, 26 Jul 2017 13:29:50 +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 1166F4BB79; Wed, 26 Jul 2017 13:29:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6QDTkSr012017 for ; Wed, 26 Jul 2017 09:29:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id CB690757BD; Wed, 26 Jul 2017 13:29:46 +0000 (UTC) Received: from dnr.brq.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5410E7814B for ; Wed, 26 Jul 2017 13:29:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A7384C0B2C47 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Wed, 26 Jul 2017 15:29:30 +0200 Message-Id: <159f98ea9b864b512200a9363187ee9007b6cbcc.1501075760.git.jtomko@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/8] virDomainDeviceInfoFormat: delete outdated comments 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 26 Jul 2017 13:29:51 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This function has grown to format more than just the address. Delete the comment completely to avoid failing to update it in the future. Also, the indentation is now handled by the virBuffer APIs, so the comment about indentation no longer makes sense. Reviewed-by: John Ferlan --- src/conf/domain_conf.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 73c4b55e9..6c958bcf6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5349,9 +5349,6 @@ virDomainVirtioOptionsFormat(virBufferPtr buf, } =20 =20 -/* Generate a string representation of a device address - * @info address Device address to stringify - */ static int ATTRIBUTE_NONNULL(2) virDomainDeviceInfoFormat(virBufferPtr buf, virDomainDeviceInfoPtr info, @@ -5400,7 +5397,6 @@ virDomainDeviceInfoFormat(virBufferPtr buf, info->type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) return 0; =20 - /* We'll be in domain/devices/[device type]/ so 3 level indent */ virBufferAsprintf(buf, "
type)); =20 --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 02:57:22 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.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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1501075801630800.3549512711654; Wed, 26 Jul 2017 06:30:01 -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 27A3825CD9; Wed, 26 Jul 2017 13:29:56 +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 E50CF78121; Wed, 26 Jul 2017 13:29:55 +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 9AD7F180597D; Wed, 26 Jul 2017 13:29:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6QDTn4N012028 for ; Wed, 26 Jul 2017 09:29:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 094E0757BD; Wed, 26 Jul 2017 13:29:49 +0000 (UTC) Received: from dnr.brq.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 86C1078152 for ; Wed, 26 Jul 2017 13:29:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 27A3825CD9 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Wed, 26 Jul 2017 15:29:31 +0200 Message-Id: <0d833514faac4e74897bf30748377b3817038e41.1501075760.git.jtomko@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/8] Use a separate buffer for subelements 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]); Wed, 26 Jul 2017 13:29:56 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Convert virDomainSmartcardDefFormat to use a separate buffer for possible subelements, to avoid the need for duplicated formatting logic in virDomainDeviceInfoNeedsFormat. Reviewed-by: John Ferlan --- src/conf/domain_conf.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6c958bcf6..ead94976d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -23047,37 +23047,32 @@ virDomainSmartcardDefFormat(virBufferPtr buf, unsigned int flags) { const char *mode =3D virDomainSmartcardTypeToString(def->type); + virBuffer childBuf =3D VIR_BUFFER_INITIALIZER; size_t i; =20 + virBufferAdjustIndent(&childBuf, virBufferGetIndent(buf, false) + 2); + if (!mode) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected smartcard type %d"), def->type); return -1; } =20 - virBufferAsprintf(buf, "type) { case VIR_DOMAIN_SMARTCARD_TYPE_HOST: - if (!virDomainDeviceInfoNeedsFormat(&def->info, flags)) { - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "/>\n"); - return 0; - } - virBufferAddLit(buf, ">\n"); break; =20 case VIR_DOMAIN_SMARTCARD_TYPE_HOST_CERTIFICATES: - virBufferAddLit(buf, ">\n"); - for (i =3D 0; i < VIR_DOMAIN_SMARTCARD_NUM_CERTIFICATES; i++) - virBufferEscapeString(buf, "%s\n", + for (i =3D 0; i < VIR_DOMAIN_SMARTCARD_NUM_CERTIFICATES; i++) { + virBufferEscapeString(&childBuf, "%s\n", def->data.cert.file[i]); - virBufferEscapeString(buf, "%s\n", + } + virBufferEscapeString(&childBuf, "%s\n", def->data.cert.database); break; =20 case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH: - if (virDomainChrSourceDefFormat(buf, def->data.passthru, false, + if (virDomainChrSourceDefFormat(&childBuf, def->data.passthru, fal= se, flags) < 0) return -1; break; @@ -23087,10 +23082,22 @@ virDomainSmartcardDefFormat(virBufferPtr buf, _("unexpected smartcard type %d"), def->type); return -1; } - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) + if (virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0) { + virBufferFreeAndReset(&childBuf); return -1; - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); + } + + if (virBufferCheckError(&childBuf) < 0) + return -1; + + virBufferAsprintf(buf, "\n"); + virBufferAddBuffer(buf, &childBuf); + virBufferAddLit(buf, "\n"); + } else { + virBufferAddLit(buf, "/>\n"); + } return 0; } =20 --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 02:57:22 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.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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1501075805365838.7167979715476; Wed, 26 Jul 2017 06:30:05 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 187306557; Wed, 26 Jul 2017 13:30:00 +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 CC08477662; Wed, 26 Jul 2017 13:29:59 +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 743B9180B467; Wed, 26 Jul 2017 13:29:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6QDTrVZ012044 for ; Wed, 26 Jul 2017 09:29:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6B97077A06; Wed, 26 Jul 2017 13:29:53 +0000 (UTC) Received: from dnr.brq.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id E764A5D978 for ; Wed, 26 Jul 2017 13:29:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 187306557 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Wed, 26 Jul 2017 15:29:32 +0200 Message-Id: <834713597c4c0c08c413510620c0e82e50f25050.1501075760.git.jtomko@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/8] Use a separate buffer for subelements 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 26 Jul 2017 13:30:00 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Convert virDomainSoundDefFormat to use a separate buffer for subelements. Reviewed-by: John Ferlan --- src/conf/domain_conf.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ead94976d..6c4f2f398 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -23158,38 +23158,32 @@ virDomainSoundDefFormat(virBufferPtr buf, unsigned int flags) { const char *model =3D virDomainSoundModelTypeToString(def->model); - bool children =3D false; + virBuffer childBuf =3D VIR_BUFFER_INITIALIZER; size_t i; =20 + virBufferAdjustIndent(&childBuf, virBufferGetIndent(buf, false) + 2); + if (!model) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected sound model %d"), def->model); return -1; } =20 - virBufferAsprintf(buf, "ncodecs; i++) + virDomainSoundCodecDefFormat(&childBuf, def->codecs[i]); =20 - for (i =3D 0; i < def->ncodecs; i++) { - if (!children) { - virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); - children =3D true; - } - virDomainSoundCodecDefFormat(buf, def->codecs[i]); + if (virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0) { + virBufferFreeAndReset(&childBuf); + return -1; } =20 - if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) { - if (!children) { - virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); - children =3D true; - } - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) - return -1; - } + if (virBufferCheckError(&childBuf) < 0) + return -1; =20 - if (children) { - virBufferAdjustIndent(buf, -2); + virBufferAsprintf(buf, "\n"); + virBufferAddBuffer(buf, &childBuf); virBufferAddLit(buf, "\n"); } else { virBufferAddLit(buf, "/>\n"); --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 02:57:22 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.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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1501075801826637.5499186555064; Wed, 26 Jul 2017 06:30:01 -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 E4CB78B135; Wed, 26 Jul 2017 13:29:59 +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 B7D436FDA1; Wed, 26 Jul 2017 13:29:59 +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 65A3C4A46A; Wed, 26 Jul 2017 13:29:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6QDTwQX012055 for ; Wed, 26 Jul 2017 09:29:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 60AA877A06; Wed, 26 Jul 2017 13:29:58 +0000 (UTC) Received: from dnr.brq.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id DDDF67814B for ; Wed, 26 Jul 2017 13:29:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E4CB78B135 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Wed, 26 Jul 2017 15:29:33 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/8] Use a separate buffer for subelements 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.28]); Wed, 26 Jul 2017 13:30:00 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Convert virDomainWatchdogDefFormat to use a separate buffer for subelements. Reviewed-by: John Ferlan --- src/conf/domain_conf.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6c4f2f398..fdac0e0ba 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -23275,6 +23275,9 @@ virDomainWatchdogDefFormat(virBufferPtr buf, { const char *model =3D virDomainWatchdogModelTypeToString(def->model); const char *action =3D virDomainWatchdogActionTypeToString(def->action= ); + virBuffer childBuf =3D VIR_BUFFER_INITIALIZER; + + virBufferAdjustIndent(&childBuf, virBufferGetIndent(buf, false) + 2); =20 if (!model) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -23288,15 +23291,18 @@ virDomainWatchdogDefFormat(virBufferPtr buf, return -1; } =20 + if (virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0) + return -1; + + if (virBufferCheckError(&childBuf) < 0) + return -1; + virBufferAsprintf(buf, "info, flags)) { + if (virBufferUse(&childBuf)) { virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) - return -1; - virBufferAdjustIndent(buf, -2); + virBufferAddBuffer(buf, &childBuf); virBufferAddLit(buf, "\n"); } else { virBufferAddLit(buf, "/>\n"); --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 02:57:22 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.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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1501075817638574.2260502751615; Wed, 26 Jul 2017 06:30:17 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 49131272D4; Wed, 26 Jul 2017 13:30:13 +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 151F8785F2; Wed, 26 Jul 2017 13:30: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 F095814B27; Wed, 26 Jul 2017 13:30:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6QDU9RS012078 for ; Wed, 26 Jul 2017 09:30:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4087677A06; Wed, 26 Jul 2017 13:30:09 +0000 (UTC) Received: from dnr.brq.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD2B678159 for ; Wed, 26 Jul 2017 13:29:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 49131272D4 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Wed, 26 Jul 2017 15:29:34 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 6/8] Use a separate buffer for subelements 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 26 Jul 2017 13:30:14 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Switch virDomainHubDefFormat to use a separate buffer for subelements. Reviewed-by: John Ferlan --- src/conf/domain_conf.c | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index fdac0e0ba..7728321cb 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3529,23 +3529,6 @@ virDomainDeviceGetInfo(virDomainDeviceDefPtr device) return NULL; } =20 -static bool -virDomainDeviceInfoNeedsFormat(virDomainDeviceInfoPtr info, unsigned int f= lags) -{ - if (info->type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) - return true; - if (info->alias && !(flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE)) - return true; - if (info->mastertype !=3D VIR_DOMAIN_CONTROLLER_MASTER_NONE) - return true; - if ((info->rombar !=3D VIR_TRISTATE_SWITCH_ABSENT) || - info->romfile) - return true; - if (info->bootIndex) - return true; - return false; -} - =20 static int virDomainDefHasDeviceAddressIterator(virDomainDefPtr def ATTRIBUTE_UNUSED, @@ -24304,6 +24287,9 @@ virDomainHubDefFormat(virBufferPtr buf, unsigned int flags) { const char *type =3D virDomainHubTypeToString(def->type); + virBuffer childBuf =3D VIR_BUFFER_INITIALIZER; + + virBufferAdjustIndent(&childBuf, virBufferGetIndent(buf, false) + 2); =20 if (!type) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -24311,14 +24297,16 @@ virDomainHubDefFormat(virBufferPtr buf, return -1; } =20 - virBufferAsprintf(buf, "info, flags) < 0) + return -1; + + if (virBufferCheckError(&childBuf) < 0) + return -1; =20 - if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) { + virBufferAsprintf(buf, "\n"); - virBufferAdjustIndent(buf, 2); - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) - return -1; - virBufferAdjustIndent(buf, -2); + virBufferAddBuffer(buf, &childBuf); virBufferAddLit(buf, "\n"); } else { virBufferAddLit(buf, "/>\n"); --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 02:57:22 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.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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1501076024172290.34413495246656; Wed, 26 Jul 2017 06:33:44 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3FAFAD69CA; Wed, 26 Jul 2017 13:33:40 +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 A2E198FBE8; Wed, 26 Jul 2017 13:33:39 +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 71FC14BB79; Wed, 26 Jul 2017 13:33:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6QDUF3e012106 for ; Wed, 26 Jul 2017 09:30:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id B76BF78121; Wed, 26 Jul 2017 13:30:15 +0000 (UTC) Received: from dnr.brq.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3EDFE7ADB5 for ; Wed, 26 Jul 2017 13:30:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3FAFAD69CA Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Wed, 26 Jul 2017 15:29:35 +0200 Message-Id: <92409353e297a7199b4683a4b672d1d1400de829.1501075760.git.jtomko@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 7/8] conf: check for buffer errors before virBufferUse 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 26 Jul 2017 13:33:41 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" After an OOM error, virBuffer* APIs set buf->use to zero. Adding a buffer to the parent buffer only if use is non-zero would quitely drop data on error. Check the error beforehand to make sure buf->use is zero because we have not attempted to add anything to it. Reviewed-by: John Ferlan --- src/conf/capabilities.c | 5 +++++ src/conf/cpu_conf.c | 4 ++++ src/conf/domain_conf.c | 31 +++++++++++++++++++++++++++++-- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 0f99f3096..db7efffdf 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -930,6 +930,11 @@ virCapabilitiesFormatCaches(virBufferPtr buf, bank->controls[j]->max_allocation); } =20 + if (virBufferCheckError(&controlBuf) < 0) { + VIR_FREE(cpus_str); + return -1; + } + if (virBufferUse(&controlBuf)) { virBufferAddLit(buf, ">\n"); virBufferAddBuffer(buf, &controlBuf); diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index da40e9ba9..065b4df99 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -646,6 +646,10 @@ virCPUDefFormatBufFull(virBufferPtr buf, if (virDomainNumaDefCPUFormat(&childrenBuf, numa) < 0) goto cleanup; =20 + if (virBufferCheckError(&attributeBuf) < 0 || + virBufferCheckError(&childrenBuf) < 0) + goto cleanup; + /* Put it all together */ if (virBufferUse(&attributeBuf) || virBufferUse(&childrenBuf)) { virBufferAddLit(buf, "virtio); =20 + if (virBufferCheckError(&driverBuf) < 0) + return -1; + if (virBufferUse(&driverBuf)) { virBufferAddLit(buf, "virtio); =20 - if (virBufferUse(&driverBuf)) { + if (virBufferError(&driverBuf) !=3D 0 || virBufferUse(&driverBuf)) { virBufferAddLit(buf, "\n"); @@ -21891,6 +21894,9 @@ virDomainControllerDefFormat(virBufferPtr buf, "pcihole64>\n", def->opts.pciopts.pcihole64size); } =20 + if (virBufferCheckError(&childBuf) < 0) + return -1; + if (virBufferUse(&childBuf)) { virBufferAddLit(buf, ">\n"); virBufferAddBuffer(buf, &childBuf); @@ -21962,6 +21968,9 @@ virDomainFSDefFormat(virBufferPtr buf, =20 virDomainVirtioOptionsFormat(&driverBuf, def->virtio); =20 + if (virBufferCheckError(&driverBuf) < 0) + return -1; + if (virBufferUse(&driverBuf)) { virBufferAddLit(buf, "\n"); } else { @@ -23309,6 +23321,10 @@ static int virDomainPanicDefFormat(virBufferPtr bu= f, virBufferAdjustIndent(&childrenBuf, indent + 2); if (virDomainDeviceInfoFormat(&childrenBuf, &def->info, 0) < 0) return -1; + + if (virBufferCheckError(&childrenBuf) < 0) + return -1; + if (virBufferUse(&childrenBuf)) { virBufferAddLit(buf, ">\n"); virBufferAddBuffer(buf, &childrenBuf); @@ -23655,6 +23671,9 @@ virDomainInputDefFormat(virBufferPtr buf, if (virDomainDeviceInfoFormat(&childbuf, &def->info, flags) < 0) return -1; =20 + if (virBufferCheckError(&childbuf) < 0) + return -1; + if (!virBufferUse(&childbuf)) { virBufferAddLit(buf, "/>\n"); } else { @@ -24596,6 +24615,9 @@ virDomainCputuneDefFormat(virBufferPtr buf, def->iothreadids[i]->iothread_id); } =20 + if (virBufferCheckError(&childrenBuf) < 0) + return -1; + if (virBufferUse(&childrenBuf)) { virBufferAddLit(buf, "\n"); virBufferAddBuffer(buf, &childrenBuf); @@ -24709,7 +24731,8 @@ virDomainIOMMUDefFormat(virBufferPtr buf, =20 virBufferAsprintf(buf, "model)); - if (virBufferUse(&childBuf)) { + + if (virBufferError(&childBuf) !=3D 0 || virBufferUse(&childBuf)) { virBufferAddLit(buf, ">\n"); virBufferAddBuffer(buf, &childBuf); virBufferAddLit(buf, "\n"); @@ -24847,6 +24870,10 @@ virDomainDefFormatInternal(virDomainDefPtr def, virBufferAdjustIndent(&childrenBuf, -2); virBufferAddLit(&childrenBuf, "\n"); } + + if (virBufferCheckError(&childrenBuf) < 0) + goto error; + if (virBufferUse(&childrenBuf)) { virBufferAddLit(buf, "\n"); virBufferAddBuffer(buf, &childrenBuf); --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri May 3 02:57:22 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.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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1501075943579462.6328275865785; Wed, 26 Jul 2017 06:32:23 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 795A0272B2; Wed, 26 Jul 2017 13:32:19 +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 13D556A766; Wed, 26 Jul 2017 13:32:19 +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 6B731180B467; Wed, 26 Jul 2017 13:32:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6QDUPSd012149 for ; Wed, 26 Jul 2017 09:30:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 979C578157; Wed, 26 Jul 2017 13:30:25 +0000 (UTC) Received: from dnr.brq.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F1A278121 for ; Wed, 26 Jul 2017 13:30:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 795A0272B2 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Wed, 26 Jul 2017 15:29:36 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 8/8] Turn virDomainDeviceInfoFormat into void 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 26 Jul 2017 13:32:20 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The rombar attribute was already validated at the time of parsing the XML. Reviewed-by: John Ferlan --- src/conf/domain_conf.c | 94 ++++++++++++++++------------------------------= ---- 1 file changed, 30 insertions(+), 64 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4dc49fdb0..460776ec6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5332,7 +5332,7 @@ virDomainVirtioOptionsFormat(virBufferPtr buf, } =20 =20 -static int ATTRIBUTE_NONNULL(2) +static void ATTRIBUTE_NONNULL(2) virDomainDeviceInfoFormat(virBufferPtr buf, virDomainDeviceInfoPtr info, unsigned int flags) @@ -5360,16 +5360,10 @@ virDomainDeviceInfoFormat(virBufferPtr buf, =20 virBufferAddLit(buf, "rombar) { - const char *rombar =3D virTristateSwitchTypeToString(info->rom= bar); =20 - if (!rombar) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected rom bar value %d"), - info->rombar); - return -1; - } - virBufferAsprintf(buf, " bar=3D'%s'", rombar); + if (rombar) + virBufferAsprintf(buf, " bar=3D'%s'", rombar); } if (info->romfile) virBufferEscapeString(buf, " file=3D'%s'", info->romfile); @@ -5378,7 +5372,7 @@ virDomainDeviceInfoFormat(virBufferPtr buf, =20 if (info->type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE || info->type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390) - return 0; + return; =20 virBufferAsprintf(buf, "
type)); @@ -5465,7 +5459,6 @@ virDomainDeviceInfoFormat(virBufferPtr buf, } =20 virBufferAddLit(buf, "/>\n"); - return 0; } =20 static int @@ -21711,9 +21704,8 @@ virDomainDiskDefFormat(virBufferPtr buf, if (def->src->encryption && virStorageEncryptionFormat(buf, def->src->encryption) < 0) return -1; - if (virDomainDeviceInfoFormat(buf, &def->info, - flags | VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT= ) < 0) - return -1; + virDomainDeviceInfoFormat(buf, &def->info, + flags | VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT); =20 virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); @@ -21885,8 +21877,7 @@ virDomainControllerDefFormat(virBufferPtr buf, =20 virDomainControllerDriverFormat(&childBuf, def); =20 - if (virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0) - return -1; + virDomainDeviceInfoFormat(&childBuf, &def->info, flags); =20 if (def->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_PCI && def->opts.pciopts.pcihole64) { @@ -22018,9 +22009,7 @@ virDomainFSDefFormat(virBufferPtr buf, if (def->readonly) virBufferAddLit(buf, "\n"); =20 - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) - return -1; - + virDomainDeviceInfoFormat(buf, &def->info, flags); =20 if (def->space_hard_limit) virBufferAsprintf(buf, "" @@ -22786,10 +22775,9 @@ virDomainNetDefFormat(virBufferPtr buf, =20 virDomainNetDefCoalesceFormatXML(buf, def->coalesce); =20 - if (virDomainDeviceInfoFormat(buf, &def->info, - flags | VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT - | VIR_DOMAIN_DEF_FORMAT_ALLOW_ROM) < 0) - return -1; + virDomainDeviceInfoFormat(buf, &def->info, + flags | VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT + | VIR_DOMAIN_DEF_FORMAT_ALLOW_ROM); =20 virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); @@ -23024,8 +23012,7 @@ virDomainChrDefFormat(virBufferPtr buf, break; } =20 - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) - return -1; + virDomainDeviceInfoFormat(buf, &def->info, flags); =20 virBufferAdjustIndent(buf, -2); virBufferAsprintf(buf, "\n", elementName); @@ -23074,10 +23061,7 @@ virDomainSmartcardDefFormat(virBufferPtr buf, _("unexpected smartcard type %d"), def->type); return -1; } - if (virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0) { - virBufferFreeAndReset(&childBuf); - return -1; - } + virDomainDeviceInfoFormat(&childBuf, &def->info, flags); =20 if (virBufferCheckError(&childBuf) < 0) return -1; @@ -23134,8 +23118,7 @@ virDomainTPMDefFormat(virBufferPtr buf, virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); =20 - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) - return -1; + virDomainDeviceInfoFormat(buf, &def->info, flags); =20 virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); @@ -23164,10 +23147,7 @@ virDomainSoundDefFormat(virBufferPtr buf, for (i =3D 0; i < def->ncodecs; i++) virDomainSoundCodecDefFormat(&childBuf, def->codecs[i]); =20 - if (virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0) { - virBufferFreeAndReset(&childBuf); - return -1; - } + virDomainDeviceInfoFormat(&childBuf, &def->info, flags); =20 if (virBufferCheckError(&childBuf) < 0) return -1; @@ -23211,10 +23191,7 @@ virDomainMemballoonDefFormat(virBufferPtr buf, if (def->period) virBufferAsprintf(&childrenBuf, "\n", def->p= eriod); =20 - if (virDomainDeviceInfoFormat(&childrenBuf, &def->info, flags) < 0) { - virBufferFreeAndReset(&childrenBuf); - return -1; - } + virDomainDeviceInfoFormat(&childrenBuf, &def->info, flags); =20 if (def->virtio) { virBuffer driverBuf =3D VIR_BUFFER_INITIALIZER; @@ -23253,8 +23230,7 @@ virDomainNVRAMDefFormat(virBufferPtr buf, { virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, 2); - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) - return -1; + virDomainDeviceInfoFormat(buf, &def->info, flags); =20 virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); @@ -23286,8 +23262,7 @@ virDomainWatchdogDefFormat(virBufferPtr buf, return -1; } =20 - if (virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0) - return -1; + virDomainDeviceInfoFormat(&childBuf, &def->info, flags); =20 if (virBufferCheckError(&childBuf) < 0) return -1; @@ -23319,8 +23294,7 @@ static int virDomainPanicDefFormat(virBufferPtr buf, virDomainPanicModelTypeToString(def->model)); =20 virBufferAdjustIndent(&childrenBuf, indent + 2); - if (virDomainDeviceInfoFormat(&childrenBuf, &def->info, 0) < 0) - return -1; + virDomainDeviceInfoFormat(&childrenBuf, &def->info, 0); =20 if (virBufferCheckError(&childrenBuf) < 0) return -1; @@ -23367,8 +23341,7 @@ virDomainShmemDefFormat(virBufferPtr buf, virBufferAddLit(buf, "/>\n"); } =20 - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) - return -1; + virDomainDeviceInfoFormat(buf, &def->info, flags); =20 virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); @@ -23422,8 +23395,7 @@ virDomainRNGDefFormat(virBufferPtr buf, virBufferAddLit(buf, "/>\n"); } =20 - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) - return -1; + virDomainDeviceInfoFormat(buf, &def->info, flags); =20 virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); @@ -23541,8 +23513,7 @@ virDomainMemoryDefFormat(virBufferPtr buf, =20 virDomainMemoryTargetDefFormat(buf, def); =20 - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) - return -1; + virDomainDeviceInfoFormat(buf, &def->info, flags); =20 virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); @@ -23618,8 +23589,7 @@ virDomainVideoDefFormat(virBufferPtr buf, virBufferAddLit(buf, "/>\n"); } =20 - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) - return -1; + virDomainDeviceInfoFormat(buf, &def->info, flags); =20 virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); @@ -23668,8 +23638,7 @@ virDomainInputDefFormat(virBufferPtr buf, virBufferAddLit(&childbuf, "/>\n"); } virBufferEscapeString(&childbuf, "\n", def->sour= ce.evdev); - if (virDomainDeviceInfoFormat(&childbuf, &def->info, flags) < 0) - return -1; + virDomainDeviceInfoFormat(&childbuf, &def->info, flags); =20 if (virBufferCheckError(&childbuf) < 0) return -1; @@ -24229,10 +24198,9 @@ virDomainHostdevDefFormat(virBufferPtr buf, if (def->shareable) virBufferAddLit(buf, "\n"); =20 - if (virDomainDeviceInfoFormat(buf, def->info, - flags | VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT - | VIR_DOMAIN_DEF_FORMAT_ALLOW_ROM) < 0) - return -1; + virDomainDeviceInfoFormat(buf, def->info, + flags | VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT + | VIR_DOMAIN_DEF_FORMAT_ALLOW_ROM); =20 virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); @@ -24253,9 +24221,8 @@ virDomainRedirdevDefFormat(virBufferPtr buf, virBufferAdjustIndent(buf, 2); if (virDomainChrSourceDefFormat(buf, def->source, false, flags) < 0) return -1; - if (virDomainDeviceInfoFormat(buf, &def->info, - flags | VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT= ) < 0) - return -1; + virDomainDeviceInfoFormat(buf, &def->info, + flags | VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); return 0; @@ -24316,8 +24283,7 @@ virDomainHubDefFormat(virBufferPtr buf, return -1; } =20 - if (virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0) - return -1; + virDomainDeviceInfoFormat(&childBuf, &def->info, flags); =20 if (virBufferCheckError(&childBuf) < 0) return -1; --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list