mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 09:55:18 +00:00
lxc: driver: Improve logging when launching emulator
Log the full command line and a timestamp like we do for QEMU
This commit is contained in:
parent
451cfd05a2
commit
924eb9a4b4
@ -56,6 +56,8 @@
|
|||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_LXC
|
#define VIR_FROM_THIS VIR_FROM_LXC
|
||||||
|
|
||||||
|
#define START_POSTFIX ": starting up\n"
|
||||||
|
|
||||||
#define LXC_NB_MEM_PARAM 3
|
#define LXC_NB_MEM_PARAM 3
|
||||||
|
|
||||||
typedef struct _lxcDomainObjPrivate lxcDomainObjPrivate;
|
typedef struct _lxcDomainObjPrivate lxcDomainObjPrivate;
|
||||||
@ -1254,6 +1256,9 @@ static int lxcControllerStart(lxc_driver_t *driver,
|
|||||||
char *filterstr;
|
char *filterstr;
|
||||||
char *outputstr;
|
char *outputstr;
|
||||||
virCommandPtr cmd;
|
virCommandPtr cmd;
|
||||||
|
off_t pos = -1;
|
||||||
|
char ebuf[1024];
|
||||||
|
char *timestamp;
|
||||||
|
|
||||||
cmd = virCommandNew(vm->def->emulator);
|
cmd = virCommandNew(vm->def->emulator);
|
||||||
|
|
||||||
@ -1315,6 +1320,24 @@ static int lxcControllerStart(lxc_driver_t *driver,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Log timestamp */
|
||||||
|
if ((timestamp = virTimestamp()) == NULL) {
|
||||||
|
virReportOOMError();
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
if (safewrite(logfile, timestamp, strlen(timestamp)) < 0 ||
|
||||||
|
safewrite(logfile, START_POSTFIX, strlen(START_POSTFIX)) < 0) {
|
||||||
|
VIR_WARN("Unable to write timestamp to logfile: %s",
|
||||||
|
virStrerror(errno, ebuf, sizeof ebuf));
|
||||||
|
}
|
||||||
|
VIR_FREE(timestamp);
|
||||||
|
|
||||||
|
/* Log generated command line */
|
||||||
|
virCommandWriteArgLog(cmd, logfile);
|
||||||
|
if ((pos = lseek(logfile, 0, SEEK_END)) < 0)
|
||||||
|
VIR_WARN("Unable to seek to end of logfile: %s",
|
||||||
|
virStrerror(errno, ebuf, sizeof ebuf));
|
||||||
|
|
||||||
virCommandPreserveFD(cmd, appPty);
|
virCommandPreserveFD(cmd, appPty);
|
||||||
virCommandSetOutputFD(cmd, &logfile);
|
virCommandSetOutputFD(cmd, &logfile);
|
||||||
virCommandSetErrorFD(cmd, &logfile);
|
virCommandSetErrorFD(cmd, &logfile);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user