Received: from eggs.gnu.org ([140.186.70.92]:33283) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rvmtr-0003b7-5x for qemu-devel@nongnu.org; Fri, 10 Feb 2012 04:36:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rvmtl-00070M-BR for qemu-devel@nongnu.org; Fri, 10 Feb 2012 04:36:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:6696) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rvmtl-00070I-20 for qemu-devel@nongnu.org; Fri, 10 Feb 2012 04:36:09 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q1A9a7N5001141 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 10 Feb 2012 04:36:08 -0500 From: Markus Armbruster References: <1328638189-9534-1-git-send-email-lcapitulino@redhat.com> <4F34CE19.7010806@redhat.com> Date: Fri, 10 Feb 2012 10:36:06 +0100 In-Reply-To: <4F34CE19.7010806@redhat.com> (Paolo Bonzini's message of "Fri, 10 Feb 2012 08:58:17 +0100") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [RFC 0/5]: QMP: Introduce GUEST_MEDIUM_EJECT & BLOCK_MEDIUM_CHANGED List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: kwolf@redhat.com, eblake@redhat.com, qemu-devel@nongnu.org, Luiz Capitulino Paolo Bonzini writes: > On 02/09/2012 04:01 PM, Markus Armbruster wrote: >> Your GUEST_MEDIUM_EJECTED does*not* track my open<-> closed. I think >> it's more complex than a straight open<-> closed event. Evidence: your >> event documentation in qmp-events.txt needs an extra note to clarify >> when exactly the event is emitted. > > I think I agree at this point that always generating an event for open > <-> closed would make sense. > > However, we need to write a proper state machine rather than keeping > it implicit. Events would be generated in the state machine rather > than magically in bdrv_eject/bdrv_close. We could also take the > occasion to move all this out of block.c which is becoming huge. So > we would have: > > guest eject, tray locked: > nothing > > guest eject, tray unlocked: > BLOCK_MEDIUM_EJECT > empty/full not affected > > guest eject, tray open: > BLOCK_MEDIUM_EJECT > empty/full not affected > > eject, tray locked: > eject request sent to guest > guest responds to eject request as above > > eject, tray unlocked and full: > BLOCK_MEDIUM_EJECT > BLOCK_MEDIUM_CHANGED > > eject, tray unlocked and empty: > BLOCK_MEDIUM_EJECT > > eject, tray open and full: > BLOCK_MEDIUM_CHANGED > > eject, tray open and empty: > no event > > change, tray locked: > eject request sent to guest > guest responds to eject request as above > > change, tray unlocked and full: > BLOCK_MEDIUM_EJECT (to open) > BLOCK_MEDIUM_CHANGED (perhaps twice? full -> empty -> full) > BLOCK_MEDIUM_EJECT (to close) > > change, tray unlocked and empty: > BLOCK_MEDIUM_EJECT (to open) > BLOCK_MEDIUM_CHANGED > BLOCK_MEDIUM_EJECT (to close) > > change, tray open and full: > BLOCK_MEDIUM_CHANGED (perhaps twice?) > BLOCK_MEDIUM_EJECT (to close) > > change, tray open and empty: > BLOCK_MEDIUM_CHANGED > BLOCK_MEDIUM_EJECT (to close) > > Luiz, can you try making a proof of concept of this state machine? > Events then would hopefully come natural. Making the tray state machine explicit may make sense. But we also need to preserve the sane guest / host split: tray movement and locking is guest matter, handling media in an open tray is host matter. Moreover, let's not think "eject" and "change". These are complex actions that should be built from basic parts. The verbs I want used are open, close, lock, unlock, insert, remove. Eject becomes something like open (if not already open) + remove (if open and not empty). Change becomes something like open (if not already open) + remove (if open and not empty) + insert (if empty) + close (if open).