mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
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:
@@ -9328,9 +9328,12 @@ virDomainDiskDefFormat(virBufferPtr buf,
|
|||||||
if (def->serial)
|
if (def->serial)
|
||||||
virBufferEscapeString(buf, " <serial>%s</serial>\n",
|
virBufferEscapeString(buf, " <serial>%s</serial>\n",
|
||||||
def->serial);
|
def->serial);
|
||||||
if (def->encryption != NULL &&
|
if (def->encryption) {
|
||||||
virStorageEncryptionFormat(buf, def->encryption, 6) < 0)
|
virBufferAdjustIndent(buf, 6);
|
||||||
return -1;
|
if (virStorageEncryptionFormat(buf, def->encryption) < 0)
|
||||||
|
return -1;
|
||||||
|
virBufferAdjustIndent(buf, -6);
|
||||||
|
}
|
||||||
|
|
||||||
if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
|
if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -1211,9 +1211,12 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
|
|||||||
|
|
||||||
virBufferAddLit(buf," </permissions>\n");
|
virBufferAddLit(buf," </permissions>\n");
|
||||||
|
|
||||||
if (def->encryption != NULL &&
|
if (def->encryption) {
|
||||||
virStorageEncryptionFormat(buf, def->encryption, 4) < 0)
|
virBufferAdjustIndent(buf, 4);
|
||||||
return -1;
|
if (virStorageEncryptionFormat(buf, def->encryption) < 0)
|
||||||
|
return -1;
|
||||||
|
virBufferAdjustIndent(buf, -4);
|
||||||
|
}
|
||||||
|
|
||||||
virBufferAsprintf(buf, " </%s>\n", type);
|
virBufferAsprintf(buf, " </%s>\n", type);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* storage_encryption_conf.c: volume encryption information
|
* 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
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@@ -211,8 +211,7 @@ virStorageEncryptionParseNode(xmlDocPtr xml, xmlNodePtr root)
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
virStorageEncryptionSecretFormat(virBufferPtr buf,
|
virStorageEncryptionSecretFormat(virBufferPtr buf,
|
||||||
virStorageEncryptionSecretPtr secret,
|
virStorageEncryptionSecretPtr secret)
|
||||||
int indent)
|
|
||||||
{
|
{
|
||||||
const char *type;
|
const char *type;
|
||||||
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
char uuidstr[VIR_UUID_STRING_BUFLEN];
|
||||||
@@ -225,15 +224,14 @@ virStorageEncryptionSecretFormat(virBufferPtr buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
virUUIDFormat(secret->uuid, uuidstr);
|
virUUIDFormat(secret->uuid, uuidstr);
|
||||||
virBufferAsprintf(buf, "%*s<secret type='%s' uuid='%s'/>\n",
|
virBufferAsprintf(buf, " <secret type='%s' uuid='%s'/>\n",
|
||||||
indent, "", type, uuidstr);
|
type, uuidstr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
virStorageEncryptionFormat(virBufferPtr buf,
|
virStorageEncryptionFormat(virBufferPtr buf,
|
||||||
virStorageEncryptionPtr enc,
|
virStorageEncryptionPtr enc)
|
||||||
int indent)
|
|
||||||
{
|
{
|
||||||
const char *format;
|
const char *format;
|
||||||
size_t i;
|
size_t i;
|
||||||
@@ -244,16 +242,14 @@ virStorageEncryptionFormat(virBufferPtr buf,
|
|||||||
"%s", _("unexpected encryption format"));
|
"%s", _("unexpected encryption format"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
virBufferAsprintf(buf, "%*s<encryption format='%s'>\n",
|
virBufferAsprintf(buf, "<encryption format='%s'>\n", format);
|
||||||
indent, "", format);
|
|
||||||
|
|
||||||
for (i = 0; i < enc->nsecrets; i++) {
|
for (i = 0; i < enc->nsecrets; i++) {
|
||||||
if (virStorageEncryptionSecretFormat(buf, enc->secrets[i],
|
if (virStorageEncryptionSecretFormat(buf, enc->secrets[i]) < 0)
|
||||||
indent + 2) < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
virBufferAsprintf(buf, "%*s</encryption>\n", indent, "");
|
virBufferAddLit(buf, "</encryption>\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* storage_encryption_conf.h: volume encryption information
|
* 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
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@@ -66,8 +66,7 @@ void virStorageEncryptionFree(virStorageEncryptionPtr enc);
|
|||||||
virStorageEncryptionPtr virStorageEncryptionParseNode(xmlDocPtr xml,
|
virStorageEncryptionPtr virStorageEncryptionParseNode(xmlDocPtr xml,
|
||||||
xmlNodePtr root);
|
xmlNodePtr root);
|
||||||
int virStorageEncryptionFormat(virBufferPtr buf,
|
int virStorageEncryptionFormat(virBufferPtr buf,
|
||||||
virStorageEncryptionPtr enc,
|
virStorageEncryptionPtr enc);
|
||||||
int indent);
|
|
||||||
|
|
||||||
/* A helper for VIR_STORAGE_ENCRYPTION_FORMAT_QCOW */
|
/* A helper for VIR_STORAGE_ENCRYPTION_FORMAT_QCOW */
|
||||||
enum {
|
enum {
|
||||||
|
|||||||
Reference in New Issue
Block a user