2007-02-14 01:40:09 +00:00
|
|
|
/*
|
Standardize use of header files, making internal.h primary.
* qemud/internal.h, qemud/qemud.h: Rename this file so it
doesn't conflict with src/internal.h.
* HACKING: Document how header files should be used.
* qemud/Makefile.am: Add src/ directory to includes.
* qemud/event.c, qemud/mdns.c, qemud/qemud.c, qemud/remote.c,
qemud/remote_protocol.c, qemud/remote_protocol.h,
qemud/remote_protocol.x, src/buf.c, src/libvirt.c,
src/nodeinfo.c, src/qemu_conf.c, src/qemu_driver.c,
src/stats_linux.c, src/storage_backend.c, src/storage_backend_fs.c,
src/storage_backend_iscsi.c, src/storage_backend_logical.c,
src/storage_conf.c, src/storage_driver.c, src/util.c,
src/util.h, src/virsh.c, src/virterror.c, src/xend_internal.c,
src/xml.c, tests/reconnect.c, tests/xmlrpctest.c,
tests/qparamtest.c: Standardize use of header files.
* docs/*, po/*: Rebuild docs.
2008-05-23 08:24:41 +00:00
|
|
|
* qemud.h: daemon data structure definitions
|
2007-02-14 01:40:09 +00:00
|
|
|
*
|
2009-02-09 17:52:38 +00:00
|
|
|
* Copyright (C) 2006-2009 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__
|
|
|
|
#define QEMUD_INTERNAL_H__
|
|
|
|
|
2008-01-23 14:54:41 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2007-06-11 12:04:54 +00:00
|
|
|
#include <gnutls/gnutls.h>
|
|
|
|
#include <gnutls/x509.h>
|
Standardize use of header files, making internal.h primary.
* qemud/internal.h, qemud/qemud.h: Rename this file so it
doesn't conflict with src/internal.h.
* HACKING: Document how header files should be used.
* qemud/Makefile.am: Add src/ directory to includes.
* qemud/event.c, qemud/mdns.c, qemud/qemud.c, qemud/remote.c,
qemud/remote_protocol.c, qemud/remote_protocol.h,
qemud/remote_protocol.x, src/buf.c, src/libvirt.c,
src/nodeinfo.c, src/qemu_conf.c, src/qemu_driver.c,
src/stats_linux.c, src/storage_backend.c, src/storage_backend_fs.c,
src/storage_backend_iscsi.c, src/storage_backend_logical.c,
src/storage_conf.c, src/storage_driver.c, src/util.c,
src/util.h, src/virsh.c, src/virterror.c, src/xend_internal.c,
src/xml.c, tests/reconnect.c, tests/xmlrpctest.c,
tests/qparamtest.c: Standardize use of header files.
* docs/*, po/*: Rebuild docs.
2008-05-23 08:24:41 +00:00
|
|
|
#include "gnutls_1_0_compat.h"
|
2007-12-05 15:24:15 +00:00
|
|
|
#if HAVE_SASL
|
|
|
|
#include <sasl/sasl.h>
|
|
|
|
#endif
|
2007-02-14 01:40:09 +00:00
|
|
|
|
2007-12-05 18:21:27 +00:00
|
|
|
#ifdef HAVE_POLKIT
|
|
|
|
#include <dbus/dbus.h>
|
|
|
|
#endif
|
|
|
|
|
2007-11-26 11:54:29 +00:00
|
|
|
#ifdef HAVE_SYS_SYSLIMITS_H
|
|
|
|
#include <sys/syslimits.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <rpc/types.h>
|
|
|
|
#include <rpc/xdr.h>
|
2007-06-11 12:04:54 +00:00
|
|
|
#include "remote_protocol.h"
|
2008-12-22 12:53:26 +00:00
|
|
|
#include "logging.h"
|
2009-01-15 19:56:05 +00:00
|
|
|
#include "threads.h"
|
2007-02-14 01:40:09 +00:00
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#ifdef HAVE_ANSIDECL_H
|
|
|
|
#include <ansidecl.h>
|
|
|
|
#endif
|
|
|
|
#ifndef ATTRIBUTE_UNUSED
|
2007-03-16 15:03:21 +00:00
|
|
|
#define ATTRIBUTE_UNUSED __attribute__((__unused__))
|
2007-02-14 01:40:09 +00:00
|
|
|
#endif
|
2007-03-15 17:24:56 +00:00
|
|
|
#ifndef ATTRIBUTE_FORMAT
|
|
|
|
#define ATTRIBUTE_FORMAT(args...) __attribute__((__format__ (args)))
|
|
|
|
#endif
|
2007-02-14 01:40:09 +00:00
|
|
|
#else
|
|
|
|
#define ATTRIBUTE_UNUSED
|
2007-03-15 17:24:56 +00:00
|
|
|
#define ATTRIBUTE_FORMAT(...)
|
2007-02-14 01:40:09 +00:00
|
|
|
#endif
|
|
|
|
|
2008-12-22 12:53:26 +00:00
|
|
|
#define qemudDebug DEBUG
|
2007-06-11 12:04:54 +00:00
|
|
|
|
2007-12-05 15:27:08 +00:00
|
|
|
/* Whether we're passing reads & writes through a sasl SSF */
|
|
|
|
enum qemud_sasl_ssf {
|
|
|
|
QEMUD_SASL_SSF_NONE = 0,
|
|
|
|
QEMUD_SASL_SSF_READ = 1,
|
|
|
|
QEMUD_SASL_SSF_WRITE = 2,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum qemud_sock_type {
|
|
|
|
QEMUD_SOCK_TYPE_UNIX = 0,
|
|
|
|
QEMUD_SOCK_TYPE_TCP = 1,
|
|
|
|
QEMUD_SOCK_TYPE_TLS = 2,
|
2007-06-11 12:04:54 +00:00
|
|
|
};
|
|
|
|
|
2009-01-20 19:25:15 +00:00
|
|
|
struct qemud_client_message {
|
|
|
|
char buffer [REMOTE_MESSAGE_MAX + REMOTE_MESSAGE_HEADER_XDR_LEN];
|
|
|
|
unsigned int bufferLength;
|
|
|
|
unsigned int bufferOffset;
|
|
|
|
|
|
|
|
int async : 1;
|
|
|
|
|
|
|
|
struct qemud_client_message *next;
|
|
|
|
};
|
|
|
|
|
2007-02-14 01:40:09 +00:00
|
|
|
/* Stores the per-client connection state */
|
|
|
|
struct qemud_client {
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutex lock;
|
2008-12-04 22:16:40 +00:00
|
|
|
|
2007-06-11 12:04:54 +00:00
|
|
|
int magic;
|
|
|
|
|
2007-02-14 01:40:09 +00:00
|
|
|
int fd;
|
2008-11-19 16:19:36 +00:00
|
|
|
int watch;
|
2008-12-04 22:16:40 +00:00
|
|
|
int readonly:1;
|
|
|
|
int closing:1;
|
2007-06-11 12:04:54 +00:00
|
|
|
|
|
|
|
struct sockaddr_storage addr;
|
|
|
|
socklen_t addrlen;
|
|
|
|
|
2007-12-05 15:27:08 +00:00
|
|
|
int type; /* qemud_sock_type */
|
|
|
|
gnutls_session_t tlssession;
|
2007-12-05 15:24:15 +00:00
|
|
|
int auth;
|
2009-01-20 19:25:15 +00:00
|
|
|
int handshake : 1; /* If we're in progress for TLS handshake */
|
2007-12-05 15:24:15 +00:00
|
|
|
#if HAVE_SASL
|
|
|
|
sasl_conn_t *saslconn;
|
2007-12-05 15:27:08 +00:00
|
|
|
int saslSSF;
|
|
|
|
const char *saslDecoded;
|
|
|
|
unsigned int saslDecodedLength;
|
|
|
|
unsigned int saslDecodedOffset;
|
|
|
|
const char *saslEncoded;
|
|
|
|
unsigned int saslEncodedLength;
|
|
|
|
unsigned int saslEncodedOffset;
|
2007-12-05 15:34:05 +00:00
|
|
|
char *saslUsername;
|
2007-12-05 15:24:15 +00:00
|
|
|
#endif
|
2007-06-11 12:04:54 +00:00
|
|
|
|
2009-01-20 19:25:15 +00:00
|
|
|
/* Count of meages in 'dx' or 'tx' queue
|
|
|
|
* ie RPC calls in progress. Does not count
|
|
|
|
* async events which are not used for
|
|
|
|
* throttling calculations */
|
|
|
|
int nrequests;
|
|
|
|
/* Zero or one messages being received. Zero if
|
|
|
|
* nrequests >= max_clients and throttling */
|
|
|
|
struct qemud_client_message *rx;
|
|
|
|
/* Zero or many messages waiting for a worker
|
|
|
|
* to process them */
|
|
|
|
struct qemud_client_message *dx;
|
|
|
|
/* Zero or many messages waiting for transmit
|
|
|
|
* back to client, including async events */
|
|
|
|
struct qemud_client_message *tx;
|
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;
|
2008-12-04 22:16:40 +00:00
|
|
|
int refs;
|
2007-06-11 12:04:54 +00:00
|
|
|
|
2008-10-23 13:18:18 +00:00
|
|
|
/* back-pointer to our server */
|
|
|
|
struct qemud_server *server;
|
2007-02-14 01:40:09 +00:00
|
|
|
};
|
|
|
|
|
2007-06-11 12:04:54 +00:00
|
|
|
#define QEMUD_CLIENT_MAGIC 0x7788aaee
|
|
|
|
|
2007-02-14 01:40:09 +00:00
|
|
|
|
|
|
|
struct qemud_socket {
|
|
|
|
int fd;
|
2008-11-19 16:19:36 +00:00
|
|
|
int watch;
|
2007-02-14 01:40:09 +00:00
|
|
|
int readonly;
|
2007-12-05 15:27:08 +00:00
|
|
|
int type; /* qemud_sock_type */
|
2007-12-05 15:24:15 +00:00
|
|
|
int auth;
|
2007-09-19 01:56:55 +00:00
|
|
|
int port;
|
2007-02-14 01:40:09 +00:00
|
|
|
struct qemud_socket *next;
|
|
|
|
};
|
|
|
|
|
2009-01-20 19:27:11 +00:00
|
|
|
struct qemud_worker {
|
|
|
|
pthread_t thread;
|
|
|
|
int hasThread :1;
|
|
|
|
int processingCall :1;
|
|
|
|
int quitRequest : 1;
|
|
|
|
|
|
|
|
/* back-pointer to our server */
|
|
|
|
struct qemud_server *server;
|
|
|
|
};
|
|
|
|
|
2007-02-14 01:40:09 +00:00
|
|
|
/* Main server state */
|
|
|
|
struct qemud_server {
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutex lock;
|
|
|
|
virCond job;
|
2008-12-04 22:16:40 +00:00
|
|
|
|
2009-06-12 13:20:13 +00:00
|
|
|
int privileged;
|
|
|
|
|
2008-12-04 22:16:40 +00:00
|
|
|
int nworkers;
|
2009-01-20 19:27:11 +00:00
|
|
|
int nactiveworkers;
|
|
|
|
struct qemud_worker *workers;
|
2007-02-14 01:40:09 +00:00
|
|
|
int nsockets;
|
|
|
|
struct qemud_socket *sockets;
|
|
|
|
int nclients;
|
2008-12-04 22:09:35 +00:00
|
|
|
struct qemud_client **clients;
|
2008-12-04 22:16:40 +00:00
|
|
|
|
2007-02-16 18:28:17 +00:00
|
|
|
int sigread;
|
2009-02-09 17:52:38 +00:00
|
|
|
char *logDir;
|
2007-02-16 18:28:17 +00:00
|
|
|
unsigned int shutdown : 1;
|
2007-09-19 01:56:55 +00:00
|
|
|
#ifdef HAVE_AVAHI
|
|
|
|
struct libvirtd_mdns *mdns;
|
|
|
|
#endif
|
2007-12-05 15:34:05 +00:00
|
|
|
#if HAVE_SASL
|
|
|
|
char **saslUsernameWhitelist;
|
|
|
|
#endif
|
2007-12-05 18:21:27 +00:00
|
|
|
#if HAVE_POLKIT
|
|
|
|
DBusConnection *sysbus;
|
|
|
|
#endif
|
2007-02-14 01:40:09 +00:00
|
|
|
};
|
|
|
|
|
2007-03-16 15:03:21 +00:00
|
|
|
void qemudLog(int priority, const char *fmt, ...)
|
|
|
|
ATTRIBUTE_FORMAT(printf,2,3);
|
2007-02-16 18:30:55 +00:00
|
|
|
|
2007-02-14 15:58:06 +00:00
|
|
|
|
2009-01-20 19:25:15 +00:00
|
|
|
int
|
2008-12-04 22:12:53 +00:00
|
|
|
remoteDispatchClientRequest (struct qemud_server *server,
|
2009-01-20 19:25:15 +00:00
|
|
|
struct qemud_client *client,
|
|
|
|
struct qemud_client_message *req);
|
2007-06-11 12:04:54 +00:00
|
|
|
|
2009-01-20 19:25:15 +00:00
|
|
|
int qemudRegisterClientEvent(struct qemud_server *server,
|
|
|
|
struct qemud_client *client,
|
|
|
|
int update);
|
2008-10-23 13:18:18 +00:00
|
|
|
|
2009-01-20 19:25:15 +00:00
|
|
|
void qemudDispatchClientFailure(struct qemud_client *client);
|
|
|
|
|
|
|
|
void
|
|
|
|
qemudClientMessageQueuePush(struct qemud_client_message **queue,
|
|
|
|
struct qemud_client_message *msg);
|
2007-02-23 08:39:49 +00:00
|
|
|
|
2008-10-23 13:18:18 +00:00
|
|
|
int remoteRelayDomainEvent (virConnectPtr conn ATTRIBUTE_UNUSED,
|
|
|
|
virDomainPtr dom,
|
|
|
|
int event,
|
2008-11-17 16:43:00 +00:00
|
|
|
int detail,
|
2008-10-23 13:18:18 +00:00
|
|
|
void *opaque);
|
|
|
|
|
2009-01-20 19:25:15 +00:00
|
|
|
|
|
|
|
#if HAVE_POLKIT
|
|
|
|
int qemudGetSocketIdentity(int fd, uid_t *uid, pid_t *pid);
|
|
|
|
#endif
|
|
|
|
|
2007-02-14 01:40:09 +00:00
|
|
|
#endif
|