From 592a9a859a31b8a044d1b1af91ad239e17edb92a Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 30 Sep 2020 15:24:19 +0200 Subject: [PATCH] qemuMigrationCookieGraphicsXMLFormat: Use 'virXMLFormatElement' Switch to the two buffer approach to simplify the logic for terminating the element. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c index 97a14c6618..7f8772968f 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -578,20 +578,19 @@ static void qemuMigrationCookieGraphicsXMLFormat(virBufferPtr buf, qemuMigrationCookieGraphicsPtr grap) { - virBufferAsprintf(buf, "type), grap->port, grap->listen); + if (grap->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) - virBufferAsprintf(buf, " tlsPort='%d'", grap->tlsPort); - if (grap->tlsSubject) { - virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); - virBufferEscapeString(buf, "\n", grap->tlsSubject); - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - } else { - virBufferAddLit(buf, "/>\n"); - } + virBufferAsprintf(&attrBuf, " tlsPort='%d'", grap->tlsPort); + + virBufferEscapeString(&childBuf, "\n", grap->tlsSubject); + + virXMLFormatElement(buf, "graphics", &attrBuf, &childBuf); } -- 2.47.2