From nobody Fri May 16 08:44:02 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.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 1496769722558653.9009345334335; Tue, 6 Jun 2017 10:22:02 -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 D7D70C04B326; Tue, 6 Jun 2017 17:21:54 +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 B4E126031D; Tue, 6 Jun 2017 17:21:54 +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 5E504180BAFA; Tue, 6 Jun 2017 17:21:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v559R8B5001973 for ; Mon, 5 Jun 2017 05:27:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1576584018; Mon, 5 Jun 2017 09:27:08 +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 D618284011 for ; Mon, 5 Jun 2017 09:27:05 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 9EACD10CCF8; Mon, 5 Jun 2017 11:27:04 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D7D70C04B326 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=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D7D70C04B326 From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 5 Jun 2017 11:26:51 +0200 Message-Id: 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.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 03/15] 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 06 Jun 2017 17:21:55 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark --- 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