qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: pkrempa@redhat.com, lersek@redhat.com, marcel.a@redhat.com,
	libvir-list@redhat.com, Hu Tao <hutao@cn.fujitsu.com>,
	qemu-devel@nongnu.org, armbru@redhat.com, rhod@redhat.com,
	kraxel@redhat.com, anthony@codemonkey.ws, lcapitulino@redhat.com,
	afaerber@suse.de
Subject: Re: [Qemu-devel] pvpanic plans?
Date: Thu, 31 Oct 2013 18:48:28 +0200	[thread overview]
Message-ID: <20131031164828.GA10862@redhat.com> (raw)
In-Reply-To: <52728790.7010404@redhat.com>

On Thu, Oct 31, 2013 at 05:38:40PM +0100, Paolo Bonzini wrote:
> Il 31/10/2013 17:26, Michael S. Tsirkin ha scritto:
> > On Thu, Oct 31, 2013 at 05:17:24PM +0100, Paolo Bonzini wrote:
> >> Il 31/10/2013 17:14, Michael S. Tsirkin ha scritto:
> >>>> PANICKED->DEBUG was added by commit bc7d0e667.  That commit can be
> >>>> reverted if the panicked state is removed from runstate_needs_reset.
> >>>
> >>> Okay so let's drop the code duplication and explicitly make
> >>> them the same?
> >>>
> >>> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> >>>
> >>>
> >>> diff --git a/vl.c b/vl.c
> >>> index 46c29c4..e12d317 100644
> >>> --- a/vl.c
> >>> +++ b/vl.c
> >>> @@ -638,10 +638,6 @@ static const RunStateTransition runstate_transitions_def[] = {
> >>>      { RUN_STATE_WATCHDOG, RUN_STATE_RUNNING },
> >>>      { RUN_STATE_WATCHDOG, RUN_STATE_FINISH_MIGRATE },
> >>>  
> >>> -    { RUN_STATE_GUEST_PANICKED, RUN_STATE_PAUSED },
> >>> -    { RUN_STATE_GUEST_PANICKED, RUN_STATE_FINISH_MIGRATE },
> >>> -    { RUN_STATE_GUEST_PANICKED, RUN_STATE_DEBUG },
> >>> -
> >>>      { RUN_STATE_MAX, RUN_STATE_MAX },
> >>>  };
> >>>  
> >>> @@ -660,6 +656,12 @@ static void runstate_init(void)
> >>>  
> >>>      for (p = &runstate_transitions_def[0]; p->from != RUN_STATE_MAX; p++) {
> >>>          runstate_valid_transitions[p->from][p->to] = true;
> >>> +        /* Panicked state is same as paused, we only made it different so
> >>> +         * management can detect a panic.
> >>> +         */
> >>> +        if (p->from == RUN_STATE_PAUSED) {
> >>> +            runstate_valid_transitions[RUN_STATE_GUEST_PANICKED][p->to] = true;
> >>
> >> It makes only sense to me if you do that for IO_ERROR and WATCHDOG as
> >> well, and perhaps there are others I'm missing.  Just add a comment
> >> before runstate_transitions_def's entries for PANICKED, IO_ERROR and
> >> WATCHDOG.
> >>
> >> But again, it is somewhat separate from the issue at hand, which is to
> >> finally make pvpanic usable and hopefully before 1.7.
> >>
> >> Paolo
> > 
> > The issue is that you can't continue from panicked state.
> > You should be able to do that without going through paused.
> 
> Yes, that's what my patch (posted the link before) does:
> 
> -    { RUN_STATE_GUEST_PANICKED, RUN_STATE_PAUSED },
> +    { RUN_STATE_GUEST_PANICKED, RUN_STATE_RUNNING },
>      { RUN_STATE_GUEST_PANICKED, RUN_STATE_FINISH_MIGRATE },
> -    { RUN_STATE_GUEST_PANICKED, RUN_STATE_DEBUG },
> 
> 
> Comments don't compile, but are also easier to understand than code.
> Special logic in runstate_init is unnecessarily complicated, for a table
> that hardly sees any change.  English works better, whoever modifies the
> table has it under their eyes.
> 
> Paolo

But code duplication is bad. I think IO error for example
is broken in that you can't pause but can run then pause.
Seems strange.
Internal error has same bug as panicked.

So it's the same bug for a bunch of states, let's just
have a way to say "this is same as paused".
How's this?

diff --git a/vl.c b/vl.c
index 46c29c4..4388c95 100644
--- a/vl.c
+++ b/vl.c
@@ -593,12 +593,6 @@ static const RunStateTransition runstate_transitions_def[] = {
     { RUN_STATE_INMIGRATE, RUN_STATE_RUNNING },
     { RUN_STATE_INMIGRATE, RUN_STATE_PAUSED },
 
-    { RUN_STATE_INTERNAL_ERROR, RUN_STATE_PAUSED },
-    { RUN_STATE_INTERNAL_ERROR, RUN_STATE_FINISH_MIGRATE },
-
-    { RUN_STATE_IO_ERROR, RUN_STATE_RUNNING },
-    { RUN_STATE_IO_ERROR, RUN_STATE_FINISH_MIGRATE },
-
     { RUN_STATE_PAUSED, RUN_STATE_RUNNING },
     { RUN_STATE_PAUSED, RUN_STATE_FINISH_MIGRATE },
 
@@ -635,16 +629,17 @@ static const RunStateTransition runstate_transitions_def[] = {
     { RUN_STATE_SUSPENDED, RUN_STATE_RUNNING },
     { RUN_STATE_SUSPENDED, RUN_STATE_FINISH_MIGRATE },
 
-    { RUN_STATE_WATCHDOG, RUN_STATE_RUNNING },
-    { RUN_STATE_WATCHDOG, RUN_STATE_FINISH_MIGRATE },
-
-    { RUN_STATE_GUEST_PANICKED, RUN_STATE_PAUSED },
-    { RUN_STATE_GUEST_PANICKED, RUN_STATE_FINISH_MIGRATE },
-    { RUN_STATE_GUEST_PANICKED, RUN_STATE_DEBUG },
-
     { RUN_STATE_MAX, RUN_STATE_MAX },
 };
 
+static const RunState runstate_paused[] = {
+    { RUN_STATE_GUEST_PANICKED},
+    { RUN_STATE_IO_ERROR},
+    { RUN_STATE_INTERNAL_ERROR},
+    { RUN_STATE_WATCHDOG},
+    { RUN_STATE_MAX },
+};
+
 static bool runstate_valid_transitions[RUN_STATE_MAX][RUN_STATE_MAX];
 
 bool runstate_check(RunState state)
@@ -655,12 +650,21 @@ bool runstate_check(RunState state)
 static void runstate_init(void)
 {
     const RunStateTransition *p;
+    const RunState *i;
 
     memset(&runstate_valid_transitions, 0, sizeof(runstate_valid_transitions));
 
     for (p = &runstate_transitions_def[0]; p->from != RUN_STATE_MAX; p++) {
         runstate_valid_transitions[p->from][p->to] = true;
     }
+    /* Allow two-way transitions between identical states */
+    for (i = &runstate_paused[0]; *p != RUN_STATE_MAX; p++) {
+        runstate_valid_transitions[*i][RUN_STATE_PAUSED] = true;
+        runstate_valid_transitions[RUN_STATE_PAUSED][*i] = true;
+        memcpy(&runstate_valid_transitions[*i],
+               &runstate_valid_transitions[RUN_STATE_PAUSED],
+                sizeof(runstate_valid_transitions[RUN_STATE_PAUSED]));
+    }
 }
 
 /* This function will abort() on invalid state transitions */
@@ -686,8 +690,6 @@ int runstate_is_running(void)
 bool runstate_needs_reset(void)
 {
-    return runstate_check(RUN_STATE_INTERNAL_ERROR) ||
-        runstate_check(RUN_STATE_SHUTDOWN) ||
-        runstate_check(RUN_STATE_GUEST_PANICKED);
+    return runstate_check(RUN_STATE_SHUTDOWN);
 }
 
 StatusInfo *qmp_query_status(Error **errp)

  reply	other threads:[~2013-10-31 16:45 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-22 16:10 [Qemu-devel] pvpanic plans? Paolo Bonzini
2013-08-22 16:44 ` Anthony Liguori
2013-08-22 17:53   ` Laszlo Ersek
2013-08-22 18:25     ` Anthony Liguori
2013-08-27  8:42       ` Richard W.M. Jones
2013-08-22 19:16     ` Paolo Bonzini
2013-08-22 20:09       ` Anthony Liguori
2013-08-22 20:36         ` Laszlo Ersek
2013-08-22 20:39           ` Anthony Liguori
2013-08-23  8:52             ` Paolo Bonzini
2013-08-22 21:08         ` Peter Maydell
2013-08-27  8:06         ` Richard W.M. Jones
2013-08-27 13:08           ` Ronen Hod
2013-08-27 13:20             ` Richard W.M. Jones
2013-08-27 13:26               ` Anthony Liguori
2013-08-27 13:57                 ` Richard W.M. Jones
2013-08-27 13:13       ` [Qemu-devel] [libvirt] " Daniel P. Berrange
2013-08-27 13:17         ` Anthony Liguori
2013-08-27 13:21         ` Richard W.M. Jones
2013-08-22 17:15 ` [Qemu-devel] " Laszlo Ersek
2013-08-22 18:33   ` Anthony Liguori
2013-08-22 19:44     ` Christian Borntraeger
2013-08-22 19:19   ` Paolo Bonzini
2013-08-22 19:41     ` Laszlo Ersek
2013-08-22 20:02       ` [Qemu-devel] [libvirt] " Eric Blake
2013-10-24  2:39 ` [Qemu-devel] " Hu Tao
2013-10-29 16:01   ` Markus Armbruster
2013-10-31 14:30   ` Michael S. Tsirkin
2013-10-31 14:32     ` Eric Blake
2013-10-31 14:34       ` Anthony Liguori
2013-10-31 14:39       ` Paolo Bonzini
2013-10-31 14:52         ` Michael S. Tsirkin
2013-10-31 14:56           ` Paolo Bonzini
2013-10-31 15:09             ` Michael S. Tsirkin
2013-10-31 15:26               ` Paolo Bonzini
2013-10-31 15:45                 ` Michael S. Tsirkin
2013-10-31 15:56                   ` Paolo Bonzini
2013-10-31 16:14                     ` Michael S. Tsirkin
2013-10-31 16:17                       ` Paolo Bonzini
2013-10-31 16:26                         ` Michael S. Tsirkin
2013-10-31 16:38                           ` Paolo Bonzini
2013-10-31 16:48                             ` Michael S. Tsirkin [this message]
2013-10-31 16:52                               ` Paolo Bonzini
2013-10-31 17:00                                 ` Michael S. Tsirkin
2013-10-31 17:09                                   ` Paolo Bonzini
2013-10-31 17:01                             ` Michael S. Tsirkin
2013-10-31 17:10                               ` Paolo Bonzini
2013-10-31 17:18                                 ` Michael S. Tsirkin
2013-10-31 18:03                                   ` Paolo Bonzini
2013-10-31 16:28                         ` Michael S. Tsirkin
2013-10-31 14:47       ` Michael S. Tsirkin
2013-10-31 14:49         ` Eric Blake
2013-10-31 15:07           ` Michael S. Tsirkin
2013-11-04  9:25     ` Christian Borntraeger

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=20131031164828.GA10862@redhat.com \
    --to=mst@redhat.com \
    --cc=afaerber@suse.de \
    --cc=anthony@codemonkey.ws \
    --cc=armbru@redhat.com \
    --cc=hutao@cn.fujitsu.com \
    --cc=kraxel@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=lersek@redhat.com \
    --cc=libvir-list@redhat.com \
    --cc=marcel.a@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=pkrempa@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rhod@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).