From acca9134930603747fcfd386dc5d2ee288ced2c8 Mon Sep 17 00:00:00 2001 From: Laine Stump Date: Wed, 12 Mar 2014 18:00:10 -0600 Subject: [PATCH] qemu: eliminate hardcoded indent from migration cookie xml This is also never seen by a human. --- src/qemu/qemu_migration.c | 49 +++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 54c6feccae..0bbec2ea95 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -535,15 +535,17 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig, 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"); - virBufferEscapeString(buf, " \n", grap->tlsSubject); - virBufferAddLit(buf, " \n"); + virBufferAdjustIndent(buf, 2); + virBufferEscapeString(buf, "\n", grap->tlsSubject); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); } else { virBufferAddLit(buf, "/>\n"); } @@ -561,23 +563,28 @@ qemuMigrationCookieNetworkXMLFormat(virBufferPtr buf, /* If optr->net[i].vporttype is not set, there is nothing to transfer */ if (optr->net[i].vporttype != VIR_NETDEV_VPORT_PROFILE_NONE) { if (empty) { - virBufferAddLit(buf, " \n"); + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); empty = false; } - virBufferAsprintf(buf, " net[i].vporttype)); if (optr->net[i].portdata) { virBufferAddLit(buf, ">\n"); - virBufferEscapeString(buf, " %s\n", + virBufferAdjustIndent(buf, 2); + virBufferEscapeString(buf, "%s\n", optr->net[i].portdata); - virBufferAddLit(buf, " \n"); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); } else { virBufferAddLit(buf, "/>\n"); } } } - if (!empty) - virBufferAddLit(buf, " \n"); + if (!empty) { + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); + } } @@ -594,14 +601,15 @@ qemuMigrationCookieXMLFormat(virQEMUDriverPtr driver, virUUIDFormat(mig->localHostuuid, hostuuidstr); virBufferAddLit(buf, "\n"); - virBufferEscapeString(buf, " %s\n", mig->name); - virBufferAsprintf(buf, " %s\n", uuidstr); - virBufferEscapeString(buf, " %s\n", mig->localHostname); - virBufferAsprintf(buf, " %s\n", hostuuidstr); + virBufferAdjustIndent(buf, 2); + virBufferEscapeString(buf, "%s\n", mig->name); + virBufferAsprintf(buf, "%s\n", uuidstr); + virBufferEscapeString(buf, "%s\n", mig->localHostname); + virBufferAsprintf(buf, "%s\n", hostuuidstr); for (i = 0; i < QEMU_MIGRATION_COOKIE_FLAG_LAST; i++) { if (mig->flagsMandatory & (1 << i)) - virBufferAsprintf(buf, " \n", + virBufferAsprintf(buf, "\n", qemuMigrationCookieFlagTypeToString(i)); } @@ -611,16 +619,17 @@ qemuMigrationCookieXMLFormat(virQEMUDriverPtr driver, if ((mig->flags & QEMU_MIGRATION_COOKIE_LOCKSTATE) && mig->lockState) { - virBufferAsprintf(buf, " \n", + virBufferAsprintf(buf, "\n", mig->lockDriver); - virBufferAsprintf(buf, " %s\n", + virBufferAdjustIndent(buf, 2); + virBufferAsprintf(buf, "%s\n", mig->lockState); - virBufferAddLit(buf, " \n"); + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); } if ((mig->flags & QEMU_MIGRATION_COOKIE_PERSISTENT) && mig->persistent) { - virBufferAdjustIndent(buf, 2); if (qemuDomainDefFormatBuf(driver, mig->persistent, VIR_DOMAIN_XML_INACTIVE | @@ -628,19 +637,19 @@ qemuMigrationCookieXMLFormat(virQEMUDriverPtr driver, VIR_DOMAIN_XML_MIGRATABLE, buf) < 0) return -1; - virBufferAdjustIndent(buf, -2); } if ((mig->flags & QEMU_MIGRATION_COOKIE_NETWORK) && mig->network) qemuMigrationCookieNetworkXMLFormat(buf, mig->network); if ((mig->flags & QEMU_MIGRATION_COOKIE_NBD) && mig->nbd) { - virBufferAddLit(buf, " nbd->port) virBufferAsprintf(buf, " port='%d'", mig->nbd->port); virBufferAddLit(buf, "/>\n"); } + virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); return 0; } -- GitLab