From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:48357) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QoyZ6-0002QJ-N9 for qemu-devel@nongnu.org; Thu, 04 Aug 2011 10:06:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QoyZ4-0002mg-K1 for qemu-devel@nongnu.org; Thu, 04 Aug 2011 10:06:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49859) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QoyZ4-0002mY-8j for qemu-devel@nongnu.org; Thu, 04 Aug 2011 10:06:22 -0400 Date: Thu, 4 Aug 2011 11:06:18 -0300 From: Luiz Capitulino Message-ID: <20110804110618.392e446d@doriath> In-Reply-To: <4E3A71D3.6030700@siemens.com> References: <1312384643-581-1-git-send-email-lcapitulino@redhat.com> <1312384643-581-3-git-send-email-lcapitulino@redhat.com> <4E3A6C8C.8060304@redhat.com> <4E3A71D3.6030700@siemens.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/7] Replace VMSTOP macros with a proper QemuState type List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jan Kiszka Cc: blauwirbel@gmail.com, amit.shah@redhat.com, aliguori@us.ibm.com, Avi Kivity , qemu-devel@nongnu.org On Thu, 04 Aug 2011 12:17:55 +0200 Jan Kiszka wrote: > On 2011-08-04 11:55, Avi Kivity wrote: > > On 08/03/2011 06:17 PM, Luiz Capitulino wrote: > >> @@ -9,6 +9,20 @@ > >> #include "notify.h" > >> > >> /* vl.c */ > >> + > >> +typedef enum { > >> + QSTATE_DEBUG, /* qemu is running under gdb */ > >> + QSTATE_INTERROR, /* paused due to an internal error */ > >> + QSTATE_IOERROR, /* paused due to an I/O error */ > >> + QSTATE_PAUSED, /* paused by the user (ie. the 'stop' > >> command) */ > >> + QSTATE_PREMIGRATE, /* paused preparing to finish migrate */ > >> + QSTATE_RESTVM, /* paused restoring the VM state */ > >> + QSTATE_RUNNING, /* qemu is running */ > >> + QSTATE_SAVEVM, /* paused saving VM state */ > >> + QSTATE_SHUTDOWN, /* guest shut down and -no-shutdown is in > >> use */ > >> + QSTATE_WATCHDOG /* watchdog fired and qemu is configured to > >> pause */ > >> +} QemuState; > >> + > >> extern const char *bios_name; > >> > > > > Why "QemuState"? In general, "qemu" can be inferred from the fact that > > we're in qemu.git. Suggest "RunState". Having a RUNSTATE_PAUSED seems a bit strange when reading it for the first time. But I chose QemuState because I didn't have other options, so I'm fine with RunState. > > Second, these states can coexist. A user may pause the VM > > simultaneously with the watchdog firing or entering premigrate state. > > In fact, with multiple monitors, each monitor can pause and resume the > > vm independently. > > > > So I think we should keep a reference count instead of just a start/stop > > state. Perhaps > > > > vm_stop(QemuState s) > > { > > ++stopcount[s]; > > } > > > > vm_is_stopped() > > { > > for (s in states) > > if (stopcount[s]) > > return true; > > return false; > > } > > I don't think this makes sense nor is user-friendly. If one command > channel suspends the machine, others have the chance to subscribe for > that event. Maintaining a suspension counter would mean you also need a > channel to query its value. Agreed. Can be done incrementally if this turns out to be needed. > > IMHO, there is also no use for defining stopped orthogonally to > premigrate and other states that imply that the machine is stopped. > Basically they mean "stopped for/because of X". We just need to avoid > that you can enter plain stopped state from them by issuing the > corresponding monitor command. The other way around might be possible, > though, if there are race windows. > > Jan > >