From: Eric Blake Date: Thu, 22 Sep 2011 18:16:26 +0000 (-0600) Subject: snapshot: simplify indentation of disk encryption xml X-Git-Tag: v0.9.7-rc1~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4d8e20f6c20827d4900bf785e6f0b77ce759e5eb;p=thirdparty%2Flibvirt.git snapshot: simplify indentation of disk encryption xml 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. --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ff737ecda9..6b94262083 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -9328,9 +9328,12 @@ virDomainDiskDefFormat(virBufferPtr buf, if (def->serial) virBufferEscapeString(buf, " %s\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; diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 4f4f5cea4e..55205d40a2 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -1211,9 +1211,12 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options, virBufferAddLit(buf," \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, " \n", type); diff --git a/src/conf/storage_encryption_conf.c b/src/conf/storage_encryption_conf.c index 73e16ed288..32083339c8 100644 --- a/src/conf/storage_encryption_conf.c +++ b/src/conf/storage_encryption_conf.c @@ -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\n", - indent, "", type, uuidstr); + virBufferAsprintf(buf, " \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\n", - indent, "", format); + virBufferAsprintf(buf, "\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\n", indent, ""); + virBufferAddLit(buf, "\n"); return 0; } diff --git a/src/conf/storage_encryption_conf.h b/src/conf/storage_encryption_conf.h index fa5f3cbf0a..cfb088c75f 100644 --- a/src/conf/storage_encryption_conf.h +++ b/src/conf/storage_encryption_conf.h @@ -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 {