Convert virDomainWatchdogDefFormat to use a separate buffer for subelements. --- src/conf/domain_conf.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 6c4f2f398..fdac0e0ba 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -23275,6 +23275,9 @@ virDomainWatchdogDefFormat(virBufferPtr buf, { const char *model = virDomainWatchdogModelTypeToString(def->model); const char *action = virDomainWatchdogActionTypeToString(def->action); + virBuffer childBuf = VIR_BUFFER_INITIALIZER; + + virBufferAdjustIndent(&childBuf, virBufferGetIndent(buf, false) + 2); if (!model) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -23288,15 +23291,18 @@ virDomainWatchdogDefFormat(virBufferPtr buf, return -1; } + if (virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0) + return -1; + + if (virBufferCheckError(&childBuf) < 0) + return -1; + virBufferAsprintf(buf, "<watchdog model='%s' action='%s'", model, action); - if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) { + if (virBufferUse(&childBuf)) { virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); - if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) - return -1; - virBufferAdjustIndent(buf, -2); + virBufferAddBuffer(buf, &childBuf); virBufferAddLit(buf, "</watchdog>\n"); } else { virBufferAddLit(buf, "/>\n"); -- 2.13.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list