diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b4fb6cf981..a3a514136b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -23929,6 +23929,7 @@ virDomainDiskSourceFormatPrivateData(virBufferPtr buf, * 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 is formatted if true * @flags: XML formatter flags @@ -23940,6 +23941,7 @@ virDomainDiskSourceFormatPrivateData(virBufferPtr buf, int virDomainDiskSourceFormat(virBufferPtr buf, virStorageSourcePtr src, + const char *element, int policy, bool attrIndex, unsigned int flags, @@ -24020,7 +24022,7 @@ virDomainDiskSourceFormat(virBufferPtr buf, 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; @@ -24066,7 +24068,8 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf, virBufferAsprintf(&childBuf, "\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) @@ -24229,7 +24232,8 @@ virDomainDiskDefFormatMirror(virBufferPtr buf, virDomainDiskMirrorStateTypeToString(disk->mirrorState)); virBufferEscapeString(&childBuf, "\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) @@ -24329,8 +24333,8 @@ virDomainDiskDefFormat(virBufferPtr buf, 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 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 01c22d8cc3..fa0756b634 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3061,6 +3061,7 @@ int virDomainDefFormatInternal(virDomainDefPtr def, int virDomainDiskSourceFormat(virBufferPtr buf, virStorageSourcePtr src, + const char *element, int policy, bool attrIndex, unsigned int flags, diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 36c328f692..eaa9b3c5e6 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -772,7 +772,8 @@ virDomainSnapshotDiskDefFormat(virBufferPtr buf, if (disk->src->format > 0) virBufferEscapeString(buf, "\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); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 960aaff3c7..db67fe2193 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2360,7 +2360,7 @@ qemuDomainObjPrivateXMLFormatNBDMigrationSource(virBufferPtr buf, 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; diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index c221b8af30..21db3e4881 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -86,7 +86,8 @@ testBackingXMLjsonXML(const void *args) return -1; } - if (virDomainDiskSourceFormat(&buf, jsonsrc, 0, false, 0, NULL) < 0 || + if (virDomainDiskSourceFormat(&buf, jsonsrc, "source", 0, false, 0, + NULL) < 0 || !(actualxml = virBufferContentAndReset(&buf))) { fprintf(stderr, "failed to format disk source xml\n"); return -1; diff --git a/tests/virstoragetest.c b/tests/virstoragetest.c index 4f23511240..ef16b3c6e0 100644 --- a/tests/virstoragetest.c +++ b/tests/virstoragetest.c @@ -627,7 +627,7 @@ testBackingParse(const void *args) goto cleanup; } - if (virDomainDiskSourceFormat(&buf, src, 0, false, 0, NULL) < 0 || + if (virDomainDiskSourceFormat(&buf, src, "source", 0, false, 0, NULL) < 0 || !(xml = virBufferContentAndReset(&buf))) { fprintf(stderr, "failed to format disk source xml\n"); goto cleanup;