}
virCHMonitor *
-virCHMonitorNew(virDomainObj *vm, virCHDriverConfig *cfg)
+virCHMonitorNew(virDomainObj *vm, virCHDriverConfig *cfg, int logfile)
{
g_autoptr(virCHMonitor) mon = NULL;
g_autoptr(virCommand) cmd = NULL;
}
cmd = virCommandNew(vm->def->emulator);
+ virCommandSetOutputFD(cmd, &logfile);
+ virCommandSetErrorFD(cmd, &logfile);
+ virCommandNonblockingFDs(cmd);
virCommandSetUmask(cmd, 0x002);
socket_fd = chMonitorCreateSocket(mon->socketpath);
if (socket_fd < 0) {
#include "ch_process.h"
#include "domain_cgroup.h"
#include "domain_interface.h"
+#include "domain_logcontext.h"
#include "viralloc.h"
#include "virerror.h"
#include "virfile.h"
static virCHMonitor *
virCHProcessConnectMonitor(virCHDriver *driver,
- virDomainObj *vm)
+ virDomainObj *vm,
+ int logfile)
{
virCHMonitor *monitor = NULL;
virCHDriverConfig *cfg = virCHDriverGetConfig(driver);
- monitor = virCHMonitorNew(vm, cfg);
+ monitor = virCHMonitorNew(vm, cfg, logfile);
virObjectUnref(cfg);
return monitor;
g_autoptr(virCHDriverConfig) cfg = virCHDriverGetConfig(priv->driver);
g_autofree int *nicindexes = NULL;
size_t nnicindexes = 0;
+ g_autoptr(domainLogContext) logCtxt = NULL;
+ int logfile = -1;
if (virDomainObjIsActive(vm)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
return -1;
}
+ VIR_DEBUG("Creating domain log file for %s domain", vm->def->name);
+ if (!(logCtxt = domainLogContextNew(cfg->stdioLogD, cfg->logDir,
+ CH_DRIVER_NAME,
+ vm, driver->privileged,
+ vm->def->name))) {
+ virLastErrorPrefixMessage("%s", _("can't connect to virtlogd"));
+ return -1;
+ }
+ logfile = domainLogContextGetWriteFD(logCtxt);
+
if (virCHProcessPrepareDomain(vm) < 0) {
return -1;
}
if (!priv->monitor) {
/* And we can get the first monitor connection now too */
- if (!(priv->monitor = virCHProcessConnectMonitor(driver, vm))) {
+ if (!(priv->monitor = virCHProcessConnectMonitor(driver, vm, logfile))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to create connection to CH socket"));
goto cleanup;
size_t ntapfds = 0;
size_t nnicindexes = 0;
int ret = -1;
+ g_autoptr(domainLogContext) logCtxt = NULL;
+ int logfile = -1;
+
+ VIR_DEBUG("Creating domain log file for %s domain", vm->def->name);
+ if (!(logCtxt = domainLogContextNew(cfg->stdioLogD, cfg->logDir,
+ CH_DRIVER_NAME,
+ vm, driver->privileged,
+ vm->def->name))) {
+ virLastErrorPrefixMessage("%s", _("can't connect to virtlogd"));
+ return -1;
+ }
+ logfile = domainLogContextGetWriteFD(logCtxt);
if (!priv->monitor) {
/* Get the first monitor connection if not already */
- if (!(priv->monitor = virCHProcessConnectMonitor(driver, vm))) {
+ if (!(priv->monitor = virCHProcessConnectMonitor(driver, vm, logfile))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("failed to create connection to CH socket"));
goto cleanup;