Skip to content

Commit d49a6f6

Browse files
lyan3lijinxia
authored andcommitted
capture acrnd AaaG booting messages to journald
It's for AaaG boot time measurement only. Tracked-On: #1759 Signed-off-by: Yan, Like <like.yan@intel.com> Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
1 parent c4161c8 commit d49a6f6

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

tools/acrn-manager/acrnd.c

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -215,20 +215,16 @@ static int load_timer_list(void)
215215
return ret;
216216
}
217217

218-
#define ACRND_LOG_FMT "/opt/acrn/%s.log"
218+
static int logfile = 1;
219219

220220
static void acrnd_run_vm(char *name)
221221
{
222-
char log_path[128] = {};
223-
224-
if (snprintf(log_path, sizeof(log_path) -1, ACRND_LOG_FMT, name)
225-
>= sizeof(log_path) -1) {
226-
printf("WARN: log path is truncated\n");
227-
} else {
228-
unlink(log_path);
229-
stdin = freopen(log_path, "w+", stdin);
230-
stdout = freopen(log_path, "w+", stdout);
231-
stderr = freopen(log_path, "w+", stderr);
222+
/*If do not use logfile, then output to stdout,
223+
so that it can be redirected to journal by systemd */
224+
if (logfile) {
225+
stdin = freopen("/dev/null", "r+", stdin);
226+
stdout = freopen("/dev/null", "r+", stdout);
227+
stderr = freopen("/dev/null", "r+", stderr);
232228
fflush(stdin);
233229
fflush(stdout);
234230
fflush(stderr);
@@ -653,8 +649,22 @@ static void sigterm_handler(int signo)
653649
sigterm = 1;
654650
}
655651

652+
static const char optString[] = "t";
653+
656654
int main(int argc, char *argv[])
657655
{
656+
int opt;
657+
658+
while ((opt = getopt(argc, argv, optString)) != -1) {
659+
switch (opt) {
660+
case 't':
661+
logfile = 0;
662+
break;
663+
default:
664+
printf("Ingrone unknown opt: %c\n", opt);
665+
}
666+
}
667+
658668
/* create listening thread */
659669
acrnd_fd = mngr_open_un(ACRND_NAME, MNGR_SERVER);
660670
if (acrnd_fd < 0) {

tools/acrn-manager/acrnd.service

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ ConditionPathExists=/dev/acrn_vhm
77

88
[Service]
99
Type=simple
10-
ExecStart=/usr/bin/acrnd
10+
ExecStart=/usr/bin/acrnd -t
11+
StandardOutput=journal
12+
StandardError=journal
1113

1214
[Install]
1315
WantedBy=multi-user.target
14-

0 commit comments

Comments
 (0)