[libvirt] [PATCH] Fix emission of domain events messages

The code which updated the message length after writing the payload wrote the updated length word in the wrong place since the XDR object was given a buffer pointing to the start of the header payload, rather than message start. * daemon/remote.c: Fix updating of event message length so that we actually send the payload, not just the header --- daemon/remote.c | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) diff --git a/daemon/remote.c b/daemon/remote.c index 6d4cc1c..2b58045 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -4559,17 +4559,19 @@ remoteDispatchDomainEventSend (struct qemud_client *client, /* Serialise the return header and event. */ xdrmem_create (&xdr, - msg->buffer + msg->bufferOffset, - msg->bufferLength - msg->bufferOffset, + msg->buffer, + msg->bufferLength, XDR_ENCODE); - if (!xdr_remote_domain_event_msg(&xdr, data)) + /* Skip over the header we just wrote */ + if (xdr_setpos (&xdr, msg->bufferOffset) == 0) goto xdr_error; + if (!xdr_remote_domain_event_msg(&xdr, data)) + goto xdr_error; - /* Update length word */ - msg->bufferOffset += xdr_getpos (&xdr); - len = msg->bufferOffset; + /* Update length word to include payload*/ + len = msg->bufferOffset = xdr_getpos (&xdr); if (xdr_setpos (&xdr, 0) == 0) goto xdr_error; -- 1.6.2.5

On Wed, Sep 30, 2009 at 02:34:46PM +0100, Daniel P. Berrange wrote:
The code which updated the message length after writing the payload wrote the updated length word in the wrong place since the XDR object was given a buffer pointing to the start of the header payload, rather than message start.
* daemon/remote.c: Fix updating of event message length so that we actually send the payload, not just the header
ACK Hum, but how did that work previously ? Or did it never worked ? Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On Wed, Sep 30, 2009 at 03:51:21PM +0200, Daniel Veillard wrote:
On Wed, Sep 30, 2009 at 02:34:46PM +0100, Daniel P. Berrange wrote:
The code which updated the message length after writing the payload wrote the updated length word in the wrong place since the XDR object was given a buffer pointing to the start of the header payload, rather than message start.
* daemon/remote.c: Fix updating of event message length so that we actually send the payload, not just the header
ACK Hum, but how did that work previously ? Or did it never worked ?
I only broke the code fairly recently :-) Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On Wed, Sep 30, 2009 at 03:09:29PM +0100, Daniel P. Berrange wrote:
On Wed, Sep 30, 2009 at 03:51:21PM +0200, Daniel Veillard wrote:
On Wed, Sep 30, 2009 at 02:34:46PM +0100, Daniel P. Berrange wrote:
The code which updated the message length after writing the payload wrote the updated length word in the wrong place since the XDR object was given a buffer pointing to the start of the header payload, rather than message start.
* daemon/remote.c: Fix updating of event message length so that we actually send the payload, not just the header
ACK Hum, but how did that work previously ? Or did it never worked ?
I only broke the code fairly recently :-)
heh :-) Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/
participants (2)
-
Daniel P. Berrange
-
Daniel Veillard