From nobody Mon Feb 9 03:48:21 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571925440; cv=none; d=zoho.com; s=zohoarc; b=YuP8VHzC9dVCVm2nUSk2CDY29NiOf4gHoRLMMf0li5667610Id1IkxUnfVZsZ9+Cui3XoiDi/whbNsCYHXMJo21bwyTRuRbeUdn7vrmoxJTLQp/+L+wogl5bLpt5Df/vHw572qdHkVfNhHaL7s/ryrEws3Rm5R6Ib7VV+A5RcMA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571925440; h=Content-Type:Content-Transfer-Encoding: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=UOdScD7rrFQqgNIZxE3VjD7L9EBDpJtkCGKnPHuEXFY=; b=hCx38snpsqWKwJs2Qf10BaEQC3oUb2i93vX9qfb3nTGO4OYzHwgw0g9/U4Yi2S2fvOkjg3MhcbPQJ1rkdFa8wlF58K5A/DCGhpk81UQCoyejFb3TIossMhzb9xsAKd6sW1DI6FoSUhkB6HOquOHndL77zTDWxHAL7h9SJhPuaKE= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1571925440294308.4389540347846; Thu, 24 Oct 2019 06:57:20 -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-48-KbU5bS8iMaa8NmBArBORjg-1; Thu, 24 Oct 2019 09:57:17 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D6A5B801E78; Thu, 24 Oct 2019 13:57:11 +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 A5EC5194B6; Thu, 24 Oct 2019 13:57:11 +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 5F8724EE97; Thu, 24 Oct 2019 13:57:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9ODv420026400 for ; Thu, 24 Oct 2019 09:57:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8129610027AB; Thu, 24 Oct 2019 13:57:04 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B0A7100164D for ; Thu, 24 Oct 2019 13:57:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571925439; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=UOdScD7rrFQqgNIZxE3VjD7L9EBDpJtkCGKnPHuEXFY=; b=SigDNJ/U9oMGicrm94+43MSmt1zCWrgMjCsaL7waLRy6A9hBeifdgq7VsTFPPf7VcZ150u j5X/aIcOoZ2wfSFrQ063XbSVBB/Zn3v9WVBQLTHW5Hj/nRbyAwsiJ7EDrRt6Nzpu3f/JJT Udksh+nuNQujsf3jVT3k46P16ZANbps= From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 24 Oct 2019 15:56:29 +0200 Message-Id: <638f873f1aab3de23ec5169b65d598ad0a6427b3.1571925291.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 11/19] util: sysinfo: Use virXMLFormatElement and infrastructure in virSysinfoFormat 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.84 on 10.5.11.23 X-MC-Unique: KbU5bS8iMaa8NmBArBORjg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" It basically implements almost the same thing, so we can replace it with existing helpers with a few tweaks. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/util/virsysinfo.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index 0a622dbbf9..6e7e221f00 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -1481,20 +1481,19 @@ virSysinfoOEMStringsFormat(virBufferPtr buf, virSys= infoOEMStringsDefPtr def) int virSysinfoFormat(virBufferPtr buf, virSysinfoDefPtr def) { + virBuffer attrBuf =3D VIR_BUFFER_INITIALIZER; virBuffer childrenBuf =3D VIR_BUFFER_INITIALIZER; const char *type =3D virSysinfoTypeToString(def->type); - int indent =3D virBufferGetIndent(buf, false); - int ret =3D -1; if (!type) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected sysinfo type model %d"), def->type); virBufferFreeAndReset(buf); - goto cleanup; + return -1; } - virBufferAdjustIndent(&childrenBuf, indent + 2); + virBufferSetChildIndent(&childrenBuf, buf); virSysinfoBIOSFormat(&childrenBuf, def->bios); virSysinfoSystemFormat(&childrenBuf, def->system); @@ -1504,22 +1503,17 @@ virSysinfoFormat(virBufferPtr buf, virSysinfoDefPtr= def) virSysinfoMemoryFormat(&childrenBuf, def); virSysinfoOEMStringsFormat(&childrenBuf, def->oemStrings); - virBufferAsprintf(buf, "\n"); - virBufferAddBuffer(buf, &childrenBuf); - virBufferAddLit(buf, "\n"); - } else { - virBufferAddLit(buf, "/>\n"); + virBufferAsprintf(&attrBuf, " type=3D'%s'", type); + + if (virXMLFormatElement(buf, "sysinfo", &attrBuf, &childrenBuf) < 0) { + virBufferFreeAndReset(buf); + return -1; } if (virBufferCheckError(buf) < 0) - goto cleanup; + return -1; - ret =3D 0; - cleanup: - virBufferFreeAndReset(&childrenBuf); - return ret; + return 0; } #define CHECK_FIELD(name, desc) \ --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list