On 10/20/2011 03:08 AM, Peter Krempa wrote:
Dňa 29.9.2011 18:22, Eric Blake wrote / napísal(a):
<domainsnapshot> is the first public instance of<domain> being
used as a sub-element, although we have two other private uses
(runtime state, and migration cookie). Although indentation has
no effect on XML parsing, using it makes the output more consistent.
This uses virBuffer auto-indentation to obtain the effect, for all
but the portions of<domain> that are not generated a line at a
time into the same virBuffer. Further patches will clean up the
remaining problems.
* src/conf/domain_conf.h (virDomainDefFormatInternal): New prototype.
* src/conf/domain_conf.c (virDomainDefFormatInternal): Export.
(virDomainObjFormat, virDomainSnapshotDefFormat): Update callers.
* src/libvirt_private.syms (domain_conf.h): Add new export.
* src/qemu/qemu_migration.c (qemuMigrationCookieXMLFormat): Use
new function.
(qemuMigrationCookieXMLFormatStr): Update caller.
---
src/conf/domain_conf.c | 16 +++++++++++-----
src/conf/domain_conf.h | 3 +++
src/libvirt_private.syms | 1 +
src/qemu/qemu_migration.c | 25 ++++++++++++++++---------
4 files changed, 31 insertions(+), 14 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 1122dab..513ec37 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -416,14 +416,17 @@ static void
qemuMigrationCookieXMLFormat(virBufferPtr buf,
if ((mig->flags& QEMU_MIGRATION_COOKIE_PERSISTENT)&&
mig->persistent) {
- domXML = virDomainDefFormat(mig->persistent,
- VIR_DOMAIN_XML_INACTIVE |
- VIR_DOMAIN_XML_SECURE);
- virBufferAdd(buf, domXML, -1);
Saves one big strlen().
Yeah, hundreds of bytes at least.
- VIR_FREE(domXML);
@@ -431,10 +434,14 @@ static char
*qemuMigrationCookieXMLFormatStr(qemuMigrationCookiePtr mig)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
- qemuMigrationCookieXMLFormat(&buf, mig);
+ if (qemuMigrationCookieXMLFormat(&buf, mig)< 0) {
+ virBufferFreeAndReset(&buf);
+ return NULL;
+ }
if (virBufferError(&buf)) {
virReportOOMError();
+ virBufferFreeAndReset(&buf);
Probably shouldn't be necessary as the virBufferSetError already frees
the internal buffer.
Maybe for sure. Relying on other function's error handling(especially
when it is a deep calling line) is a little not that sure.
return NULL;
}
ACK,
Peter.
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list