From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:60625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QzEM3-0004SK-JD for qemu-devel@nongnu.org; Thu, 01 Sep 2011 16:59:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QzEM2-0005ht-FL for qemu-devel@nongnu.org; Thu, 01 Sep 2011 16:59:19 -0400 Received: from fmmailgate01.web.de ([217.72.192.221]:44111) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QzEM2-0005hn-0E for qemu-devel@nongnu.org; Thu, 01 Sep 2011 16:59:18 -0400 Message-ID: <4E5FF20B.5030504@web.de> Date: Thu, 01 Sep 2011 22:58:51 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <1314900738-30164-1-git-send-email-lcapitulino@redhat.com> <1314900738-30164-4-git-send-email-lcapitulino@redhat.com> <4E5FCF61.4040404@siemens.com> <20110901153917.112c5428@doriath> In-Reply-To: <20110901153917.112c5428@doriath> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig30CE4DAA97F575427441EED4" Sender: jan.kiszka@web.de Subject: Re: [Qemu-devel] [PATCH 3/8] RunState: Add additional states List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: "kwolf@redhat.com" , "amit.shah@redhat.com" , "aliguori@us.ibm.com" , "qemu-devel@nongnu.org" , "armbru@redhat.com" This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig30CE4DAA97F575427441EED4 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 2011-09-01 20:39, Luiz Capitulino wrote: > On Thu, 01 Sep 2011 20:30:57 +0200 > Jan Kiszka wrote: >=20 >> On 2011-09-01 20:12, Luiz Capitulino wrote: >>> Currently, only vm_start() and vm_stop() change the VM state. >>> That's, the state is only changed when starting or stopping the VM. >>> >>> This commit adds the runstate_set() function, which makes it possible= >>> to also do state transitions when the VM is stopped or running. >>> >>> Additional states are also added and the current state is stored. >>> >>> Signed-off-by: Luiz Capitulino >>> --- >>> cpus.c | 1 + >>> migration.c | 8 +++++++- >>> sysemu.h | 10 +++++++++- >>> vl.c | 20 ++++++++++++++++++++ >>> 4 files changed, 37 insertions(+), 2 deletions(-) >>> >> >> ... >> >>> diff --git a/vl.c b/vl.c >>> index f0b56a4..59f71fc 100644 >>> --- a/vl.c >>> +++ b/vl.c >>> @@ -321,6 +321,22 @@ static int default_driver_check(QemuOpts *opts, = void *opaque) >>> } >>> =20 >>> /***********************************************************/ >>> +/* QEMU state */ >>> + >>> +static RunState current_run_state =3D RSTATE_NO_STATE; >>> + >>> +bool runstate_check(RunState state) >>> +{ >>> + return current_run_state =3D=3D state; >>> +} >>> + >>> +void runstate_set(RunState state) >>> +{ >>> + assert(state < RSTATE_MAX); >>> + current_run_state =3D state; >> >> I still think this should check for valid state transitions instead of= >> blindly accepting what the caller passes in. >=20 > I thought your comment where more like a future enhancement than > a request for change. I think we want this now to document at a central place which transitions are valid and which not. State machines without such checks break sooner or later, subtly. >=20 > What to do if the transition is invalid? abort()? Yes. Jan --------------enig30CE4DAA97F575427441EED4 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk5f8iMACgkQitSsb3rl5xQDIwCfSM1MtzTVVyaeUegMSv+BfMRg XlMAn0ZeTSEGnlLmTeEVZsRYgDMQgCLG =KqLH -----END PGP SIGNATURE----- --------------enig30CE4DAA97F575427441EED4--