render / rpms / libvirt

Forked from rpms/libvirt 11 months ago
Clone
3e5111
From d1adb920ad7f460e32b1cc68e68120b3c655bc18 Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <d1adb920ad7f460e32b1cc68e68120b3c655bc18@dist-git>
3e5111
From: Jiri Denemark <jdenemar@redhat.com>
3e5111
Date: Thu, 1 Jun 2017 15:57:55 +0200
3e5111
Subject: [PATCH] conf: Make virDomainSnapshotDefFormat easier to read
3e5111
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
3e5111
(cherry picked from commit 00968dca967f4bf9d4f496e5c971bff3f8147ed8)
3e5111
3e5111
https://bugzilla.redhat.com/show_bug.cgi?id=1441662
3e5111
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
---
3e5111
 src/conf/snapshot_conf.c | 30 +++++++++++++++++++++---------
3e5111
 1 file changed, 21 insertions(+), 9 deletions(-)
3e5111
3e5111
diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c
3e5111
index b6cba5ac38..7daa9b22ad 100644
3e5111
--- a/src/conf/snapshot_conf.c
3e5111
+++ b/src/conf/snapshot_conf.c
3e5111
@@ -686,11 +686,13 @@ virDomainSnapshotDiskDefFormat(virBufferPtr buf,
3e5111
     virBufferAddLit(buf, "</disk>\n");
3e5111
 }
3e5111
 
3e5111
-char *virDomainSnapshotDefFormat(const char *domain_uuid,
3e5111
-                                 virDomainSnapshotDefPtr def,
3e5111
-                                 virCapsPtr caps,
3e5111
-                                 unsigned int flags,
3e5111
-                                 int internal)
3e5111
+
3e5111
+char *
3e5111
+virDomainSnapshotDefFormat(const char *domain_uuid,
3e5111
+                           virDomainSnapshotDefPtr def,
3e5111
+                           virCapsPtr caps,
3e5111
+                           unsigned int flags,
3e5111
+                           int internal)
3e5111
 {
3e5111
     virBuffer buf = VIR_BUFFER_INITIALIZER;
3e5111
     size_t i;
3e5111
@@ -702,12 +704,14 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
3e5111
 
3e5111
     virBufferAddLit(&buf, "<domainsnapshot>\n");
3e5111
     virBufferAdjustIndent(&buf, 2);
3e5111
+
3e5111
     virBufferEscapeString(&buf, "<name>%s</name>\n", def->name);
3e5111
     if (def->description)
3e5111
         virBufferEscapeString(&buf, "<description>%s</description>\n",
3e5111
                               def->description);
3e5111
     virBufferAsprintf(&buf, "<state>%s</state>\n",
3e5111
                       virDomainSnapshotStateTypeToString(def->state));
3e5111
+
3e5111
     if (def->parent) {
3e5111
         virBufferAddLit(&buf, "<parent>\n");
3e5111
         virBufferAdjustIndent(&buf, 2);
3e5111
@@ -715,14 +719,17 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
3e5111
         virBufferAdjustIndent(&buf, -2);
3e5111
         virBufferAddLit(&buf, "</parent>\n");
3e5111
     }
3e5111
+
3e5111
     virBufferAsprintf(&buf, "<creationTime>%lld</creationTime>\n",
3e5111
                       def->creationTime);
3e5111
+
3e5111
     if (def->memory) {
3e5111
         virBufferAsprintf(&buf, "
3e5111
                           virDomainSnapshotLocationTypeToString(def->memory));
3e5111
         virBufferEscapeString(&buf, " file='%s'", def->file);
3e5111
         virBufferAddLit(&buf, "/>\n");
3e5111
     }
3e5111
+
3e5111
     if (def->ndisks) {
3e5111
         virBufferAddLit(&buf, "<disks>\n");
3e5111
         virBufferAdjustIndent(&buf, 2);
3e5111
@@ -731,11 +738,10 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
3e5111
         virBufferAdjustIndent(&buf, -2);
3e5111
         virBufferAddLit(&buf, "</disks>\n");
3e5111
     }
3e5111
+
3e5111
     if (def->dom) {
3e5111
-        if (virDomainDefFormatInternal(def->dom, caps, flags, &buf) < 0) {
3e5111
-            virBufferFreeAndReset(&buf;;
3e5111
-            return NULL;
3e5111
-        }
3e5111
+        if (virDomainDefFormatInternal(def->dom, caps, flags, &buf) < 0)
3e5111
+            goto error;
3e5111
     } else if (domain_uuid) {
3e5111
         virBufferAddLit(&buf, "<domain>\n");
3e5111
         virBufferAdjustIndent(&buf, 2);
3e5111
@@ -743,8 +749,10 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
3e5111
         virBufferAdjustIndent(&buf, -2);
3e5111
         virBufferAddLit(&buf, "</domain>\n");
3e5111
     }
3e5111
+
3e5111
     if (internal)
3e5111
         virBufferAsprintf(&buf, "<active>%d</active>\n", def->current);
3e5111
+
3e5111
     virBufferAdjustIndent(&buf, -2);
3e5111
     virBufferAddLit(&buf, "</domainsnapshot>\n");
3e5111
 
3e5111
@@ -752,6 +760,10 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
3e5111
         return NULL;
3e5111
 
3e5111
     return virBufferContentAndReset(&buf;;
3e5111
+
3e5111
+ error:
3e5111
+    virBufferFreeAndReset(&buf;;
3e5111
+    return NULL;
3e5111
 }
3e5111
 
3e5111
 /* Snapshot Obj functions */
3e5111
-- 
3e5111
2.13.1
3e5111