From 5b32815d1ad3d063691e8b4b901e454f22d2d6cf Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Mon, 28 Sep 2020 17:12:40 +0200 Subject: [PATCH] qemuMigrationCookieXMLFormatStr: Remove MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is just one caller, inline the code. This also optimizes the code as we no longer have to calculate length of the output XML as it's actually stored in the buffer struct. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/qemu/qemu_migration_cookie.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c index f5c16a8d16..1596ab914b 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -861,20 +861,6 @@ qemuMigrationCookieXMLFormat(virQEMUDriverPtr driver, } -static char * -qemuMigrationCookieXMLFormatStr(virQEMUDriverPtr driver, - virQEMUCapsPtr qemuCaps, - qemuMigrationCookiePtr mig) -{ - g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; - - if (qemuMigrationCookieXMLFormat(driver, qemuCaps, &buf, mig) < 0) - return NULL; - - return virBufferContentAndReset(&buf); -} - - static qemuMigrationCookieGraphicsPtr qemuMigrationCookieGraphicsXMLParse(xmlXPathContextPtr ctxt) { @@ -1397,6 +1383,7 @@ qemuMigrationCookieFormat(qemuMigrationCookiePtr mig, unsigned int flags) { qemuDomainObjPrivatePtr priv = dom->privateData; + g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; if (!cookieout || !cookieoutlen) return 0; @@ -1441,10 +1428,11 @@ qemuMigrationCookieFormat(qemuMigrationCookiePtr mig, qemuMigrationCookieAddCaps(mig, dom, party) < 0) return -1; - if (!(*cookieout = qemuMigrationCookieXMLFormatStr(driver, priv->qemuCaps, mig))) + if (qemuMigrationCookieXMLFormat(driver, priv->qemuCaps, &buf, mig) < 0) return -1; - *cookieoutlen = strlen(*cookieout) + 1; + *cookieoutlen = virBufferUse(&buf) + 1; + *cookieout = virBufferContentAndReset(&buf); VIR_DEBUG("cookielen=%d cookie=%s", *cookieoutlen, *cookieout);