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.
This commit is contained in:
Eric Blake
2011-09-22 12:16:26 -06:00
parent 46e1a426f9
commit 4d8e20f6c2
4 changed files with 22 additions and 21 deletions

View 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;

View 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);

View 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;
}

View 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 {