%if ! %{with_qemu}
rm -rf $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/qemu.conf
%endif
+%if ! %{with_lxc}
+rm -rf $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/lxc.conf
+%endif
%if %{with_libvirtd}
chmod 0644 $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/libvirtd
%if %{with_qemu}
%config(noreplace) %{_sysconfdir}/libvirt/qemu.conf
%endif
+%if %{with_lxc}
+%config(noreplace) %{_sysconfdir}/libvirt/lxc.conf
+%endif
%dir %{_datadir}/libvirt/
moddir = $(libdir)/libvirt/drivers
mod_LTLIBRARIES =
+confdir = $(sysconfdir)/libvirt
+conf_DATA =
# These files are not related to driver APIs. Simply generic
# helper APIs for various purposes
endif
libvirt_driver_qemu_la_SOURCES = $(QEMU_DRIVER_SOURCES)
-confdir = $(sysconfdir)/libvirt/
-conf_DATA = qemu/qemu.conf
+conf_DATA += qemu/qemu.conf
augeasdir = $(datadir)/augeas/lenses
augeas_DATA = qemu/libvirtd_qemu.aug
libvirt_driver_lxc_la_LDFLAGS = -module -avoid-version
endif
libvirt_driver_lxc_la_SOURCES = $(LXC_DRIVER_SOURCES)
+
+conf_DATA += lxc/lxc.conf
+
endif
+EXTRA_DIST += lxc/lxc.conf
if WITH_UML
if WITH_DRIVER_MODULES
--- /dev/null
+# Master configuration file for the LXC driver.
+# All settings described here are optional - if omitted, sensible
+# defaults are used.
+
+# By default, log messages generated by the lxc controller go to the
+# container logfile. It is also possible to accumulate log messages
+# from all lxc controllers along with libvirtd's log outputs. In this
+# case, the lxc controller will honor either LIBVIRT_LOG_OUTPUTS or
+# log_outputs from libvirtd.conf.
+#
+# This is disabled by default, uncomment below to enable it.
+#
+# log_with_libvirtd = 1
#include "lxc_conf.h"
#include "nodeinfo.h"
#include "virterror_internal.h"
+#include "conf.h"
#include "logging.h"
int lxcLoadDriverConfig(lxc_driver_t *driver)
{
+ char *filename;
+ virConfPtr conf;
+ virConfValuePtr p;
+
/* Set the container configuration directory */
if ((driver->configDir = strdup(LXC_CONFIG_DIR)) == NULL)
goto no_memory;
if ((driver->logDir = strdup(LXC_LOG_DIR)) == NULL)
goto no_memory;
+ if ((filename = strdup(SYSCONF_DIR "/libvirt/lxc.conf")) == NULL)
+ goto no_memory;
+
+ /* Avoid error from non-existant or unreadable file. */
+ if (access (filename, R_OK) == -1)
+ return 0;
+ conf = virConfReadFile(filename, 0);
+ if (!conf)
+ return 0;
+
+ p = virConfGetValue(conf, "log_with_libvirtd");
+ if (p) {
+ if (p->type != VIR_CONF_LONG)
+ VIR_WARN0("lxcLoadDriverConfig: invalid setting: log_with_libvirtd");
+ else
+ driver->log_libvirtd = p->l;
+ }
+
+ virConfFree(conf);
return 0;
no_memory:
char *autostartDir;
char *stateDir;
char *logDir;
+ int log_libvirtd;
int have_netns;
/* An array of callbacks */
char *filterstr;
char *outputstr;
char *tmp;
+ int log_level;
pid_t child;
int status;
fd_set keepfd;
char appPtyStr[30];
const char *emulator;
+ lxc_driver_t *driver = conn->privateData;
FD_ZERO(&keepfd);
lenv[lenvc++] = envval; \
} while (0)
- if (virAsprintf(&tmp, "LIBVIRT_DEBUG=%d", virLogGetDefaultPriority()) < 0)
+ log_level = virLogGetDefaultPriority();
+ if (virAsprintf(&tmp, "LIBVIRT_DEBUG=%d", log_level) < 0)
goto no_memory;
ADD_ENV(tmp);
VIR_FREE(filterstr);
}
- if (virLogGetNbOutputs() > 0) {
- outputstr = virLogGetOutputs();
- if (!outputstr)
+ if (driver->log_libvirtd) {
+ if (virLogGetNbOutputs() > 0) {
+ outputstr = virLogGetOutputs();
+ if (!outputstr)
+ goto no_memory;
+ ADD_ENV_PAIR("LIBVIRT_LOG_OUTPUTS", outputstr);
+ VIR_FREE(outputstr);
+ }
+ } else {
+ if (virAsprintf(&tmp, "LIBVIRT_LOG_OUTPUTS=%d:stderr", log_level) < 0)
goto no_memory;
- ADD_ENV_PAIR("LIBVIRT_LOG_OUTPUTS", outputstr);
- VIR_FREE(outputstr);
+ ADD_ENV(tmp);
}
ADD_ENV(NULL);
virEventAddTimeout(-1, lxcDomainEventFlush, lxc_driver, NULL)) < 0)
goto cleanup;
+ lxc_driver->log_libvirtd = 0; /* by default log to container logfile */
lxc_driver->have_netns = lxcCheckNetNsSupport();
rc = virCgroupForDriver("lxc", &lxc_driver->cgroup, privileged, 1);