* virDomainDiskSourceFormat:
* @buf: output buffer
* @src: storage source definition to format
+ * @element: name to use for the top-level element (often "source")
* @policy: startup policy attribute value, if necessary
* @attrIndex: the 'index' attribute of <source> is formatted if true
* @flags: XML formatter flags
int
virDomainDiskSourceFormat(virBufferPtr buf,
virStorageSourcePtr src,
+ const char *element,
int policy,
bool attrIndex,
unsigned int flags,
if (virDomainDiskSourceFormatPrivateData(&childBuf, src, flags, xmlopt) < 0)
return -1;
- if (virXMLFormatElement(buf, "source", &attrBuf, &childBuf) < 0)
+ if (virXMLFormatElement(buf, element, &attrBuf, &childBuf) < 0)
return -1;
return 0;
virBufferAsprintf(&childBuf, "<format type='%s'/>\n",
virStorageFileFormatTypeToString(backingStore->format));
- if (virDomainDiskSourceFormat(&childBuf, backingStore, 0, false, flags, xmlopt) < 0)
+ if (virDomainDiskSourceFormat(&childBuf, backingStore, "source", 0, false,
+ flags, xmlopt) < 0)
return -1;
if (virDomainDiskBackingStoreFormat(&childBuf, backingStore, xmlopt, flags) < 0)
virDomainDiskMirrorStateTypeToString(disk->mirrorState));
virBufferEscapeString(&childBuf, "<format type='%s'/>\n", formatStr);
- if (virDomainDiskSourceFormat(&childBuf, disk->mirror, 0, true, flags, xmlopt) < 0)
+ if (virDomainDiskSourceFormat(&childBuf, disk->mirror, "source", 0, true,
+ flags, xmlopt) < 0)
return -1;
if (virDomainDiskBackingStoreFormat(&childBuf, disk->mirror, xmlopt, flags) < 0)
if (def->src->auth && !def->src->authInherited)
virStorageAuthDefFormat(buf, def->src->auth);
- if (virDomainDiskSourceFormat(buf, def->src, def->startupPolicy, true,
- flags, xmlopt) < 0)
+ if (virDomainDiskSourceFormat(buf, def->src, "source", def->startupPolicy,
+ true, flags, xmlopt) < 0)
return -1;
/* Don't format backingStore to inactive XMLs until the code for
if (disk->src->format > 0)
virBufferEscapeString(buf, "<driver type='%s'/>\n",
virStorageFileFormatTypeToString(disk->src->format));
- if (virDomainDiskSourceFormat(buf, disk->src, 0, false, 0, xmlopt) < 0)
+ if (virDomainDiskSourceFormat(buf, disk->src, "source", 0, false, 0,
+ xmlopt) < 0)
return -1;
virBufferAdjustIndent(buf, -2);
virStorageTypeToString(src->type),
virStorageFileFormatTypeToString(src->format));
- if (virDomainDiskSourceFormat(&childBuf, src, 0, false,
+ if (virDomainDiskSourceFormat(&childBuf, src, "source", 0, false,
VIR_DOMAIN_DEF_FORMAT_STATUS, xmlopt) < 0)
goto cleanup;