mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
conf: Make virDomainSnapshotDefFormat easier to read
Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
702013f3b3
commit
00968dca96
@ -686,7 +686,9 @@ virDomainSnapshotDiskDefFormat(virBufferPtr buf,
|
||||
virBufferAddLit(buf, "</disk>\n");
|
||||
}
|
||||
|
||||
char *virDomainSnapshotDefFormat(const char *domain_uuid,
|
||||
|
||||
char *
|
||||
virDomainSnapshotDefFormat(const char *domain_uuid,
|
||||
virDomainSnapshotDefPtr def,
|
||||
virCapsPtr caps,
|
||||
unsigned int flags,
|
||||
@ -702,12 +704,14 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
|
||||
|
||||
virBufferAddLit(&buf, "<domainsnapshot>\n");
|
||||
virBufferAdjustIndent(&buf, 2);
|
||||
|
||||
virBufferEscapeString(&buf, "<name>%s</name>\n", def->name);
|
||||
if (def->description)
|
||||
virBufferEscapeString(&buf, "<description>%s</description>\n",
|
||||
def->description);
|
||||
virBufferAsprintf(&buf, "<state>%s</state>\n",
|
||||
virDomainSnapshotStateTypeToString(def->state));
|
||||
|
||||
if (def->parent) {
|
||||
virBufferAddLit(&buf, "<parent>\n");
|
||||
virBufferAdjustIndent(&buf, 2);
|
||||
@ -715,14 +719,17 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
|
||||
virBufferAdjustIndent(&buf, -2);
|
||||
virBufferAddLit(&buf, "</parent>\n");
|
||||
}
|
||||
|
||||
virBufferAsprintf(&buf, "<creationTime>%lld</creationTime>\n",
|
||||
def->creationTime);
|
||||
|
||||
if (def->memory) {
|
||||
virBufferAsprintf(&buf, "<memory snapshot='%s'",
|
||||
virDomainSnapshotLocationTypeToString(def->memory));
|
||||
virBufferEscapeString(&buf, " file='%s'", def->file);
|
||||
virBufferAddLit(&buf, "/>\n");
|
||||
}
|
||||
|
||||
if (def->ndisks) {
|
||||
virBufferAddLit(&buf, "<disks>\n");
|
||||
virBufferAdjustIndent(&buf, 2);
|
||||
@ -731,11 +738,10 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
|
||||
virBufferAdjustIndent(&buf, -2);
|
||||
virBufferAddLit(&buf, "</disks>\n");
|
||||
}
|
||||
|
||||
if (def->dom) {
|
||||
if (virDomainDefFormatInternal(def->dom, caps, flags, &buf) < 0) {
|
||||
virBufferFreeAndReset(&buf);
|
||||
return NULL;
|
||||
}
|
||||
if (virDomainDefFormatInternal(def->dom, caps, flags, &buf) < 0)
|
||||
goto error;
|
||||
} else if (domain_uuid) {
|
||||
virBufferAddLit(&buf, "<domain>\n");
|
||||
virBufferAdjustIndent(&buf, 2);
|
||||
@ -743,8 +749,10 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
|
||||
virBufferAdjustIndent(&buf, -2);
|
||||
virBufferAddLit(&buf, "</domain>\n");
|
||||
}
|
||||
|
||||
if (internal)
|
||||
virBufferAsprintf(&buf, "<active>%d</active>\n", def->current);
|
||||
|
||||
virBufferAdjustIndent(&buf, -2);
|
||||
virBufferAddLit(&buf, "</domainsnapshot>\n");
|
||||
|
||||
@ -752,6 +760,10 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid,
|
||||
return NULL;
|
||||
|
||||
return virBufferContentAndReset(&buf);
|
||||
|
||||
error:
|
||||
virBufferFreeAndReset(&buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Snapshot Obj functions */
|
||||
|
Loading…
x
Reference in New Issue
Block a user