mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
conf: eliminate hardcoded indent in volume/pool xml
Again completely mechanical, but a lot of lines.
This commit is contained in:
parent
f728155f69
commit
5f84543772
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* storage_conf.c: config handling for storage driver
|
* storage_conf.c: config handling for storage driver
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2013 Red Hat, Inc.
|
* Copyright (C) 2006-2014 Red Hat, Inc.
|
||||||
* Copyright (C) 2006-2008 Daniel P. Berrange
|
* Copyright (C) 2006-2008 Daniel P. Berrange
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
@ -1069,6 +1069,8 @@ virStoragePoolSourceFormat(virBufferPtr buf,
|
|||||||
char uuid[VIR_UUID_STRING_BUFLEN];
|
char uuid[VIR_UUID_STRING_BUFLEN];
|
||||||
|
|
||||||
virBufferAddLit(buf, "<source>\n");
|
virBufferAddLit(buf, "<source>\n");
|
||||||
|
virBufferAdjustIndent(buf, 2);
|
||||||
|
|
||||||
if ((options->flags & VIR_STORAGE_POOL_SOURCE_HOST) && src->nhost) {
|
if ((options->flags & VIR_STORAGE_POOL_SOURCE_HOST) && src->nhost) {
|
||||||
for (i = 0; i < src->nhost; i++) {
|
for (i = 0; i < src->nhost; i++) {
|
||||||
virBufferEscapeString(buf, "<host name='%s'",
|
virBufferEscapeString(buf, "<host name='%s'",
|
||||||
@ -1085,11 +1087,13 @@ virStoragePoolSourceFormat(virBufferPtr buf,
|
|||||||
if (src->devices[i].nfreeExtent) {
|
if (src->devices[i].nfreeExtent) {
|
||||||
virBufferEscapeString(buf, "<device path='%s'>\n",
|
virBufferEscapeString(buf, "<device path='%s'>\n",
|
||||||
src->devices[i].path);
|
src->devices[i].path);
|
||||||
|
virBufferAdjustIndent(buf, 2);
|
||||||
for (j = 0; j < src->devices[i].nfreeExtent; j++) {
|
for (j = 0; j < src->devices[i].nfreeExtent; j++) {
|
||||||
virBufferAsprintf(buf, "<freeExtent start='%llu' end='%llu'/>\n",
|
virBufferAsprintf(buf, "<freeExtent start='%llu' end='%llu'/>\n",
|
||||||
src->devices[i].freeExtents[j].start,
|
src->devices[i].freeExtents[j].start,
|
||||||
src->devices[i].freeExtents[j].end);
|
src->devices[i].freeExtents[j].end);
|
||||||
}
|
}
|
||||||
|
virBufferAdjustIndent(buf, -2);
|
||||||
virBufferAddLit(buf, "</device>\n");
|
virBufferAddLit(buf, "</device>\n");
|
||||||
} else {
|
} else {
|
||||||
virBufferEscapeString(buf, "<device path='%s'/>\n",
|
virBufferEscapeString(buf, "<device path='%s'/>\n",
|
||||||
@ -1125,8 +1129,10 @@ virStoragePoolSourceFormat(virBufferPtr buf,
|
|||||||
if ((options->flags & VIR_STORAGE_POOL_SOURCE_INITIATOR_IQN) &&
|
if ((options->flags & VIR_STORAGE_POOL_SOURCE_INITIATOR_IQN) &&
|
||||||
src->initiator.iqn) {
|
src->initiator.iqn) {
|
||||||
virBufferAddLit(buf, "<initiator>\n");
|
virBufferAddLit(buf, "<initiator>\n");
|
||||||
|
virBufferAdjustIndent(buf, 2);
|
||||||
virBufferEscapeString(buf, "<iqn name='%s'/>\n",
|
virBufferEscapeString(buf, "<iqn name='%s'/>\n",
|
||||||
src->initiator.iqn);
|
src->initiator.iqn);
|
||||||
|
virBufferAdjustIndent(buf, -2);
|
||||||
virBufferAddLit(buf, "</initiator>\n");
|
virBufferAddLit(buf, "</initiator>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1149,6 +1155,7 @@ virStoragePoolSourceFormat(virBufferPtr buf,
|
|||||||
(src->authType == VIR_STORAGE_POOL_AUTH_CHAP ?
|
(src->authType == VIR_STORAGE_POOL_AUTH_CHAP ?
|
||||||
src->auth.chap.username :
|
src->auth.chap.username :
|
||||||
src->auth.cephx.username));
|
src->auth.cephx.username));
|
||||||
|
virBufferAdjustIndent(buf, 2);
|
||||||
|
|
||||||
virBufferAddLit(buf, "<secret");
|
virBufferAddLit(buf, "<secret");
|
||||||
if (src->auth.cephx.secret.uuidUsable) {
|
if (src->auth.cephx.secret.uuidUsable) {
|
||||||
@ -1161,14 +1168,15 @@ virStoragePoolSourceFormat(virBufferPtr buf,
|
|||||||
}
|
}
|
||||||
virBufferAddLit(buf, "/>\n");
|
virBufferAddLit(buf, "/>\n");
|
||||||
|
|
||||||
|
virBufferAdjustIndent(buf, -2);
|
||||||
virBufferAddLit(buf, "</auth>\n");
|
virBufferAddLit(buf, "</auth>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
virBufferEscapeString(buf, "<vendor name='%s'/>\n", src->vendor);
|
virBufferEscapeString(buf, "<vendor name='%s'/>\n", src->vendor);
|
||||||
virBufferEscapeString(buf, "<product name='%s'/>\n", src->product);
|
virBufferEscapeString(buf, "<product name='%s'/>\n", src->product);
|
||||||
|
|
||||||
|
virBufferAdjustIndent(buf, -2);
|
||||||
virBufferAddLit(buf, "</source>\n");
|
virBufferAddLit(buf, "</source>\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1192,6 +1200,7 @@ virStoragePoolDefFormat(virStoragePoolDefPtr def)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
virBufferAsprintf(&buf, "<pool type='%s'>\n", type);
|
virBufferAsprintf(&buf, "<pool type='%s'>\n", type);
|
||||||
|
virBufferAdjustIndent(&buf, 2);
|
||||||
virBufferEscapeString(&buf, "<name>%s</name>\n", def->name);
|
virBufferEscapeString(&buf, "<name>%s</name>\n", def->name);
|
||||||
|
|
||||||
virUUIDFormat(def->uuid, uuid);
|
virUUIDFormat(def->uuid, uuid);
|
||||||
@ -1213,10 +1222,12 @@ virStoragePoolDefFormat(virStoragePoolDefPtr def)
|
|||||||
def->type != VIR_STORAGE_POOL_SHEEPDOG &&
|
def->type != VIR_STORAGE_POOL_SHEEPDOG &&
|
||||||
def->type != VIR_STORAGE_POOL_GLUSTER) {
|
def->type != VIR_STORAGE_POOL_GLUSTER) {
|
||||||
virBufferAddLit(&buf, "<target>\n");
|
virBufferAddLit(&buf, "<target>\n");
|
||||||
|
virBufferAdjustIndent(&buf, 2);
|
||||||
|
|
||||||
virBufferEscapeString(&buf, "<path>%s</path>\n", def->target.path);
|
virBufferEscapeString(&buf, "<path>%s</path>\n", def->target.path);
|
||||||
|
|
||||||
virBufferAddLit(&buf, "<permissions>\n");
|
virBufferAddLit(&buf, "<permissions>\n");
|
||||||
|
virBufferAdjustIndent(&buf, 2);
|
||||||
virBufferAsprintf(&buf, "<mode>0%o</mode>\n",
|
virBufferAsprintf(&buf, "<mode>0%o</mode>\n",
|
||||||
def->target.perms.mode);
|
def->target.perms.mode);
|
||||||
virBufferAsprintf(&buf, "<owner>%d</owner>\n",
|
virBufferAsprintf(&buf, "<owner>%d</owner>\n",
|
||||||
@ -1227,9 +1238,12 @@ virStoragePoolDefFormat(virStoragePoolDefPtr def)
|
|||||||
virBufferEscapeString(&buf, "<label>%s</label>\n",
|
virBufferEscapeString(&buf, "<label>%s</label>\n",
|
||||||
def->target.perms.label);
|
def->target.perms.label);
|
||||||
|
|
||||||
|
virBufferAdjustIndent(&buf, -2);
|
||||||
virBufferAddLit(&buf, "</permissions>\n");
|
virBufferAddLit(&buf, "</permissions>\n");
|
||||||
|
virBufferAdjustIndent(&buf, -2);
|
||||||
virBufferAddLit(&buf, "</target>\n");
|
virBufferAddLit(&buf, "</target>\n");
|
||||||
}
|
}
|
||||||
|
virBufferAdjustIndent(&buf, -2);
|
||||||
virBufferAddLit(&buf, "</pool>\n");
|
virBufferAddLit(&buf, "</pool>\n");
|
||||||
|
|
||||||
if (virBufferError(&buf))
|
if (virBufferError(&buf))
|
||||||
@ -1509,6 +1523,7 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
|
|||||||
const char *type)
|
const char *type)
|
||||||
{
|
{
|
||||||
virBufferAsprintf(buf, "<%s>\n", type);
|
virBufferAsprintf(buf, "<%s>\n", type);
|
||||||
|
virBufferAdjustIndent(buf, 2);
|
||||||
|
|
||||||
virBufferEscapeString(buf, "<path>%s</path>\n", def->path);
|
virBufferEscapeString(buf, "<path>%s</path>\n", def->path);
|
||||||
|
|
||||||
@ -1524,6 +1539,8 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
|
|||||||
}
|
}
|
||||||
|
|
||||||
virBufferAddLit(buf, "<permissions>\n");
|
virBufferAddLit(buf, "<permissions>\n");
|
||||||
|
virBufferAdjustIndent(buf, 2);
|
||||||
|
|
||||||
virBufferAsprintf(buf, "<mode>0%o</mode>\n",
|
virBufferAsprintf(buf, "<mode>0%o</mode>\n",
|
||||||
def->perms.mode);
|
def->perms.mode);
|
||||||
virBufferAsprintf(buf, "<owner>%u</owner>\n",
|
virBufferAsprintf(buf, "<owner>%u</owner>\n",
|
||||||
@ -1535,23 +1552,23 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
|
|||||||
virBufferEscapeString(buf, "<label>%s</label>\n",
|
virBufferEscapeString(buf, "<label>%s</label>\n",
|
||||||
def->perms.label);
|
def->perms.label);
|
||||||
|
|
||||||
|
virBufferAdjustIndent(buf, -2);
|
||||||
virBufferAddLit(buf, "</permissions>\n");
|
virBufferAddLit(buf, "</permissions>\n");
|
||||||
|
|
||||||
if (def->timestamps) {
|
if (def->timestamps) {
|
||||||
virBufferAddLit(buf, "<timestamps>\n");
|
virBufferAddLit(buf, "<timestamps>\n");
|
||||||
|
virBufferAdjustIndent(buf, 2);
|
||||||
virStorageVolTimestampFormat(buf, "atime", &def->timestamps->atime);
|
virStorageVolTimestampFormat(buf, "atime", &def->timestamps->atime);
|
||||||
virStorageVolTimestampFormat(buf, "mtime", &def->timestamps->mtime);
|
virStorageVolTimestampFormat(buf, "mtime", &def->timestamps->mtime);
|
||||||
virStorageVolTimestampFormat(buf, "ctime", &def->timestamps->ctime);
|
virStorageVolTimestampFormat(buf, "ctime", &def->timestamps->ctime);
|
||||||
virStorageVolTimestampFormat(buf, "btime", &def->timestamps->btime);
|
virStorageVolTimestampFormat(buf, "btime", &def->timestamps->btime);
|
||||||
|
virBufferAdjustIndent(buf, -2);
|
||||||
virBufferAddLit(buf, "</timestamps>\n");
|
virBufferAddLit(buf, "</timestamps>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (def->encryption) {
|
if (def->encryption &&
|
||||||
virBufferAdjustIndent(buf, 4);
|
virStorageEncryptionFormat(buf, def->encryption) < 0)
|
||||||
if (virStorageEncryptionFormat(buf, def->encryption) < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
virBufferAdjustIndent(buf, -4);
|
|
||||||
}
|
|
||||||
|
|
||||||
virBufferEscapeString(buf, "<compat>%s</compat>\n", def->compat);
|
virBufferEscapeString(buf, "<compat>%s</compat>\n", def->compat);
|
||||||
|
|
||||||
@ -1560,10 +1577,12 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
|
|||||||
bool b;
|
bool b;
|
||||||
bool empty = virBitmapIsAllClear(def->features);
|
bool empty = virBitmapIsAllClear(def->features);
|
||||||
|
|
||||||
if (empty)
|
if (empty) {
|
||||||
virBufferAddLit(buf, "<features/>\n");
|
virBufferAddLit(buf, "<features/>\n");
|
||||||
else
|
} else {
|
||||||
virBufferAddLit(buf, "<features>\n");
|
virBufferAddLit(buf, "<features>\n");
|
||||||
|
virBufferAdjustIndent(buf, 2);
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < VIR_STORAGE_FILE_FEATURE_LAST; i++) {
|
for (i = 0; i < VIR_STORAGE_FILE_FEATURE_LAST; i++) {
|
||||||
ignore_value(virBitmapGetBit(def->features, i, &b));
|
ignore_value(virBitmapGetBit(def->features, i, &b));
|
||||||
@ -1571,12 +1590,14 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
|
|||||||
virBufferAsprintf(buf, "<%s/>\n",
|
virBufferAsprintf(buf, "<%s/>\n",
|
||||||
options->featureToString(i));
|
options->featureToString(i));
|
||||||
}
|
}
|
||||||
if (!empty)
|
if (!empty) {
|
||||||
|
virBufferAdjustIndent(buf, -2);
|
||||||
virBufferAddLit(buf, "</features>\n");
|
virBufferAddLit(buf, "</features>\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virBufferAdjustIndent(buf, -2);
|
||||||
virBufferAsprintf(buf, "</%s>\n", type);
|
virBufferAsprintf(buf, "</%s>\n", type);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1593,9 +1614,12 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
|
|||||||
|
|
||||||
virBufferAsprintf(&buf, "<volume type='%s'>\n",
|
virBufferAsprintf(&buf, "<volume type='%s'>\n",
|
||||||
virStorageVolTypeToString(def->type));
|
virStorageVolTypeToString(def->type));
|
||||||
|
virBufferAdjustIndent(&buf, 2);
|
||||||
|
|
||||||
virBufferEscapeString(&buf, "<name>%s</name>\n", def->name);
|
virBufferEscapeString(&buf, "<name>%s</name>\n", def->name);
|
||||||
virBufferEscapeString(&buf, "<key>%s</key>\n", def->key);
|
virBufferEscapeString(&buf, "<key>%s</key>\n", def->key);
|
||||||
virBufferAddLit(&buf, "<source>\n");
|
virBufferAddLit(&buf, "<source>\n");
|
||||||
|
virBufferAdjustIndent(&buf, 2);
|
||||||
|
|
||||||
if (def->source.nextent) {
|
if (def->source.nextent) {
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -1610,15 +1634,18 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
|
|||||||
def->source.extents[i].path);
|
def->source.extents[i].path);
|
||||||
}
|
}
|
||||||
|
|
||||||
virBufferAsprintf(&buf,
|
virBufferAdjustIndent(&buf, 2);
|
||||||
" <extent start='%llu' end='%llu'/>\n",
|
virBufferAsprintf(&buf, "<extent start='%llu' end='%llu'/>\n",
|
||||||
def->source.extents[i].start,
|
def->source.extents[i].start,
|
||||||
def->source.extents[i].end);
|
def->source.extents[i].end);
|
||||||
|
virBufferAdjustIndent(&buf, -2);
|
||||||
thispath = def->source.extents[i].path;
|
thispath = def->source.extents[i].path;
|
||||||
}
|
}
|
||||||
if (thispath != NULL)
|
if (thispath != NULL)
|
||||||
virBufferAddLit(&buf, "</device>\n");
|
virBufferAddLit(&buf, "</device>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virBufferAdjustIndent(&buf, -2);
|
||||||
virBufferAddLit(&buf, "</source>\n");
|
virBufferAddLit(&buf, "</source>\n");
|
||||||
|
|
||||||
virBufferAsprintf(&buf, "<capacity unit='bytes'>%llu</capacity>\n",
|
virBufferAsprintf(&buf, "<capacity unit='bytes'>%llu</capacity>\n",
|
||||||
@ -1635,6 +1662,7 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
|
|||||||
&def->backingStore, "backingStore") < 0)
|
&def->backingStore, "backingStore") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
virBufferAdjustIndent(&buf, -2);
|
||||||
virBufferAddLit(&buf, "</volume>\n");
|
virBufferAddLit(&buf, "</volume>\n");
|
||||||
|
|
||||||
if (virBufferError(&buf))
|
if (virBufferError(&buf))
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* storage_encryption_conf.c: volume encryption information
|
* storage_encryption_conf.c: volume encryption information
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009-2011 Red Hat, Inc.
|
* Copyright (C) 2009-2014 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
|
||||||
@ -237,12 +237,14 @@ virStorageEncryptionFormat(virBufferPtr buf,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
virBufferAsprintf(buf, "<encryption format='%s'>\n", format);
|
virBufferAsprintf(buf, "<encryption format='%s'>\n", format);
|
||||||
|
virBufferAdjustIndent(buf, 2);
|
||||||
|
|
||||||
for (i = 0; i < enc->nsecrets; i++) {
|
for (i = 0; i < enc->nsecrets; i++) {
|
||||||
if (virStorageEncryptionSecretFormat(buf, enc->secrets[i]) < 0)
|
if (virStorageEncryptionSecretFormat(buf, enc->secrets[i]) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virBufferAdjustIndent(buf, -2);
|
||||||
virBufferAddLit(buf, "</encryption>\n");
|
virBufferAddLit(buf, "</encryption>\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user