提交 d5b4130a 编写于 作者: J Jiri Olsa 提交者: Arnaldo Carvalho de Melo

perf kvm: Fix stdin handling for 'kvm stat live' command

Currently the initial ~(ICANON | ECHO) terminal mode is not set, so we
dont get stdin data until we press ENTER.

Fixing this by early setting of the ~(ICANON | ECHO) mode and leaving
this mode for whole life of the command, because canonical mode is not
needed.
Signed-off-by: NJiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jean Pihet <jean.pihet@linaro.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1407747014-18394-16-git-send-email-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 4a1a9971
...@@ -885,15 +885,11 @@ static int fd_set_nonblock(int fd) ...@@ -885,15 +885,11 @@ static int fd_set_nonblock(int fd)
return 0; return 0;
} }
static static int perf_kvm__handle_stdin(void)
int perf_kvm__handle_stdin(struct termios *tc_now, struct termios *tc_save)
{ {
int c; int c;
tcsetattr(0, TCSANOW, tc_now);
c = getc(stdin); c = getc(stdin);
tcsetattr(0, TCSAFLUSH, tc_save);
if (c == 'q') if (c == 'q')
return 1; return 1;
...@@ -904,7 +900,7 @@ static int kvm_events_live_report(struct perf_kvm_stat *kvm) ...@@ -904,7 +900,7 @@ static int kvm_events_live_report(struct perf_kvm_stat *kvm)
{ {
struct pollfd *pollfds = NULL; struct pollfd *pollfds = NULL;
int nr_fds, nr_stdin, ret, err = -EINVAL; int nr_fds, nr_stdin, ret, err = -EINVAL;
struct termios tc, save; struct termios save;
/* live flag must be set first */ /* live flag must be set first */
kvm->live = true; kvm->live = true;
...@@ -919,14 +915,9 @@ static int kvm_events_live_report(struct perf_kvm_stat *kvm) ...@@ -919,14 +915,9 @@ static int kvm_events_live_report(struct perf_kvm_stat *kvm)
goto out; goto out;
} }
set_term_quiet_input(&save);
init_kvm_event_record(kvm); init_kvm_event_record(kvm);
tcgetattr(0, &save);
tc = save;
tc.c_lflag &= ~(ICANON | ECHO);
tc.c_cc[VMIN] = 0;
tc.c_cc[VTIME] = 0;
signal(SIGINT, sig_handler); signal(SIGINT, sig_handler);
signal(SIGTERM, sig_handler); signal(SIGTERM, sig_handler);
...@@ -972,7 +963,7 @@ static int kvm_events_live_report(struct perf_kvm_stat *kvm) ...@@ -972,7 +963,7 @@ static int kvm_events_live_report(struct perf_kvm_stat *kvm)
goto out; goto out;
if (pollfds[nr_stdin].revents & POLLIN) if (pollfds[nr_stdin].revents & POLLIN)
done = perf_kvm__handle_stdin(&tc, &save); done = perf_kvm__handle_stdin();
if (!rc && !done) if (!rc && !done)
err = poll(pollfds, nr_fds, 100); err = poll(pollfds, nr_fds, 100);
...@@ -989,6 +980,7 @@ static int kvm_events_live_report(struct perf_kvm_stat *kvm) ...@@ -989,6 +980,7 @@ static int kvm_events_live_report(struct perf_kvm_stat *kvm)
if (kvm->timerfd >= 0) if (kvm->timerfd >= 0)
close(kvm->timerfd); close(kvm->timerfd);
tcsetattr(0, TCSAFLUSH, &save);
free(pollfds); free(pollfds);
return err; return err;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册