From: Sasha Levin <levinsasha928@gmail.com>
To: Pekka Enberg <penberg@kernel.org>
Cc: kvm@vger.kernel.org, mingo@elte.hu, asias.hejun@gmail.com,
gorcunov@gmail.com
Subject: Re: [PATCH 1/3] kvm tools: Make keyboard termination go through regular termination path
Date: Thu, 11 Aug 2011 16:41:26 +0300 [thread overview]
Message-ID: <1313070086.3456.17.camel@lappy> (raw)
In-Reply-To: <alpine.DEB.2.00.1108111638060.2531@tiger>
On Thu, 2011-08-11 at 16:39 +0300, Pekka Enberg wrote:
> On Thu, 11 Aug 2011, Sasha Levin wrote:
> > Instead of exiting directly when a user enters 'ctrl x + a', go through
> > the regular termination path by stopping all VCPUs and letting the
> > main thread handle it.
> >
> > Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
> > ---
> > tools/kvm/builtin-run.c | 9 +++++----
> > tools/kvm/kvm-cpu.c | 8 ++++++--
> > tools/kvm/term.c | 6 +-----
> > 3 files changed, 12 insertions(+), 11 deletions(-)
> >
> > diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c
> > index fa5de27..c7ed3fa 100644
> > --- a/tools/kvm/builtin-run.c
> > +++ b/tools/kvm/builtin-run.c
> > @@ -719,10 +719,11 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix)
> > exit_code = 1;
> >
> > for (i = 1; i < nrcpus; i++) {
> > - pthread_kill(kvm_cpus[i]->thread, SIGKVMEXIT);
> > - if (pthread_join(kvm_cpus[i]->thread, &ret) != 0)
> > - die("pthread_join");
> > -
> > + if (kvm_cpus[i]->is_running) {
> > + pthread_kill(kvm_cpus[i]->thread, SIGKVMEXIT);
> > + if (pthread_join(kvm_cpus[i]->thread, &ret) != 0)
> > + die("pthread_join");
> > + }
> > if (ret != NULL)
> > exit_code = 1;
> > }
> > diff --git a/tools/kvm/kvm-cpu.c b/tools/kvm/kvm-cpu.c
> > index 2f5d23c..fc0d6d4 100644
> > --- a/tools/kvm/kvm-cpu.c
> > +++ b/tools/kvm/kvm-cpu.c
> > @@ -421,7 +421,11 @@ static void kvm_cpu__handle_coalesced_mmio(struct kvm_cpu *cpu)
> >
> > void kvm_cpu__reboot(void)
> > {
> > - pthread_kill(kvm_cpus[0]->thread, SIGKVMEXIT);
> > + int i;
> > +
> > + for (i = 0; i < KVM_NR_CPUS; i++)
> > + if (kvm_cpus[i])
> > + pthread_kill(kvm_cpus[i]->thread, SIGKVMEXIT);
> > }
> >
> > int kvm_cpu__start(struct kvm_cpu *cpu)
> > @@ -442,7 +446,7 @@ int kvm_cpu__start(struct kvm_cpu *cpu)
> > if (cpu->kvm->single_step)
> > kvm_cpu__enable_singlestep(cpu);
> >
> > - for (;;) {
> > + while (cpu->is_running) {
> > if (cpu->paused) {
> > kvm__notify_paused();
> > cpu->paused = 0;
> > diff --git a/tools/kvm/term.c b/tools/kvm/term.c
> > index 2a3e1f0..fa4382d 100644
> > --- a/tools/kvm/term.c
> > +++ b/tools/kvm/term.c
> > @@ -34,12 +34,8 @@ int term_getc(int who)
> >
> > if (term_got_escape) {
> > term_got_escape = false;
> > - if (c == 'x') {
> > + if (c == 'x')
> > kvm_cpu__reboot();
> > - kvm__delete(kvm);
> > - printf("\n # KVM session terminated.\n");
>
> This is a nice cleanup but I'm not happy about the fact that you also nuke
> the above printf(). Is there a simple way to keep it there?
>
You get that printf from the normal exit path.
> > - exit(1);
> > - }
> > if (c == term_escape_char)
> > return c;
> > }
> > --
> > 1.7.6
> >
> >
--
Sasha.
next prev parent reply other threads:[~2011-08-11 13:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-11 12:43 [PATCH 1/3] kvm tools: Make keyboard termination go through regular termination path Sasha Levin
2011-08-11 12:43 ` [PATCH 2/3] kvm tools: Add kvm__trigger_irq() Sasha Levin
2011-08-11 12:43 ` [PATCH 3/3] kvm tools: Add MSI-X support to virtio-net Sasha Levin
2011-08-11 13:33 ` [PATCH 1/3] kvm tools: Make keyboard termination go through regular termination path walimis
2011-08-11 13:39 ` Pekka Enberg
2011-08-11 13:41 ` Sasha Levin [this message]
2011-08-11 13:47 ` Pekka Enberg
2011-08-11 13:48 ` Sasha Levin
2011-08-11 14:04 ` Pekka Enberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1313070086.3456.17.camel@lappy \
--to=levinsasha928@gmail.com \
--cc=asias.hejun@gmail.com \
--cc=gorcunov@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=penberg@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox