From nobody Mon Feb 9 00:30:01 2026 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.zoho.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 1496824675433949.7558512906444; Wed, 7 Jun 2017 01:37:55 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 83B7C537B; Wed, 7 Jun 2017 08:37:53 +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 9B5535C54F; Wed, 7 Jun 2017 08:37:52 +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 A2853180BAFA; Wed, 7 Jun 2017 08:37:50 +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 v578bnEe004786 for ; Wed, 7 Jun 2017 04:37:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9FC337D967; Wed, 7 Jun 2017 08:37:49 +0000 (UTC) Received: from virval.usersys.redhat.com (dhcp129-92.brq.redhat.com [10.34.129.92]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7453D7D955 for ; Wed, 7 Jun 2017 08:37:47 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 70D4610192E; Wed, 7 Jun 2017 10:37:46 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 83B7C537B 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 83B7C537B From: Jiri Denemark To: libvir-list@redhat.com Date: Wed, 7 Jun 2017 10:37:28 +0200 Message-Id: <8909d510289a4a54e9136009df29948c1cda6406.1496824604.git.jdenemar@redhat.com> In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 03/20] conf: Make virDomainSnapshotDefFormat easier to read 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 07 Jun 2017 08:37:54 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: Pavel Hrdina --- Notes: Version 2: - no change src/conf/snapshot_conf.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index b6cba5ac3..7daa9b22a 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -686,11 +686,13 @@ virDomainSnapshotDiskDefFormat(virBufferPtr buf, virBufferAddLit(buf, "\n"); } =20 -char *virDomainSnapshotDefFormat(const char *domain_uuid, - virDomainSnapshotDefPtr def, - virCapsPtr caps, - unsigned int flags, - int internal) + +char * +virDomainSnapshotDefFormat(const char *domain_uuid, + virDomainSnapshotDefPtr def, + virCapsPtr caps, + unsigned int flags, + int internal) { virBuffer buf =3D VIR_BUFFER_INITIALIZER; size_t i; @@ -702,12 +704,14 @@ char *virDomainSnapshotDefFormat(const char *domain_u= uid, =20 virBufferAddLit(&buf, "\n"); virBufferAdjustIndent(&buf, 2); + virBufferEscapeString(&buf, "%s\n", def->name); if (def->description) virBufferEscapeString(&buf, "%s\n", def->description); virBufferAsprintf(&buf, "%s\n", virDomainSnapshotStateTypeToString(def->state)); + if (def->parent) { virBufferAddLit(&buf, "\n"); virBufferAdjustIndent(&buf, 2); @@ -715,14 +719,17 @@ char *virDomainSnapshotDefFormat(const char *domain_u= uid, virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, "\n"); } + virBufferAsprintf(&buf, "%lld\n", def->creationTime); + if (def->memory) { virBufferAsprintf(&buf, "memor= y)); virBufferEscapeString(&buf, " file=3D'%s'", def->file); virBufferAddLit(&buf, "/>\n"); } + if (def->ndisks) { virBufferAddLit(&buf, "\n"); virBufferAdjustIndent(&buf, 2); @@ -731,11 +738,10 @@ char *virDomainSnapshotDefFormat(const char *domain_u= uid, virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, "\n"); } + if (def->dom) { - if (virDomainDefFormatInternal(def->dom, caps, flags, &buf) < 0) { - virBufferFreeAndReset(&buf); - return NULL; - } + if (virDomainDefFormatInternal(def->dom, caps, flags, &buf) < 0) + goto error; } else if (domain_uuid) { virBufferAddLit(&buf, "\n"); virBufferAdjustIndent(&buf, 2); @@ -743,8 +749,10 @@ char *virDomainSnapshotDefFormat(const char *domain_uu= id, virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, "\n"); } + if (internal) virBufferAsprintf(&buf, "%d\n", def->current); + virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, "\n"); =20 @@ -752,6 +760,10 @@ char *virDomainSnapshotDefFormat(const char *domain_uu= id, return NULL; =20 return virBufferContentAndReset(&buf); + + error: + virBufferFreeAndReset(&buf); + return NULL; } =20 /* Snapshot Obj functions */ --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list