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
|
|
|
*
|
2011-02-16 23:37:57 +00:00
|
|
|
* Copyright (C) 2006-2011 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
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
* Author: Daniel P. Berrange <berrange@redhat.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef QEMUD_INTERNAL_H__
|
2010-03-09 18:22:22 +00:00
|
|
|
# define QEMUD_INTERNAL_H__
|
|
|
|
|
|
|
|
# include <config.h>
|
|
|
|
|
|
|
|
# include <rpc/types.h>
|
|
|
|
# include <rpc/xdr.h>
|
|
|
|
# include "remote_protocol.h"
|
2010-04-17 02:09:25 +00:00
|
|
|
# include "qemu_protocol.h"
|
2010-03-09 18:22:22 +00:00
|
|
|
# include "logging.h"
|
|
|
|
# include "threads.h"
|
2010-10-21 14:45:12 +00:00
|
|
|
# include "network.h"
|
2011-07-05 15:30:09 +00:00
|
|
|
# if HAVE_SASL
|
|
|
|
# include "virnetsaslcontext.h"
|
|
|
|
# endif
|
2011-05-16 17:13:11 +00:00
|
|
|
# include "virnetserverprogram.h"
|
2010-03-09 18:22:22 +00:00
|
|
|
|
Add dtrace static probes in libvirtd
Adds initial support for dtrace static probes in libvirtd
daemon, assuming use of systemtap dtrace compat shim on
Linux. The probes are inserted for network client connect,
disconnect, TLS handshake states and authentication protocol
states.
This can be tested by running the xample program and then
attempting to connect with any libvirt client (virsh,
virt-manager, etc).
# stap examples/systemtap/client.stp
Client fd=44 connected readonly=0
Client fd=44 auth polkit deny pid:24997,uid:500
Client fd=44 disconnected
Client fd=46 connected readonly=1
Client fd=46 auth sasl allow test
Client fd=46 disconnected
The libvirtd.stp file should also really not be required,
since it is duplicated info that is already available in
the main probes.d definition file. A script to autogenerate
the .stp file is needed, either in libvirtd tree, or better
as part of systemtap itself.
* Makefile.am: Add examples/systemtap subdir
* autobuild.sh: Disable dtrace for mingw32
* configure.ac: Add check for dtrace
* daemon/.gitignore: Ignore generated dtrace probe file
* daemon/Makefile.am: Build dtrace probe header & object
files
* daemon/libvirtd.stp: SystemTAP convenience probeset
* daemon/libvirtd.c: Add connect/disconnect & TLS probes
* daemon/remote.c: Add SASL and PolicyKit auth probes
* daemon/probes.d: Master probe definition
* daemon/libvirtd.h: Add convenience macro for probes
so that compilation is a no-op when dtrace is not available
* examples/systemtap/Makefile.am, examples/systemtap/client.stp
Example systemtap script using dtrace probe markers
* libvirt.spec.in: Enable dtrace on F13/RHEL6
* mingw32-libvirt.spec.in: Force disable dtrace
2010-09-14 16:30:32 +00:00
|
|
|
# if WITH_DTRACE
|
|
|
|
# ifndef LIBVIRTD_PROBES_H
|
|
|
|
# define LIBVIRTD_PROBES_H
|
|
|
|
# include "probes.h"
|
|
|
|
# endif /* LIBVIRTD_PROBES_H */
|
2011-07-01 18:33:50 +00:00
|
|
|
|
|
|
|
/* Systemtap 1.2 headers have a bug where they cannot handle a
|
|
|
|
* variable declared with array type. Work around this by casting all
|
|
|
|
* arguments. This is some gross use of the preprocessor because
|
|
|
|
* PROBE is a var-arg macro, but it is better than the alternative of
|
|
|
|
* making all callers to PROBE have to be aware of the issues. And
|
|
|
|
* hopefully, if we ever add a call to PROBE with other than 2 or 3
|
|
|
|
* end arguments, you can figure out the pattern to extend this hack.
|
|
|
|
*/
|
|
|
|
# define VIR_COUNT_ARGS(...) VIR_ARG5(__VA_ARGS__, 4, 3, 2, 1)
|
|
|
|
# define VIR_ARG5(_1, _2, _3, _4, _5, ...) _5
|
|
|
|
# define VIR_ADD_CAST_EXPAND(a, b, ...) VIR_ADD_CAST_PASTE(a, b, __VA_ARGS__)
|
|
|
|
# define VIR_ADD_CAST_PASTE(a, b, ...) a##b(__VA_ARGS__)
|
|
|
|
|
|
|
|
/* The double cast is necessary to silence gcc warnings; any pointer
|
|
|
|
* can safely go to intptr_t and back to void *, which collapses
|
|
|
|
* arrays into pointers; while any integer can be widened to intptr_t
|
|
|
|
* then cast to void *. */
|
|
|
|
# define VIR_ADD_CAST(a) ((void *)(intptr_t)(a))
|
|
|
|
# define VIR_ADD_CAST2(a, b) \
|
|
|
|
VIR_ADD_CAST(a), VIR_ADD_CAST(b)
|
|
|
|
# define VIR_ADD_CAST3(a, b, c) \
|
|
|
|
VIR_ADD_CAST(a), VIR_ADD_CAST(b), VIR_ADD_CAST(c)
|
|
|
|
|
|
|
|
# define VIR_ADD_CASTS(...) \
|
|
|
|
VIR_ADD_CAST_EXPAND(VIR_ADD_CAST, VIR_COUNT_ARGS(__VA_ARGS__), \
|
|
|
|
__VA_ARGS__)
|
|
|
|
|
|
|
|
# define PROBE_EXPAND(NAME, ARGS) NAME(ARGS)
|
Add dtrace static probes in libvirtd
Adds initial support for dtrace static probes in libvirtd
daemon, assuming use of systemtap dtrace compat shim on
Linux. The probes are inserted for network client connect,
disconnect, TLS handshake states and authentication protocol
states.
This can be tested by running the xample program and then
attempting to connect with any libvirt client (virsh,
virt-manager, etc).
# stap examples/systemtap/client.stp
Client fd=44 connected readonly=0
Client fd=44 auth polkit deny pid:24997,uid:500
Client fd=44 disconnected
Client fd=46 connected readonly=1
Client fd=46 auth sasl allow test
Client fd=46 disconnected
The libvirtd.stp file should also really not be required,
since it is duplicated info that is already available in
the main probes.d definition file. A script to autogenerate
the .stp file is needed, either in libvirtd tree, or better
as part of systemtap itself.
* Makefile.am: Add examples/systemtap subdir
* autobuild.sh: Disable dtrace for mingw32
* configure.ac: Add check for dtrace
* daemon/.gitignore: Ignore generated dtrace probe file
* daemon/Makefile.am: Build dtrace probe header & object
files
* daemon/libvirtd.stp: SystemTAP convenience probeset
* daemon/libvirtd.c: Add connect/disconnect & TLS probes
* daemon/remote.c: Add SASL and PolicyKit auth probes
* daemon/probes.d: Master probe definition
* daemon/libvirtd.h: Add convenience macro for probes
so that compilation is a no-op when dtrace is not available
* examples/systemtap/Makefile.am, examples/systemtap/client.stp
Example systemtap script using dtrace probe markers
* libvirt.spec.in: Enable dtrace on F13/RHEL6
* mingw32-libvirt.spec.in: Force disable dtrace
2010-09-14 16:30:32 +00:00
|
|
|
# define PROBE(NAME, FMT, ...) \
|
|
|
|
VIR_DEBUG_INT("trace." __FILE__ , __func__, __LINE__, \
|
|
|
|
#NAME ": " FMT, __VA_ARGS__); \
|
|
|
|
if (LIBVIRTD_ ## NAME ## _ENABLED()) { \
|
2011-07-01 18:33:50 +00:00
|
|
|
PROBE_EXPAND(LIBVIRTD_ ## NAME, \
|
|
|
|
VIR_ADD_CASTS(__VA_ARGS__)); \
|
Add dtrace static probes in libvirtd
Adds initial support for dtrace static probes in libvirtd
daemon, assuming use of systemtap dtrace compat shim on
Linux. The probes are inserted for network client connect,
disconnect, TLS handshake states and authentication protocol
states.
This can be tested by running the xample program and then
attempting to connect with any libvirt client (virsh,
virt-manager, etc).
# stap examples/systemtap/client.stp
Client fd=44 connected readonly=0
Client fd=44 auth polkit deny pid:24997,uid:500
Client fd=44 disconnected
Client fd=46 connected readonly=1
Client fd=46 auth sasl allow test
Client fd=46 disconnected
The libvirtd.stp file should also really not be required,
since it is duplicated info that is already available in
the main probes.d definition file. A script to autogenerate
the .stp file is needed, either in libvirtd tree, or better
as part of systemtap itself.
* Makefile.am: Add examples/systemtap subdir
* autobuild.sh: Disable dtrace for mingw32
* configure.ac: Add check for dtrace
* daemon/.gitignore: Ignore generated dtrace probe file
* daemon/Makefile.am: Build dtrace probe header & object
files
* daemon/libvirtd.stp: SystemTAP convenience probeset
* daemon/libvirtd.c: Add connect/disconnect & TLS probes
* daemon/remote.c: Add SASL and PolicyKit auth probes
* daemon/probes.d: Master probe definition
* daemon/libvirtd.h: Add convenience macro for probes
so that compilation is a no-op when dtrace is not available
* examples/systemtap/Makefile.am, examples/systemtap/client.stp
Example systemtap script using dtrace probe markers
* libvirt.spec.in: Enable dtrace on F13/RHEL6
* mingw32-libvirt.spec.in: Force disable dtrace
2010-09-14 16:30:32 +00:00
|
|
|
}
|
|
|
|
# else
|
2010-10-21 14:45:12 +00:00
|
|
|
# define PROBE(NAME, FMT, ...) \
|
|
|
|
VIR_DEBUG_INT("trace." __FILE__, __func__, __LINE__, \
|
Add dtrace static probes in libvirtd
Adds initial support for dtrace static probes in libvirtd
daemon, assuming use of systemtap dtrace compat shim on
Linux. The probes are inserted for network client connect,
disconnect, TLS handshake states and authentication protocol
states.
This can be tested by running the xample program and then
attempting to connect with any libvirt client (virsh,
virt-manager, etc).
# stap examples/systemtap/client.stp
Client fd=44 connected readonly=0
Client fd=44 auth polkit deny pid:24997,uid:500
Client fd=44 disconnected
Client fd=46 connected readonly=1
Client fd=46 auth sasl allow test
Client fd=46 disconnected
The libvirtd.stp file should also really not be required,
since it is duplicated info that is already available in
the main probes.d definition file. A script to autogenerate
the .stp file is needed, either in libvirtd tree, or better
as part of systemtap itself.
* Makefile.am: Add examples/systemtap subdir
* autobuild.sh: Disable dtrace for mingw32
* configure.ac: Add check for dtrace
* daemon/.gitignore: Ignore generated dtrace probe file
* daemon/Makefile.am: Build dtrace probe header & object
files
* daemon/libvirtd.stp: SystemTAP convenience probeset
* daemon/libvirtd.c: Add connect/disconnect & TLS probes
* daemon/remote.c: Add SASL and PolicyKit auth probes
* daemon/probes.d: Master probe definition
* daemon/libvirtd.h: Add convenience macro for probes
so that compilation is a no-op when dtrace is not available
* examples/systemtap/Makefile.am, examples/systemtap/client.stp
Example systemtap script using dtrace probe markers
* libvirt.spec.in: Enable dtrace on F13/RHEL6
* mingw32-libvirt.spec.in: Force disable dtrace
2010-09-14 16:30:32 +00:00
|
|
|
#NAME ": " FMT, __VA_ARGS__);
|
|
|
|
# endif
|
|
|
|
|
2011-05-16 17:13:11 +00:00
|
|
|
typedef struct daemonClientStream daemonClientStream;
|
|
|
|
typedef daemonClientStream *daemonClientStreamPtr;
|
|
|
|
typedef struct daemonClientPrivate daemonClientPrivate;
|
|
|
|
typedef daemonClientPrivate *daemonClientPrivatePtr;
|
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
|
|
|
|
Remote driver & daemon impl of new event API
This wires up the remote driver to handle the new events APIs.
The public API allows an application to request a callback filters
events to a specific domain object, and register multiple callbacks
for the same event type. On the wire there are two strategies for
this
- Register multiple callbacks with the remote daemon, each
with filtering as needed
- Register only one callback per event type, with no filtering
Both approaches have potential inefficiency. In the first scheme,
the same event gets sent over the wire many times if multiple
callbacks are registered. With the second scheme, unneccessary
events get sent over the wire if a per-domain filter is set on
the client. The second scheme is far easier to implement though,
so this patch takes that approach.
* daemon/dispatch.h: Don't export remoteRelayDomainEvent since it
is no longer needed for unregistering callbacks, instead the
unique callback ID is used
* daemon/libvirtd.c, daemon/libvirtd.h: Track and unregister
callbacks based on callback ID, instead of function pointer
* daemon/remote.c: Switch over to using virConnectDomainEventRegisterAny
instead of legacy virConnectDomainEventRegister function. Refactor
remoteDispatchDomainEventSend() to cope with arbitrary event types
* src/driver.h, src/driver.c: Move verify() call into source file
instead of header, to avoid polluting the global namespace with
the verify function name
* src/remote/remote_driver.c: Implement new APIs for event
registration. Refactor processCallDispatchMessage() to cope
with arbitrary incoming event types. Merge remoteDomainQueueEvent()
into processCallDispatchMessage() to avoid duplication of code.
Rename remoteDomainReadEvent() to remoteDomainReadEventLifecycle()
* src/remote/remote_protocol.x: Define wire format for the new
virConnectDomainEventRegisterAny and virConnectDomainEventDeregisterAny
functions
2010-03-18 14:56:56 +00:00
|
|
|
int domainEventCallbackID[VIR_DOMAIN_EVENT_ID_LAST];
|
2007-06-11 12:04:54 +00:00
|
|
|
|
2011-07-05 15:30:09 +00:00
|
|
|
# if HAVE_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;
|
2007-02-14 01:40:09 +00:00
|
|
|
};
|
|
|
|
|
2011-07-05 15:30:09 +00:00
|
|
|
# if HAVE_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
|