From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:58208) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SeCjX-0003HI-DE for qemu-devel@nongnu.org; Mon, 11 Jun 2012 18:05:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SeCjV-0006cx-Kc for qemu-devel@nongnu.org; Mon, 11 Jun 2012 18:05:10 -0400 Received: from mail-pz0-f45.google.com ([209.85.210.45]:41289) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SeCjV-0006c4-Eq for qemu-devel@nongnu.org; Mon, 11 Jun 2012 18:05:09 -0400 Received: by dadv2 with SMTP id v2so6567429dad.4 for ; Mon, 11 Jun 2012 15:05:07 -0700 (PDT) Message-ID: <4FD66B8F.4080203@codemonkey.ws> Date: Mon, 11 Jun 2012 17:05:03 -0500 From: Anthony Liguori MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Semantics of DeviceState::realized and BlockDriverState List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel Cc: Kevin Wolf , Paolo Bonzini , =?ISO-8859-1?Q?Andreas_F=E4rber?= , Stefan Hajnoczi Hi, I wanted to start a central thread as this discussion is spread in two places right now. I think I'm becoming convinced that realized belongs in DeviceState and that BlockDriverState does not have a realized equivalent. To me, realized represents Vcc. When realized=true, the guest has power and is active. When realized=false, the guest has lost power. The realize() event is the rising edge of Vcc, unrealized() is the falling edge. realize() should be used to take any actions that require all parameters to be set that need to happen before the guest has power. This later clause is extremely important. unrealize() should be used to unset anything setup in realize(). The destructor being invoked does not imply that unrealize() has happened. I think BlockDriverState wants two separate signals: an opened signal and an attached signal. With BDS, there are a few phases: opened = false attached = false All properties can be set here and no side effects occur. It is not valid to do a read/write request to a BDS in this state. opened = true attached = false Properties that affect file opening (flags and filename) cannot be changed after this point. Depending on the contents of the file, a backing_file property may be created after opened = true. The backing_file that gets created does *not* automatically have opened = true. A user explicitly needs to set that. This behavior is necessary to allow overriding backing files. It is not valid to do a read/write request to a BDS in this state. opened = true attached = true This means that the device is in-use by something in QEMU. Requests may be in flight as read/write requests are now allowed to be issued. Most properties cannot be changed in this state (presumably). opened = false attached = true Invalid state. So there are three valid states and none of them map directly to the concept of realized for devices. I think this argues pretty clearly for realize() to not live in Object and instead to allow base classes to implement whatever properties make sense to them. Regard, Anthony Liguori