]> git.ipfire.org Git - thirdparty/libvirt.git/commit
event: track callbackID on daemon side of RPC
authorEric Blake <eblake@redhat.com>
Sun, 5 Jan 2014 19:37:17 +0000 (12:37 -0700)
committerEric Blake <eblake@redhat.com>
Wed, 15 Jan 2014 20:55:20 +0000 (13:55 -0700)
commitb9d14ef03b4f7aa602cebe88d7df4cbc63673c49
tree2c8481851db9a21a28f7fb6d5128cf940e78a35d
parentb952cbbccafd5ead8b5a70b2608a1d5a7f03b31e
event: track callbackID on daemon side of RPC

Right now, the daemon side of RPC events is hard-coded to at most
one callback per eventID.  But when there are hundreds of domains
or networks coupled and multiple conections, then sending every
event to every connection that wants an event, even for the
connections that only care about events for a particular object,
is inefficient.  In order to track more than one callback in the
server, we need to store callbacks by more than just their
eventID.  This patch rearranges the daemon side to store network
callbacks in a dynamic array, which can eventually be used for
multiple callbacks of the same eventID, although actual behavior
is unchanged without further patches to the RPC protocol.  For
ease of review, domain events are saved for a later patch, as
they touch more code.

While at it, fix a bug where a malicious client could send a
negative eventID to cause network event registration to access
outside of array bounds (thankfully not a CVE, since domain
events were already doing the bounds check, and since network
events have not been released).

* daemon/libvirtd.h (daemonClientPrivate): Alter the tracking of
network events.
* daemon/remote.c (daemonClientEventCallback): New struct.
(remoteEventCallbackFree): New function.
(remoteClientInitHook, remoteRelayNetworkEventLifecycle)
(remoteClientFreeFunc)
(remoteDispatchConnectNetworkEventRegisterAny): Track network
callbacks differently.
(remoteDispatchConnectNetworkEventDeregisterAny): Enforce bounds.

Signed-off-by: Eric Blake <eblake@redhat.com>
daemon/libvirtd.h
daemon/remote.c