2007-02-14 01:40:09 +00:00
|
|
|
/*
|
2009-09-16 11:37:26 +00:00
|
|
|
* libvirtd.h: daemon data structure definitions
|
2007-02-14 01:40:09 +00:00
|
|
|
*
|
2015-04-15 14:23:55 +00:00
|
|
|
* Copyright (C) 2006-2015 Red Hat, Inc.
|
2007-02-14 01:40:09 +00:00
|
|
|
* Copyright (C) 2006 Daniel P. Berrange
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-09-20 22:30:55 +00:00
|
|
|
* License along with this library. If not, see
|
2012-07-21 10:06:23 +00:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
2007-02-14 01:40:09 +00:00
|
|
|
*
|
|
|
|
* Author: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2012-01-20 18:43:28 +00:00
|
|
|
#ifndef LIBVIRTD_H__
|
|
|
|
# define LIBVIRTD_H__
|
|
|
|
|
|
|
|
# define VIR_ENUM_SENTINELS
|
2010-03-09 18:22:22 +00:00
|
|
|
|
|
|
|
# include <rpc/types.h>
|
|
|
|
# include <rpc/xdr.h>
|
|
|
|
# include "remote_protocol.h"
|
2015-04-15 14:23:55 +00:00
|
|
|
# include "admin_protocol.h"
|
2012-12-21 14:20:04 +00:00
|
|
|
# include "lxc_protocol.h"
|
2010-04-17 02:09:25 +00:00
|
|
|
# include "qemu_protocol.h"
|
2012-12-13 15:49:48 +00:00
|
|
|
# include "virthread.h"
|
2015-04-15 14:23:55 +00:00
|
|
|
|
2012-09-20 11:58:29 +00:00
|
|
|
# if WITH_SASL
|
2011-07-05 15:30:09 +00:00
|
|
|
# include "virnetsaslcontext.h"
|
|
|
|
# endif
|
2011-05-16 17:13:11 +00:00
|
|
|
# include "virnetserverprogram.h"
|
2010-03-09 18:22:22 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
typedef struct daemonClientStream daemonClientStream;
|
|
|
|
typedef daemonClientStream *daemonClientStreamPtr;
|
|
|
|
typedef struct daemonClientPrivate daemonClientPrivate;
|
|
|
|
typedef daemonClientPrivate *daemonClientPrivatePtr;
|
2015-04-15 14:23:55 +00:00
|
|
|
typedef struct daemonAdmClientPrivate daemonAdmClientPrivate;
|
|
|
|
typedef daemonAdmClientPrivate *daemonAdmClientPrivatePtr;
|
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>
2014-01-05 19:37:17 +00:00
|
|
|
typedef struct daemonClientEventCallback daemonClientEventCallback;
|
|
|
|
typedef daemonClientEventCallback *daemonClientEventCallbackPtr;
|
2009-07-10 12:06:36 +00:00
|
|
|
|
2007-02-14 01:40:09 +00:00
|
|
|
/* Stores the per-client connection state */
|
2011-05-16 17:13:11 +00:00
|
|
|
struct daemonClientPrivate {
|
|
|
|
/* Hold while accessing any data except conn */
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutex lock;
|
2008-12-04 22:16:40 +00:00
|
|
|
|
2014-01-06 00:23:55 +00:00
|
|
|
daemonClientEventCallbackPtr *domainEventCallbacks;
|
|
|
|
size_t ndomainEventCallbacks;
|
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>
2014-01-05 19:37:17 +00:00
|
|
|
daemonClientEventCallbackPtr *networkEventCallbacks;
|
|
|
|
size_t nnetworkEventCallbacks;
|
2014-01-29 22:30:44 +00:00
|
|
|
daemonClientEventCallbackPtr *qemuEventCallbacks;
|
|
|
|
size_t nqemuEventCallbacks;
|
2007-06-11 12:04:54 +00:00
|
|
|
|
2012-09-20 11:58:29 +00:00
|
|
|
# if WITH_SASL
|
2011-05-16 17:13:11 +00:00
|
|
|
virNetSASLSessionPtr sasl;
|
2011-07-05 15:30:09 +00:00
|
|
|
# endif
|
2009-07-10 12:06:36 +00:00
|
|
|
|
2007-06-11 12:04:54 +00:00
|
|
|
/* This is only valid if a remote open call has been made on this
|
|
|
|
* connection, otherwise it will be NULL. Also if remote close is
|
|
|
|
* called, it will be set back to NULL if that succeeds.
|
|
|
|
*/
|
|
|
|
virConnectPtr conn;
|
2007-02-14 01:40:09 +00:00
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
daemonClientStreamPtr streams;
|
2011-08-24 13:33:34 +00:00
|
|
|
bool keepalive_supported;
|
2007-02-14 01:40:09 +00:00
|
|
|
};
|
|
|
|
|
2015-04-15 14:23:55 +00:00
|
|
|
/* Separate private data for admin connection */
|
|
|
|
struct daemonAdmClientPrivate {
|
|
|
|
/* Just a placeholder, not that there is anything to be locked */
|
|
|
|
virMutex lock;
|
|
|
|
|
|
|
|
virNetDaemonPtr dmn;
|
|
|
|
};
|
|
|
|
|
2012-09-20 11:58:29 +00:00
|
|
|
# if WITH_SASL
|
2011-05-16 17:13:11 +00:00
|
|
|
extern virNetSASLContextPtr saslCtxt;
|
2011-07-05 15:30:09 +00:00
|
|
|
# endif
|
2011-05-16 17:13:11 +00:00
|
|
|
extern virNetServerProgramPtr remoteProgram;
|
|
|
|
extern virNetServerProgramPtr qemuProgram;
|
2009-01-20 19:27:11 +00:00
|
|
|
|
2007-02-14 01:40:09 +00:00
|
|
|
#endif
|