From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57778) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SEnMx-0002md-CT for qemu-devel@nongnu.org; Mon, 02 Apr 2012 15:56:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SEnMv-0001UG-HB for qemu-devel@nongnu.org; Mon, 02 Apr 2012 15:56:50 -0400 Received: from mail-bk0-f45.google.com ([209.85.214.45]:37092) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SEnMv-0001Tz-7p for qemu-devel@nongnu.org; Mon, 02 Apr 2012 15:56:49 -0400 Received: by bkcjg9 with SMTP id jg9so3139449bkc.4 for ; Mon, 02 Apr 2012 12:56:47 -0700 (PDT) Message-ID: <4F7A1298.70507@samsung.com> Date: Mon, 02 Apr 2012 23:56:56 +0300 From: Igor Mitsyanko MIME-Version: 1.0 References: <1333376921-13834-1-git-send-email-i.mitsyanko@samsung.com> <1333376921-13834-7-git-send-email-i.mitsyanko@samsung.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 6/6] hw/sd.c: convert to QOM object Reply-To: i.mitsyanko@samsung.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Anthony Liguori , michael@walle.cc, quintela@redhat.com, qemu-devel@nongnu.org, kyungmin.park@samsung.com, paul@codesourcery.com, afaerber@suse.de On 02.04.2012 7:48 PM, Peter Maydell wrote: > On 2 April 2012 15:28, Igor Mitsyanko wrote: >> + s->card = SD_CARD(object_new(TYPE_SD_CARD)); >> dinfo = drive_get_next(IF_SD); >> - s->card = sd_init(dinfo ? dinfo->bdrv : NULL, 0); >> + SD_GET_CLASS(s->card)->init(s->card, dinfo ? dinfo->bdrv : NULL, false); > > Ideally rather than having a class specific init function we > should make the 'is_spi' and 'bdrv' be object properties, and > then you do something like (syntax probably wrong but): > s->card = SD_CARD(object_new(TYPE_SD_CARD)); > if (dinfo) { > object_property_set_bdrv(s->card, dinfo->bdrv, "bdrv", errp); > } > realize(s->card); > > (where the default for bdrv is NULL and the default for is_spi is false > so we don't need to set that). > > This needs realize support for QOM objects, though. > > -- PMM > > I absolutely agree, that's how I wanted to do this in my working tree at first, but then several issues arose: 1) Pointer properties are obviously interfere with QOM principles, BDRV should be a link instead; 2) At first I made SD card child of SD host controller, but it most certainly wrong, it should be a link. But where should it be placed, under /block-dev/* maybe? 3) There is no point in creating SD card object until user specified an image. 4) Not every host controller on specific board is actually active, and nothing good will happen if you will try to hot-insert SD card in controller which was not activated by kernel. Having a child property in every controller instance is wrong. What I want to do now is introduce CardSlot object and probably also HostControllerClass. Boards will instantiate as much CardSlots as it actually has and connect them with SDHC with links. SDCard object will be dynamically created and destroyed by setting CardSlot::inserted and CardSlot::image properties, SDcards will be childs of CardSlots. But I havn't figured out how to avoid additional overhead in such a scheme.