diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f1b2447def..cc5e79b70b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -21671,13 +21671,14 @@ virDomainSourceDefFormatSeclabel(virBufferPtr buf, static int -virDomainDiskSourceFormatNetwork(virBufferPtr buf, +virDomainDiskSourceFormatNetwork(virBufferPtr attrBuf, + virBufferPtr childBuf, virStorageSourcePtr src) { size_t n; char *path = NULL; - virBufferAsprintf(buf, "protocol)); if (src->volume) { @@ -21685,38 +21686,28 @@ virDomainDiskSourceFormatNetwork(virBufferPtr buf, return -1; } - virBufferEscapeString(buf, " name='%s'", path ? path : src->path); + virBufferEscapeString(attrBuf, " name='%s'", path ? path : src->path); VIR_FREE(path); - if (src->nhosts == 0 && !src->snapshot && !src->configFile) { - virBufferAddLit(buf, "/>\n"); - } else { - virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); + for (n = 0; n < src->nhosts; n++) { + virBufferAddLit(childBuf, "hosts[n].name); - for (n = 0; n < src->nhosts; n++) { - virBufferAddLit(buf, "hosts[n].name); + if (src->hosts[n].port) + virBufferAsprintf(childBuf, " port='%u'", src->hosts[n].port); - if (src->hosts[n].port) - virBufferAsprintf(buf, " port='%u'", src->hosts[n].port); + if (src->hosts[n].transport) + virBufferAsprintf(childBuf, " transport='%s'", + virStorageNetHostTransportTypeToString(src->hosts[n].transport)); - if (src->hosts[n].transport) - virBufferAsprintf(buf, " transport='%s'", - virStorageNetHostTransportTypeToString(src->hosts[n].transport)); - - virBufferEscapeString(buf, " socket='%s'", src->hosts[n].socket); - virBufferAddLit(buf, "/>\n"); - } - - virBufferEscapeString(buf, "\n", src->snapshot); - virBufferEscapeString(buf, "\n", src->configFile); - - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); + virBufferEscapeString(childBuf, " socket='%s'", src->hosts[n].socket); + virBufferAddLit(childBuf, "/>\n"); } + virBufferEscapeString(childBuf, "\n", src->snapshot); + virBufferEscapeString(childBuf, "\n", src->configFile); + return 0; } @@ -21763,7 +21754,7 @@ virDomainDiskSourceFormatInternal(virBufferPtr buf, break; case VIR_STORAGE_TYPE_NETWORK: - if (virDomainDiskSourceFormatNetwork(buf, src) < 0) + if (virDomainDiskSourceFormatNetwork(&attrBuf, &childBuf, src) < 0) goto error; break;