]> xenbits.xensource.com Git - libvirt.git/commitdiff
snapshot: simplify indentation of disk encryption xml
authorEric Blake <eblake@redhat.com>
Thu, 22 Sep 2011 18:16:26 +0000 (12:16 -0600)
committerEric Blake <eblake@redhat.com>
Wed, 26 Oct 2011 17:14:43 +0000 (11:14 -0600)
Use auto-indent in more places.

* src/conf/storage_encryption_conf.h (virStorageEncryptionFormat):
Drop parameter.
* src/conf/storage_encryption_conf.c (virStorageEncryptionFormat)
(virStorageEncryptionSecretFormat): Simplify with auto-indent.
* src/conf/domain_conf.c (virDomainDiskDefFormat): Adjust caller.
* src/conf/storage_conf.c (virStorageVolTargetDefFormat): Likewise.

src/conf/domain_conf.c
src/conf/storage_conf.c
src/conf/storage_encryption_conf.c
src/conf/storage_encryption_conf.h

index ff737ecda93aee4fed35099b63799034753d88b0..6b942620834d337c6895c396bbbb310cab79b4e4 100644 (file)
@@ -9328,9 +9328,12 @@ virDomainDiskDefFormat(virBufferPtr buf,
     if (def->serial)
         virBufferEscapeString(buf, "      <serial>%s</serial>\n",
                               def->serial);
-    if (def->encryption != NULL &&
-        virStorageEncryptionFormat(buf, def->encryption, 6) < 0)
-        return -1;
+    if (def->encryption) {
+        virBufferAdjustIndent(buf, 6);
+        if (virStorageEncryptionFormat(buf, def->encryption) < 0)
+            return -1;
+        virBufferAdjustIndent(buf, -6);
+    }
 
     if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
         return -1;
index 4f4f5cea4e235f56f34244370258ee2826480edd..55205d40a2390431dcaae8991b4b1a193565f5ac 100644 (file)
@@ -1211,9 +1211,12 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
 
     virBufferAddLit(buf,"    </permissions>\n");
 
-    if (def->encryption != NULL &&
-        virStorageEncryptionFormat(buf, def->encryption, 4) < 0)
-        return -1;
+    if (def->encryption) {
+        virBufferAdjustIndent(buf, 4);
+        if (virStorageEncryptionFormat(buf, def->encryption) < 0)
+            return -1;
+        virBufferAdjustIndent(buf, -4);
+    }
 
     virBufferAsprintf(buf, "  </%s>\n", type);
 
index 73e16ed2881a74ce7d2375e12f2676991da7e013..32083339c8b29ca12ab797cdace899a87a51d832 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * storage_encryption_conf.c: volume encryption information
  *
- * Copyright (C) 2009-2010 Red Hat, Inc.
+ * Copyright (C) 2009-2011 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -211,8 +211,7 @@ virStorageEncryptionParseNode(xmlDocPtr xml, xmlNodePtr root)
 
 static int
 virStorageEncryptionSecretFormat(virBufferPtr buf,
-                                 virStorageEncryptionSecretPtr secret,
-                                 int indent)
+                                 virStorageEncryptionSecretPtr secret)
 {
     const char *type;
     char uuidstr[VIR_UUID_STRING_BUFLEN];
@@ -225,15 +224,14 @@ virStorageEncryptionSecretFormat(virBufferPtr buf,
     }
 
     virUUIDFormat(secret->uuid, uuidstr);
-    virBufferAsprintf(buf, "%*s<secret type='%s' uuid='%s'/>\n",
-                      indent, "", type, uuidstr);
+    virBufferAsprintf(buf, "  <secret type='%s' uuid='%s'/>\n",
+                      type, uuidstr);
     return 0;
 }
 
 int
 virStorageEncryptionFormat(virBufferPtr buf,
-                           virStorageEncryptionPtr enc,
-                           int indent)
+                           virStorageEncryptionPtr enc)
 {
     const char *format;
     size_t i;
@@ -244,16 +242,14 @@ virStorageEncryptionFormat(virBufferPtr buf,
                               "%s", _("unexpected encryption format"));
         return -1;
     }
-    virBufferAsprintf(buf, "%*s<encryption format='%s'>\n",
-                      indent, "", format);
+    virBufferAsprintf(buf, "<encryption format='%s'>\n", format);
 
     for (i = 0; i < enc->nsecrets; i++) {
-        if (virStorageEncryptionSecretFormat(buf, enc->secrets[i],
-                                             indent + 2) < 0)
+        if (virStorageEncryptionSecretFormat(buf, enc->secrets[i]) < 0)
             return -1;
     }
 
-    virBufferAsprintf(buf, "%*s</encryption>\n", indent, "");
+    virBufferAddLit(buf, "</encryption>\n");
 
     return 0;
 }
index fa5f3cbf0a7529c951393eba2d5ac51b8f573c4e..cfb088c75f354bb384ef90d3e90d1ccd7b85c0bd 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * storage_encryption_conf.h: volume encryption information
  *
- * Copyright (C) 2009-2010 Red Hat, Inc.
+ * Copyright (C) 2009-2011 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -66,8 +66,7 @@ void virStorageEncryptionFree(virStorageEncryptionPtr enc);
 virStorageEncryptionPtr virStorageEncryptionParseNode(xmlDocPtr xml,
                                                       xmlNodePtr root);
 int virStorageEncryptionFormat(virBufferPtr buf,
-                               virStorageEncryptionPtr enc,
-                               int indent);
+                               virStorageEncryptionPtr enc);
 
 /* A helper for VIR_STORAGE_ENCRYPTION_FORMAT_QCOW */
 enum {