diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index fe9b7c7273..a57c395661 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -23036,6 +23036,7 @@ virDomainInputDefFormat(virBufferPtr buf,
{
const char *type = virDomainInputTypeToString(def->type);
const char *bus = virDomainInputBusTypeToString(def->bus);
+ virBuffer childbuf = VIR_BUFFER_INITIALIZER;
/* don't format keyboard into migratable XML for backward compatibility */
if (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE &&
@@ -23058,17 +23059,17 @@ virDomainInputDefFormat(virBufferPtr buf,
virBufferAsprintf(buf, "info, flags) ||
- def->type == VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH) {
- virBufferAddLit(buf, ">\n");
- virBufferAdjustIndent(buf, 2);
- virBufferEscapeString(buf, "\n", def->source.evdev);
- if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
- return -1;
- virBufferAdjustIndent(buf, -2);
- virBufferAddLit(buf, "\n");
- } else {
+ virBufferAdjustIndent(&childbuf, virBufferGetIndent(buf, false) + 2);
+ virBufferEscapeString(&childbuf, "\n", def->source.evdev);
+ if (virDomainDeviceInfoFormat(&childbuf, &def->info, flags) < 0)
+ return -1;
+
+ if (!virBufferUse(&childbuf)) {
virBufferAddLit(buf, "/>\n");
+ } else {
+ virBufferAddLit(buf, ">\n");
+ virBufferAddBuffer(buf, &childbuf);
+ virBufferAddLit(buf, "\n");
}
return 0;