mirror of
https://github.com/libvirt/libvirt.git
synced 2026-08-10 04:58:12 -05:00
Import stripped down virtlockd code as basis of virtlogd
Copy the virtlockd codebase across to form the initial virlogd code. Simple search & replace of s/lock/log/ and gut the remote protocol & dispatcher. This gives us a daemon that starts up and listens for connections, but does nothing with them. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* log_daemon.h: log management daemon
|
||||
*
|
||||
* Copyright (C) 2006-2015 Red Hat, Inc.
|
||||
*
|
||||
* 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, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Author: Daniel P. Berrange <berrange@redhat.com>
|
||||
*/
|
||||
|
||||
#ifndef __VIR_LOG_DAEMON_H__
|
||||
# define __VIR_LOG_DAEMON_H__
|
||||
|
||||
# include "virthread.h"
|
||||
|
||||
typedef struct _virLogDaemon virLogDaemon;
|
||||
typedef virLogDaemon *virLogDaemonPtr;
|
||||
|
||||
typedef struct _virLogDaemonClient virLogDaemonClient;
|
||||
typedef virLogDaemonClient *virLogDaemonClientPtr;
|
||||
|
||||
struct _virLogDaemonClient {
|
||||
virMutex lock;
|
||||
|
||||
pid_t clientPid;
|
||||
};
|
||||
|
||||
extern virLogDaemonPtr logDaemon;
|
||||
|
||||
#endif /* __VIR_LOG_DAEMON_H__ */
|
||||
@@ -0,0 +1,202 @@
|
||||
/*
|
||||
* log_daemon_config.c: virtlogd config file handling
|
||||
*
|
||||
* Copyright (C) 2006-2015 Red Hat, Inc.
|
||||
* 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, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Author: Daniel P. Berrange <berrange@redhat.com>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "log_daemon_config.h"
|
||||
#include "virconf.h"
|
||||
#include "viralloc.h"
|
||||
#include "virerror.h"
|
||||
#include "virlog.h"
|
||||
#include "rpc/virnetserver.h"
|
||||
#include "configmake.h"
|
||||
#include "virstring.h"
|
||||
#include "virutil.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_CONF
|
||||
|
||||
VIR_LOG_INIT("logging.log_daemon_config");
|
||||
|
||||
|
||||
/* A helper function used by each of the following macros. */
|
||||
static int
|
||||
checkType(virConfValuePtr p, const char *filename,
|
||||
const char *key, virConfType required_type)
|
||||
{
|
||||
if (p->type != required_type) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("remoteReadConfigFile: %s: %s: invalid type:"
|
||||
" got %s; expected %s"), filename, key,
|
||||
virConfTypeToString(p->type),
|
||||
virConfTypeToString(required_type));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* If there is no config data for the key, #var_name, then do nothing.
|
||||
If there is valid data of type VIR_CONF_STRING, and VIR_STRDUP succeeds,
|
||||
store the result in var_name. Otherwise, (i.e. invalid type, or VIR_STRDUP
|
||||
failure), give a diagnostic and "goto" the cleanup-and-fail label. */
|
||||
#define GET_CONF_STR(conf, filename, var_name) \
|
||||
do { \
|
||||
virConfValuePtr p = virConfGetValue(conf, #var_name); \
|
||||
if (p) { \
|
||||
if (checkType(p, filename, #var_name, VIR_CONF_STRING) < 0) \
|
||||
goto error; \
|
||||
VIR_FREE(data->var_name); \
|
||||
if (VIR_STRDUP(data->var_name, p->str) < 0) \
|
||||
goto error; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* Like GET_CONF_STR, but for signed integer values. */
|
||||
#define GET_CONF_INT(conf, filename, var_name) \
|
||||
do { \
|
||||
virConfValuePtr p = virConfGetValue(conf, #var_name); \
|
||||
if (p) { \
|
||||
if (p->type != VIR_CONF_ULONG && \
|
||||
checkType(p, filename, #var_name, VIR_CONF_LONG) < 0) \
|
||||
goto error; \
|
||||
data->var_name = p->l; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* Like GET_CONF_STR, but for unsigned integer values. */
|
||||
#define GET_CONF_UINT(conf, filename, var_name) \
|
||||
do { \
|
||||
virConfValuePtr p = virConfGetValue(conf, #var_name); \
|
||||
if (p) { \
|
||||
if (checkType(p, filename, #var_name, VIR_CONF_ULONG) < 0) \
|
||||
goto error; \
|
||||
data->var_name = p->l; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
int
|
||||
virLogDaemonConfigFilePath(bool privileged, char **configfile)
|
||||
{
|
||||
if (privileged) {
|
||||
if (VIR_STRDUP(*configfile, SYSCONFDIR "/libvirt/virtlogd.conf") < 0)
|
||||
goto error;
|
||||
} else {
|
||||
char *configdir = NULL;
|
||||
|
||||
if (!(configdir = virGetUserConfigDirectory()))
|
||||
goto error;
|
||||
|
||||
if (virAsprintf(configfile, "%s/virtlogd.conf", configdir) < 0) {
|
||||
VIR_FREE(configdir);
|
||||
goto error;
|
||||
}
|
||||
VIR_FREE(configdir);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
virLogDaemonConfigPtr
|
||||
virLogDaemonConfigNew(bool privileged ATTRIBUTE_UNUSED)
|
||||
{
|
||||
virLogDaemonConfigPtr data;
|
||||
|
||||
if (VIR_ALLOC(data) < 0)
|
||||
return NULL;
|
||||
|
||||
data->max_clients = 1024;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void
|
||||
virLogDaemonConfigFree(virLogDaemonConfigPtr data)
|
||||
{
|
||||
if (!data)
|
||||
return;
|
||||
|
||||
VIR_FREE(data->log_filters);
|
||||
VIR_FREE(data->log_outputs);
|
||||
|
||||
VIR_FREE(data);
|
||||
}
|
||||
|
||||
static int
|
||||
virLogDaemonConfigLoadOptions(virLogDaemonConfigPtr data,
|
||||
const char *filename,
|
||||
virConfPtr conf)
|
||||
{
|
||||
GET_CONF_UINT(conf, filename, log_level);
|
||||
GET_CONF_STR(conf, filename, log_filters);
|
||||
GET_CONF_STR(conf, filename, log_outputs);
|
||||
GET_CONF_UINT(conf, filename, max_clients);
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* Read the config file if it exists.
|
||||
*/
|
||||
int
|
||||
virLogDaemonConfigLoadFile(virLogDaemonConfigPtr data,
|
||||
const char *filename,
|
||||
bool allow_missing)
|
||||
{
|
||||
virConfPtr conf;
|
||||
int ret;
|
||||
|
||||
if (allow_missing &&
|
||||
access(filename, R_OK) == -1 &&
|
||||
errno == ENOENT)
|
||||
return 0;
|
||||
|
||||
conf = virConfReadFile(filename, 0);
|
||||
if (!conf)
|
||||
return -1;
|
||||
|
||||
ret = virLogDaemonConfigLoadOptions(data, filename, conf);
|
||||
virConfFree(conf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int virLogDaemonConfigLoadData(virLogDaemonConfigPtr data,
|
||||
const char *filename,
|
||||
const char *filedata)
|
||||
{
|
||||
virConfPtr conf;
|
||||
int ret;
|
||||
|
||||
conf = virConfReadMem(filedata, strlen(filedata), 0);
|
||||
if (!conf)
|
||||
return -1;
|
||||
|
||||
ret = virLogDaemonConfigLoadOptions(data, filename, conf);
|
||||
virConfFree(conf);
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* log_daemon_config.h: virtlogd config file handling
|
||||
*
|
||||
* Copyright (C) 2006-2015 Red Hat, Inc.
|
||||
* 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, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Author: Daniel P. Berrange <berrange@redhat.com>
|
||||
*/
|
||||
|
||||
#ifndef __VIR_LOG_DAEMON_CONFIG_H__
|
||||
# define __VIR_LOG_DAEMON_CONFIG_H__
|
||||
|
||||
# include "internal.h"
|
||||
|
||||
typedef struct _virLogDaemonConfig virLogDaemonConfig;
|
||||
typedef virLogDaemonConfig *virLogDaemonConfigPtr;
|
||||
|
||||
struct _virLogDaemonConfig {
|
||||
int log_level;
|
||||
char *log_filters;
|
||||
char *log_outputs;
|
||||
int max_clients;
|
||||
};
|
||||
|
||||
|
||||
int virLogDaemonConfigFilePath(bool privileged, char **configfile);
|
||||
virLogDaemonConfigPtr virLogDaemonConfigNew(bool privileged);
|
||||
void virLogDaemonConfigFree(virLogDaemonConfigPtr data);
|
||||
int virLogDaemonConfigLoadFile(virLogDaemonConfigPtr data,
|
||||
const char *filename,
|
||||
bool allow_missing);
|
||||
int virLogDaemonConfigLoadData(virLogDaemonConfigPtr data,
|
||||
const char *filename,
|
||||
const char *filedata);
|
||||
|
||||
#endif /* __LIBVIRTD_CONFIG_H__ */
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* log_daemon_dispatch.c: log management daemon dispatch
|
||||
*
|
||||
* Copyright (C) 2006-2015 Red Hat, Inc.
|
||||
*
|
||||
* 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, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Author: Daniel P. Berrange <berrange@redhat.com>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "rpc/virnetserver.h"
|
||||
#include "rpc/virnetserverclient.h"
|
||||
#include "virlog.h"
|
||||
#include "virstring.h"
|
||||
#include "log_daemon.h"
|
||||
#include "log_protocol.h"
|
||||
#include "virerror.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_RPC
|
||||
|
||||
VIR_LOG_INIT("logging.log_daemon_dispatch");
|
||||
|
||||
#include "log_daemon_dispatch_stubs.h"
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* log_daemon_dispatch.h: log management daemon dispatch
|
||||
*
|
||||
* Copyright (C) 2006-2015 Red Hat, Inc.
|
||||
*
|
||||
* 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, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Author: Daniel P. Berrange <berrange@redhat.com>
|
||||
*/
|
||||
|
||||
#ifndef __VIR_LOG_DAEMON_DISPATCH_H__
|
||||
# define __VIR_LOG_DAEMON_DISPATCH_H__
|
||||
|
||||
# include "rpc/virnetserverprogram.h"
|
||||
|
||||
extern virNetServerProgramProc virLogManagerProtocolProcs[];
|
||||
extern size_t virLogManagerProtocolNProcs;
|
||||
|
||||
#endif /* __VIR_LOG_DAEMON_DISPATCH_H__ */
|
||||
@@ -0,0 +1,22 @@
|
||||
/* -*- c -*-
|
||||
*/
|
||||
|
||||
%#include "internal.h"
|
||||
|
||||
typedef opaque virLogManagerProtocolUUID[VIR_UUID_BUFLEN];
|
||||
|
||||
/* Length of long, but not unbounded, strings.
|
||||
* This is an arbitrary limit designed to stop the decoder from trying
|
||||
* to allocate unbounded amounts of memory when fed with a bad message.
|
||||
*/
|
||||
const VIR_LOG_MANAGER_PROTOCOL_STRING_MAX = 4194304;
|
||||
|
||||
/* A long string, which may NOT be NULL. */
|
||||
typedef string virLogManagerProtocolNonNullString<VIR_LOG_MANAGER_PROTOCOL_STRING_MAX>;
|
||||
|
||||
/* A long string, which may be NULL. */
|
||||
typedef virLogManagerProtocolNonNullString *virLogManagerProtocolString;
|
||||
|
||||
/* Define the program number, protocol version and procedure numbers here. */
|
||||
const VIR_LOG_MANAGER_PROTOCOL_PROGRAM = 0x87539319;
|
||||
const VIR_LOG_MANAGER_PROTOCOL_PROGRAM_VERSION = 1;
|
||||
@@ -0,0 +1,10 @@
|
||||
module Test_virtlogd =
|
||||
let conf = "log_level = 3
|
||||
log_filters=\"3:remote 4:event\"
|
||||
log_outputs=\"3:syslog:virtlogd\"
|
||||
"
|
||||
|
||||
test Virtlogd.lns get conf =
|
||||
{ "log_level" = "3" }
|
||||
{ "log_filters" = "3:remote 4:event" }
|
||||
{ "log_outputs" = "3:syslog:virtlogd" }
|
||||
@@ -0,0 +1,45 @@
|
||||
(* /etc/libvirt/virtlogd.conf *)
|
||||
|
||||
module Virtlogd =
|
||||
autoload xfm
|
||||
|
||||
let eol = del /[ \t]*\n/ "\n"
|
||||
let value_sep = del /[ \t]*=[ \t]*/ " = "
|
||||
let indent = del /[ \t]*/ ""
|
||||
|
||||
let array_sep = del /,[ \t\n]*/ ", "
|
||||
let array_start = del /\[[ \t\n]*/ "[ "
|
||||
let array_end = del /\]/ "]"
|
||||
|
||||
let str_val = del /\"/ "\"" . store /[^\"]*/ . del /\"/ "\""
|
||||
let bool_val = store /0|1/
|
||||
let int_val = store /[0-9]+/
|
||||
let str_array_element = [ seq "el" . str_val ] . del /[ \t\n]*/ ""
|
||||
let str_array_val = counter "el" . array_start . ( str_array_element . ( array_sep . str_array_element ) * ) ? . array_end
|
||||
|
||||
let str_entry (kw:string) = [ key kw . value_sep . str_val ]
|
||||
let bool_entry (kw:string) = [ key kw . value_sep . bool_val ]
|
||||
let int_entry (kw:string) = [ key kw . value_sep . int_val ]
|
||||
let str_array_entry (kw:string) = [ key kw . value_sep . str_array_val ]
|
||||
|
||||
|
||||
(* Config entry grouped by function - same order as example config *)
|
||||
let logging_entry = int_entry "log_level"
|
||||
| str_entry "log_filters"
|
||||
| str_entry "log_outputs"
|
||||
| int_entry "log_buffer_size"
|
||||
| int_entry "max_clients"
|
||||
|
||||
(* Each enty in the config is one of the following three ... *)
|
||||
let entry = logging_entry
|
||||
let comment = [ label "#comment" . del /#[ \t]*/ "# " . store /([^ \t\n][^\n]*)?/ . del /\n/ "\n" ]
|
||||
let empty = [ label "#empty" . eol ]
|
||||
|
||||
let record = indent . entry . eol
|
||||
|
||||
let lns = ( record | comment | empty ) *
|
||||
|
||||
let filter = incl "/etc/libvirt/virtlogd.conf"
|
||||
. Util.stdexcl
|
||||
|
||||
let xfm = transform lns filter
|
||||
@@ -0,0 +1,59 @@
|
||||
# Master virtlogd daemon configuration file
|
||||
#
|
||||
|
||||
#################################################################
|
||||
#
|
||||
# Logging controls
|
||||
#
|
||||
|
||||
# Logging level: 4 errors, 3 warnings, 2 information, 1 debug
|
||||
# basically 1 will log everything possible
|
||||
#log_level = 3
|
||||
|
||||
# Logging filters:
|
||||
# A filter allows to select a different logging level for a given category
|
||||
# of logs
|
||||
# The format for a filter is one of:
|
||||
# x:name
|
||||
# x:+name
|
||||
# where name is a string which is matched against source file name,
|
||||
# e.g., "remote", "qemu", or "util/json", the optional "+" prefix
|
||||
# tells libvirt to log stack trace for each message matching name,
|
||||
# and x is the minimal level where matching messages should be logged:
|
||||
# 1: DEBUG
|
||||
# 2: INFO
|
||||
# 3: WARNING
|
||||
# 4: ERROR
|
||||
#
|
||||
# Multiple filter can be defined in a single @filters, they just need to be
|
||||
# separated by spaces.
|
||||
#
|
||||
# e.g. to only get warning or errors from the remote layer and only errors
|
||||
# from the event layer:
|
||||
#log_filters="3:remote 4:event"
|
||||
|
||||
# Logging outputs:
|
||||
# An output is one of the places to save logging information
|
||||
# The format for an output can be:
|
||||
# x:stderr
|
||||
# output goes to stderr
|
||||
# x:syslog:name
|
||||
# use syslog for the output and use the given name as the ident
|
||||
# x:file:file_path
|
||||
# output to a file, with the given filepath
|
||||
# x:journald
|
||||
# ouput to the systemd journal
|
||||
# In all case the x prefix is the minimal level, acting as a filter
|
||||
# 1: DEBUG
|
||||
# 2: INFO
|
||||
# 3: WARNING
|
||||
# 4: ERROR
|
||||
#
|
||||
# Multiple output can be defined, they just need to be separated by spaces.
|
||||
# e.g. to log all warnings and errors to syslog under the virtlogd ident:
|
||||
#log_outputs="3:syslog:virtlogd"
|
||||
#
|
||||
|
||||
# The maximum number of concurrent client connections to allow
|
||||
# over all sockets combined.
|
||||
#max_clients = 1024
|
||||
@@ -0,0 +1,94 @@
|
||||
#!/bin/sh
|
||||
|
||||
# the following is the LSB init header see
|
||||
# http://www.linux-foundation.org/spec//booksets/LSB-Core-generic/LSB-Core-generic.html#INITSCRCOMCONV
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: virtlogd
|
||||
# Default-Start:
|
||||
# Default-Stop: 0 1 2 3 4 5 6
|
||||
# Short-Description: virtual machine log manager
|
||||
# Description: This is a daemon for managing logs
|
||||
# of virtual machine consoles
|
||||
### END INIT INFO
|
||||
|
||||
# the following is chkconfig init header
|
||||
#
|
||||
# virtlogd: virtual machine log manager
|
||||
#
|
||||
# chkconfig: - 96 04
|
||||
# description: This is a daemon for managing logs \
|
||||
# of virtual machine consoles
|
||||
#
|
||||
# processname: virtlogd
|
||||
# pidfile: @localstatedir@/run/virtlogd.pid
|
||||
#
|
||||
|
||||
# Source function library.
|
||||
. @sysconfdir@/rc.d/init.d/functions
|
||||
|
||||
SERVICE=virtlogd
|
||||
PROCESS=virtlogd
|
||||
PIDFILE=@localstatedir@/run/$SERVICE.pid
|
||||
|
||||
VIRTLOGD_ARGS=
|
||||
|
||||
test -f @sysconfdir@/sysconfig/virtlogd && . @sysconfdir@/sysconfig/virtlogd
|
||||
|
||||
RETVAL=0
|
||||
|
||||
start() {
|
||||
echo -n $"Starting $SERVICE daemon: "
|
||||
daemon --pidfile $PIDFILE --check $SERVICE $PROCESS --daemon $VIRTLOGD_ARGS
|
||||
RETVAL=$?
|
||||
echo
|
||||
[ $RETVAL -eq 0 ] && touch @localstatedir@/log/subsys/$SERVICE
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo -n $"Stopping $SERVICE daemon: "
|
||||
|
||||
killproc -p $PIDFILE $PROCESS
|
||||
RETVAL=$?
|
||||
echo
|
||||
if [ $RETVAL -eq 0 ]; then
|
||||
rm -f @localstatedir@/log/subsys/$SERVICE
|
||||
rm -f $PIDFILE
|
||||
fi
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
reload() {
|
||||
echo -n $"Reloading $SERVICE configuration: "
|
||||
|
||||
killproc -p $PIDFILE $PROCESS -USR1
|
||||
RETVAL=$?
|
||||
echo
|
||||
return $RETVAL
|
||||
}
|
||||
|
||||
# See how we were called.
|
||||
case "$1" in
|
||||
start|stop|restart|reload)
|
||||
$1
|
||||
;;
|
||||
status)
|
||||
status -p $PIDFILE $PROCESS
|
||||
RETVAL=$?
|
||||
;;
|
||||
force-reload)
|
||||
reload
|
||||
;;
|
||||
condrestart|try-restart)
|
||||
[ -f @localstatedir@/log/subsys/$SERVICE ] && restart || :
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|force-reload|try-restart}"
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
exit $RETVAL
|
||||
@@ -0,0 +1,167 @@
|
||||
=head1 NAME
|
||||
|
||||
virtlogd - libvirt log management daemon
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
B<virtlogd> [ -dvV ] [-t timeout] [ -f config_file ] [ -p pid_file ]
|
||||
|
||||
B<virtlogd> --version
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
The B<virtlogd> program is a server side daemon component of the libvirt
|
||||
virtualization management system that is used to manage logs from virtual
|
||||
machine consoles.
|
||||
|
||||
This daemon is not used directly by libvirt client applications, rather it
|
||||
is called on their behalf by B<libvirtd>. By maintaining the logs in a
|
||||
standalone daemon, the main libvirtd daemon can be restarted without risk
|
||||
of losing logs. The B<virtlogd> daemon has the ability to re-exec()
|
||||
itself upon receiving SIGUSR1, to allow live upgrades without downtime.
|
||||
|
||||
The virtlogd daemon listens for requests on a local Unix domain socket.
|
||||
|
||||
=head1 OPTIONS
|
||||
|
||||
=over
|
||||
|
||||
=item B<-h, --help>
|
||||
|
||||
Display command line help usage then exit.
|
||||
|
||||
=item B<-d, --daemon>
|
||||
|
||||
Run as a daemon and write PID file.
|
||||
|
||||
=item B<-f, --config> I<FILE>
|
||||
|
||||
Use this configuration file, overriding the default value.
|
||||
|
||||
=item B<-t, --timeout> I<SECONDS>
|
||||
|
||||
Automatically shutdown after I<SECONDS> have elapsed with
|
||||
no active console log.
|
||||
|
||||
=item B<-p, --pid-file> I<FILE>
|
||||
|
||||
Use this name for the PID file, overriding the default value.
|
||||
|
||||
=item B<-v, --verbose>
|
||||
|
||||
Enable output of verbose messages.
|
||||
|
||||
=item B<-V, --version>
|
||||
|
||||
Display version information then exit.
|
||||
|
||||
=back
|
||||
|
||||
=head1 SIGNALS
|
||||
|
||||
On receipt of B<SIGUSR1> virtlogd will re-exec() its binary, while
|
||||
maintaining all current logs and clients. This allows for live
|
||||
upgrades of the virtlogd service.
|
||||
|
||||
=head1 FILES
|
||||
|
||||
=head2 When run as B<root>.
|
||||
|
||||
=over
|
||||
|
||||
=item F<SYSCONFDIR/virtlogd.conf>
|
||||
|
||||
The default configuration file used by virtlogd, unless overridden on the
|
||||
command line using the B<-f>|B<--config> option.
|
||||
|
||||
=item F<LOCALSTATEDIR/run/libvirt/virtlogd-sock>
|
||||
|
||||
The sockets libvirtd will use.
|
||||
|
||||
=item F<LOCALSTATEDIR/run/virtlogd.pid>
|
||||
|
||||
The PID file to use, unless overridden by the B<-p>|B<--pid-file> option.
|
||||
|
||||
=back
|
||||
|
||||
=head2 When run as B<non-root>.
|
||||
|
||||
=over
|
||||
|
||||
=item F<$XDG_CONFIG_HOME/virtlogd.conf>
|
||||
|
||||
The default configuration file used by libvirtd, unless overridden on the
|
||||
command line using the B<-f>|B<--config> option.
|
||||
|
||||
=item F<$XDG_RUNTIME_DIR/libvirt/virtlogd-sock>
|
||||
|
||||
The socket libvirtd will use.
|
||||
|
||||
=item F<$XDG_RUNTIME_DIR/libvirt/virtlogd.pid>
|
||||
|
||||
The PID file to use, unless overridden by the B<-p>|B<--pid-file> option.
|
||||
|
||||
=item If $XDG_CONFIG_HOME is not set in your environment, libvirtd will use F<$HOME/.config>
|
||||
|
||||
=item If $XDG_RUNTIME_DIR is not set in your environment, libvirtd will use F<$HOME/.cache>
|
||||
|
||||
=back
|
||||
|
||||
=head1 EXAMPLES
|
||||
|
||||
To retrieve the version of virtlogd:
|
||||
|
||||
# virtlogd --version
|
||||
virtlogd (libvirt) 1.1.1
|
||||
#
|
||||
|
||||
To start virtlogd, instructing it to daemonize and create a PID file:
|
||||
|
||||
# virtlogd -d
|
||||
# ls -la LOCALSTATEDIR/run/virtlogd.pid
|
||||
-rw-r--r-- 1 root root 6 Jul 9 02:40 LOCALSTATEDIR/run/virtlogd.pid
|
||||
#
|
||||
|
||||
=head1 BUGS
|
||||
|
||||
Please report all bugs you discover. This should be done via either:
|
||||
|
||||
=over
|
||||
|
||||
=item a) the mailing list
|
||||
|
||||
L<http://libvirt.org/contact.html>
|
||||
|
||||
=item or,
|
||||
|
||||
B<>
|
||||
|
||||
=item b) the bug tracker
|
||||
|
||||
L<http://libvirt.org/bugs.html>
|
||||
|
||||
=item Alternatively, you may report bugs to your software distributor / vendor.
|
||||
|
||||
=back
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
Please refer to the AUTHORS file distributed with libvirt.
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
Copyright (C) 2006-2015 Red Hat, Inc., and the authors listed in the
|
||||
libvirt AUTHORS file.
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
virtlogd is distributed under the terms of the GNU LGPL v2.1+.
|
||||
This is free software; see the source for copying conditions. There
|
||||
is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
PURPOSE
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
L<libvirtd(8)>, L<http://www.libvirt.org/>
|
||||
|
||||
=cut
|
||||
@@ -0,0 +1,17 @@
|
||||
[Unit]
|
||||
Description=Virtual machine log manager
|
||||
Requires=virtlogd.socket
|
||||
Documentation=man:virtlogd(8)
|
||||
Documentation=http://libvirt.org
|
||||
|
||||
[Service]
|
||||
EnvironmentFile=-/etc/sysconfig/virtlogd
|
||||
ExecStart=@sbindir@/virtlogd $VIRTLOGD_ARGS
|
||||
ExecReload=/bin/kill -USR1 $MAINPID
|
||||
# Loosing the logs is a really bad thing that will
|
||||
# cause the machine to be fenced (rebooted), so make
|
||||
# sure we discourage OOM killer
|
||||
OOMScoreAdjust=-900
|
||||
|
||||
[Install]
|
||||
Also=virtlogd.socket
|
||||
@@ -0,0 +1,8 @@
|
||||
[Unit]
|
||||
Description=Virtual machine log manager socket
|
||||
|
||||
[Socket]
|
||||
ListenStream=@localstatedir@/run/libvirt/virtlogd-sock
|
||||
|
||||
[Install]
|
||||
WantedBy=sockets.target
|
||||
@@ -0,0 +1,3 @@
|
||||
#
|
||||
# Pass extra arguments to virtlogd
|
||||
#VIRTLOGD_ARGS=
|
||||
Reference in New Issue
Block a user