From nobody Mon Feb 9 03:48:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1610031599; cv=none; d=zohomail.com; s=zohoarc; b=TdIo6j5SV1wRElIHRY7+zlKPadzQl2ejsTJbNtdTITDgSKsw0I1Tt5j/czMpjtLLV6Fwug+g+qT02kJBHIgqujOK80MaB6ArT1CG3buzcsgiL6fWKiD8nLJuKZl3HYlxUKo36fik4QcZMVWs1mWHLvZcgNlm8Fu02loqpGa0b58= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610031599; 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=vdNWnqCqeF+3kuR44cCujk4tHUmNQIoT87dJlJMNmTI=; b=B3fdx6IJX8ZSCQOdVNYlJuPHHuRVmKovoCYpiD+ny024QfnV5/bieHD5lqDpt0wsFsHzTdXe6J/WX/3yyXkqI/YNuuOn+6al8K+qINrfWthjJv/vNweUKQq8vlXVzGpMt6uOI0Nv/PeTkgHVHmYiSPk+tAWzetBUDQE0uRBDMeE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1610031599418651.087008455458; Thu, 7 Jan 2021 06:59:59 -0800 (PST) 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-595-3-PNgJK7OGiK6osBLhRmvQ-1; Thu, 07 Jan 2021 09:59:55 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1706718C8C00; Thu, 7 Jan 2021 14:59:49 +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 E7D005E1A7; Thu, 7 Jan 2021 14:59:48 +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 B1B3F50030; Thu, 7 Jan 2021 14:59:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 107ExkJc005525 for ; Thu, 7 Jan 2021 09:59:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id 23555177F8; Thu, 7 Jan 2021 14:59:46 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 684DB5E1A7 for ; Thu, 7 Jan 2021 14:59:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1610031598; 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=vdNWnqCqeF+3kuR44cCujk4tHUmNQIoT87dJlJMNmTI=; b=JpBfZ/diOcv7Dj82XC0SZ/g+5nF+mxzjDEkWjCXDsCR+FCcA5F88nSpeX7gXVmQMxTqN9o 2bPajuio9FW88Wl0B5eiuNTla1KnkYY5SWS1c/yLc0o+0v1TdUrqtBX6j5SHAhq0nep2Ug qzJQQQHKXREfaDmjEZ4zAzPSxE4Z6IY= X-MC-Unique: 3-PNgJK7OGiK6osBLhRmvQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 2/5] virDomainSnapshotDiskDefFormat: Use virXMLFormatElement Date: Thu, 7 Jan 2021 15:59:35 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com 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.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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" Refactor the code to use modern XML formatting approach. Signed-off-by: Peter Krempa --- src/conf/snapshot_conf.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index f896fd1cf2..757af681cd 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -772,33 +772,30 @@ virDomainSnapshotDiskDefFormat(virBufferPtr buf, virDomainSnapshotDiskDefPtr disk, virDomainXMLOptionPtr xmlopt) { - int type =3D disk->src->type; + g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); if (!disk->name) return 0; - virBufferEscapeString(buf, "name); + virBufferEscapeString(&attrBuf, " name=3D'%s'", disk->name); if (disk->snapshot > 0) - virBufferAsprintf(buf, " snapshot=3D'%s'", + virBufferAsprintf(&attrBuf, " snapshot=3D'%s'", virDomainSnapshotLocationTypeToString(disk->snap= shot)); - if (!disk->src->path && disk->src->format =3D=3D 0) { - virBufferAddLit(buf, "/>\n"); - return 0; - } + if (disk->src->path || disk->src->format !=3D 0) { + virBufferAsprintf(&attrBuf, " type=3D'%s'", virStorageTypeToString= (disk->src->type)); - virBufferAsprintf(buf, " type=3D'%s'>\n", virStorageTypeToString(type)= ); - virBufferAdjustIndent(buf, 2); + if (disk->src->format > 0) + virBufferEscapeString(&childBuf, "\n", + virStorageFileFormatTypeToString(disk->s= rc->format)); - if (disk->src->format > 0) - virBufferEscapeString(buf, "\n", - virStorageFileFormatTypeToString(disk->src->= format)); - if (virDomainDiskSourceFormat(buf, disk->src, "source", 0, false, 0, - false, false, xmlopt) < 0) + if (virDomainDiskSourceFormat(&childBuf, disk->src, "source", 0, f= alse, 0, + false, false, xmlopt) < 0) return -1; + } - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); + virXMLFormatElement(buf, "disk", &attrBuf, &childBuf); return 0; } --=20 2.29.2