mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
conf: use virXMLFormatElement in virDomainDiskDefFormatMirror
Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
670053326b
commit
86855f761f
@ -24007,8 +24007,12 @@ virDomainDiskDefFormatMirror(virBufferPtr buf,
|
|||||||
unsigned int flags,
|
unsigned int flags,
|
||||||
virDomainXMLOptionPtr xmlopt)
|
virDomainXMLOptionPtr xmlopt)
|
||||||
{
|
{
|
||||||
|
VIR_AUTOCLEAN(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
|
||||||
|
VIR_AUTOCLEAN(virBuffer) childBuf = VIR_BUFFER_INITIALIZER;
|
||||||
const char *formatStr = NULL;
|
const char *formatStr = NULL;
|
||||||
|
|
||||||
|
virBufferSetChildIndent(&childBuf, buf);
|
||||||
|
|
||||||
/* For now, mirroring is currently output-only: we only output it
|
/* For now, mirroring is currently output-only: we only output it
|
||||||
* for live domains, therefore we ignore it on input except for
|
* for live domains, therefore we ignore it on input except for
|
||||||
* the internal parse on libvirtd restart. We prefer to output
|
* the internal parse on libvirtd restart. We prefer to output
|
||||||
@ -24022,28 +24026,25 @@ virDomainDiskDefFormatMirror(virBufferPtr buf,
|
|||||||
|
|
||||||
if (disk->mirror->format)
|
if (disk->mirror->format)
|
||||||
formatStr = virStorageFileFormatTypeToString(disk->mirror->format);
|
formatStr = virStorageFileFormatTypeToString(disk->mirror->format);
|
||||||
virBufferAsprintf(buf, "<mirror type='%s'",
|
virBufferAsprintf(&attrBuf, " type='%s'",
|
||||||
virStorageTypeToString(disk->mirror->type));
|
virStorageTypeToString(disk->mirror->type));
|
||||||
if (disk->mirror->type == VIR_STORAGE_TYPE_FILE &&
|
if (disk->mirror->type == VIR_STORAGE_TYPE_FILE &&
|
||||||
disk->mirrorJob == VIR_DOMAIN_BLOCK_JOB_TYPE_COPY) {
|
disk->mirrorJob == VIR_DOMAIN_BLOCK_JOB_TYPE_COPY) {
|
||||||
virBufferEscapeString(buf, " file='%s'", disk->mirror->path);
|
virBufferEscapeString(&attrBuf, " file='%s'", disk->mirror->path);
|
||||||
virBufferEscapeString(buf, " format='%s'", formatStr);
|
virBufferEscapeString(&attrBuf, " format='%s'", formatStr);
|
||||||
}
|
}
|
||||||
virBufferEscapeString(buf, " job='%s'",
|
virBufferEscapeString(&attrBuf, " job='%s'",
|
||||||
virDomainBlockJobTypeToString(disk->mirrorJob));
|
virDomainBlockJobTypeToString(disk->mirrorJob));
|
||||||
if (disk->mirrorState) {
|
if (disk->mirrorState)
|
||||||
const char *mirror;
|
virBufferEscapeString(&attrBuf, " ready='%s'",
|
||||||
|
virDomainDiskMirrorStateTypeToString(disk->mirrorState));
|
||||||
|
|
||||||
mirror = virDomainDiskMirrorStateTypeToString(disk->mirrorState);
|
virBufferEscapeString(&childBuf, "<format type='%s'/>\n", formatStr);
|
||||||
virBufferEscapeString(buf, " ready='%s'", mirror);
|
if (virDomainDiskSourceFormat(&childBuf, disk->mirror, 0, false, 0, xmlopt) < 0)
|
||||||
}
|
return -1;
|
||||||
virBufferAddLit(buf, ">\n");
|
|
||||||
virBufferAdjustIndent(buf, 2);
|
if (virXMLFormatElement(buf, "mirror", &attrBuf, &childBuf) < 0)
|
||||||
virBufferEscapeString(buf, "<format type='%s'/>\n", formatStr);
|
|
||||||
if (virDomainDiskSourceFormat(buf, disk->mirror, 0, false, 0, xmlopt) < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
virBufferAdjustIndent(buf, -2);
|
|
||||||
virBufferAddLit(buf, "</mirror>\n");
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user