Commit Graph

13 Commits

Author SHA1 Message Date
Matthias Bolte
89928d2c46 daemon: Include stdlib.h in dispatch.c
Otherwise GCC complains about malloc being unknown on FreeBSD.
2010-11-14 22:21:21 +01:00
Daniel P. Berrange
97d982a748 Try harder to send RPC error message back to client
When failing to serialize the normal RPC reply, try harder to
send a error message back to the client, instead of immediately
closing the connection.

* daemon/dispatch.c: Improve error messages when RPC reply
  can not be sent
2010-08-24 14:19:05 +01:00
Daniel P. Berrange
677c834ca7 Add explicit warning messages when failing to serialize to XDR
When libvirtd fails to serialize a message to XDR the client
connection is terminated immediately. To enable this to be
diagnosed, log the message which caused the problem on the
server

* daemon/dispatch.c: Log XDR serialization failures
2010-08-24 14:19:01 +01:00
Chris Lalancette
337d201ef2 Qemu remote protocol.
Since we are adding a new "per-hypervisor" protocol, we
make it so that the qemu remote protocol uses a new
PROTOCOL and PROGRAM number.  This allows us to easily
distinguish it from the normal REMOTE protocol.

This necessitates changing the proc in remote_message_header
from a "remote_procedure" to an "unsigned", which should
be the same size (and thus preserve the on-wire protocol).

Changes since v1:
 - Fixed up a couple of script problems in remote_generate_stubs.pl
 - Switch an int flag to a bool in dispatch.c

Changes since v2:
 - None

Changes since v3:
 - Change unsigned proc to signed proc, to conform to spec

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-07-23 17:30:33 -04:00
Ryota Ozaki
a3fc67a12c daemon: dispatch.c should include stdio.h (and stdarg.h)
dispatch.c requires stdio.h (and stdarg.h), however, currently
dispatch.c implicitly relys on rpc/xdr.h to include stdio.h.
If rpc/xdr.h unxpectedly does not include stdio.h, the compilation
of dispatch.c fails.

This can happen, for example, when portablexdr is installed
under /usr/local; because portablexdr's rpc/xdr.h does not
include stdio.h and gcc looks up it not /usr/include/rpc/xdr.h.

Note that stdarg.h is also included according to man va_start,
although stdio.h seems including it anyway.
2010-07-15 09:27:47 +02:00
Chris Lalancette
fa30eaf3d3 Fix messsage -> message.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-13 15:39:39 -04:00
Chris Lalancette
1be3c3c8ee Fix up a debug typo.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2010-04-13 15:39:32 -04:00
Chris Lalancette
c1a45b5107 Pass remote_message_header to the dispatch functions.
This is necessary for the dispatch functions to be able to use
streams in the future.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-09-30 14:05:57 +02:00
Matthias Bolte
d710d60c31 Change signature of remoteSendStreamData() to fix compile warning
The actual type of size_t is architecture dependent. Because the len
parameter is used as unsigned int in remoteSendStreamData(), change its
type to unsigned int.

* daemon/dispatch.[ch]: change size_t to unsigned int for
  remoteSendStreamData()
2009-09-30 12:37:10 +02:00
Matthias Bolte
c6f1459eb9 Fix memory leaks in libvirtd's message processing
Commit 47cab73499 changed the way how
qemud_client_message objects were reused. Before this commit
remoteDispatchClientRequest() reused the received message for normal responses
and to report non-fatal errors. If a fatal error occurred qemudWorker() frees
the message. After this commit non-fatal errors are reported by
remoteSerializeReplyError() using a new qemud_client_message object and the
original message leaks.

To fix this leak the original message has to be freed if
remoteSerializeReplyError() succeeds. If remoteSerializeReplyError()
fails the original message is freed in qemudWorker().

* daemon/dispatch.c: free qemud_client_message objects that will not be reused
  and would leak otherwise, also free the allocated qemud_client_message object
  in remoteSerializeError() if an error occurs
2009-09-30 02:27:00 +02:00
Daniel P. Berrange
4f17809a36 Handle outgoing data streams in libvirtd
* daemon/dispatch.c: Set streamTX flag on outgoing data packets
* daemon/qemud.h: Add streamTX flag to track outgoing data
* daemon/qemud.c: Re-enable further TX when outgoing data packet
  has been fully sent.
* daemon/stream.h, daemon/stream.c: Add method for enabling TX.
  Support reading from streams and transmitting data out to client
2009-09-29 15:48:58 +01:00
Daniel P. Berrange
11573f3ec1 Helper functions for processing data streams in libvirtd
Defines the extensions to the remote protocol for generic
data streams. Adds a bunch of helper code to the libvirtd
daemon for working with data streams.

* daemon/Makefile.am: Add stream.c/stream.h to build
* daemon/stream.c, qemud/stream.h: Generic helper functions for
  creating new streams, associating streams with clients, finding
  existing streams for a client and removing/deleting streams.
* src/remote/remote_protocol.x: Add a new 'REMOTE_STREAM' constant
  for the 'enum remote_message_type' for encoding stream data
  in wire messages. Add a new 'REMOTE_CONTINUE' constant to
  'enum remote_message_status' to indicate further data stream
  messsages are expected to follow.  Document how the
  remote_message_header is used to encode data streams
* src/remote/remote_protocol.h: Regenerate
* daemon/dispatch.c: Remove assumption that a error message
  sent to client is always type=REMOTE_REPLY. It may now
  also be type=REMOTE_STREAM. Add convenient method for
  sending outgoing stream data packets. Log and ignore
  non-filtered incoming stream packets. Add a method for
  serializing a stream error message
* daemon/dispatch.h:  Add API for serializing stream errors
  and sending stream data packets
* daemon/qemud.h: Add struct qemud_client_stream for tracking
  active data streams for clients. Tweak filter function
  operation so that it accepts a client object too.
* daemon/qemud.c: Refactor code for free'ing message objects
  which have been fully transmitted into separate method.
  Release all active streams when client shuts down. Change
  filter function to be responsible for queueing the message
2009-09-29 15:48:58 +01:00
Daniel P. Berrange
5c2a1ae876 Rename qemud/ directory to daemon/
* qemud/: Rename to daemon/
* Makefile.am, configure.in, src/Makefile.am, src/remote_internal.c,
  tests/Makefile.am, tests/eventtest.c: s/qemud/daemon/ where needed
2009-09-21 14:41:42 +01:00