From patchwork Wed Apr 1 15:03:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 457271 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1AEF21400DE for ; Thu, 2 Apr 2015 02:04:58 +1100 (AEDT) Received: from localhost ([::1]:53174 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdKCO-0007uF-6h for incoming@patchwork.ozlabs.org; Wed, 01 Apr 2015 11:04:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41530) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdKAo-00027N-LF for qemu-devel@nongnu.org; Wed, 01 Apr 2015 11:03:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YdKAj-0006v3-CF for qemu-devel@nongnu.org; Wed, 01 Apr 2015 11:03:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44925) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdKAj-0006uk-5p for qemu-devel@nongnu.org; Wed, 01 Apr 2015 11:03:13 -0400 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 t31F39wo015412 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 1 Apr 2015 11:03:09 -0400 Received: from blackfin.pond.sub.org (ovpn-116-64.ams2.redhat.com [10.36.116.64]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t31F36Pt004578 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 1 Apr 2015 11:03:08 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 500C43008AAF; Wed, 1 Apr 2015 17:03:06 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 1 Apr 2015 17:03:02 +0200 Message-Id: <1427900586-5358-2-git-send-email-armbru@redhat.com> In-Reply-To: <1427900586-5358-1-git-send-email-armbru@redhat.com> References: <1427900586-5358-1-git-send-email-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-MIME-Autoconverted: from 8bit to quoted-printable by mx1.redhat.com id t31F39wo015412 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org, Peter Crosthwaite , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Michael Walle , pbonzini@redhat.com Subject: [Qemu-devel] [PULL 1/5] hw: Mark devices picking up block backends actively FIXME X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Drives defined with if!=none are for board initialization to wire up. Board code calls drive_get() or similar to find them, and creates devices with their qdev drive properties set accordingly. Except a few devices go on a fishing expedition for a suitable backend instead of exposing a drive property for board code to set: they call driver_get() or drive_get_next() in their realize() or init() method to implicitly connect to the "next" backend with a certain interface type. Picking up backends that way works when the devices are created by board code. But it's inappropriate for -device or device_add. Not only is this inconsistent with how the other block device models work (they connect to a backend explicitly identified by a "drive" property), it breaks when the "next" backend has been picked up by the board already. Example: $ qemu-system-arm -S -M connex -pflash flash.img -device ssi-sd Aborted (core dumped) Mark them with suitable FIXME comments. Cc: Andrzej Zaborowski Cc: Peter Crosthwaite Cc: "Andreas Färber" Cc: Michael Walle Signed-off-by: Markus Armbruster --- hw/arm/spitz.c | 1 + hw/block/m25p80.c | 1 + hw/isa/pc87312.c | 2 ++ hw/sd/milkymist-memcard.c | 1 + hw/sd/pl181.c | 1 + hw/sd/sdhci.c | 1 + hw/sd/ssi-sd.c | 1 + 7 files changed, 8 insertions(+) diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c index a16831c..da02932 100644 --- a/hw/arm/spitz.c +++ b/hw/arm/spitz.c @@ -168,6 +168,7 @@ static int sl_nand_init(SysBusDevice *dev) DriveInfo *nand; s->ctl = 0; + /* FIXME use a qdev drive property instead of drive_get() */ nand = drive_get(IF_MTD, 0, 0); s->nand = nand_init(nand ? blk_by_legacy_dinfo(nand) : NULL, s->manf_id, s->chip_id); diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index ff1106b..afe243b 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -623,6 +623,7 @@ static int m25p80_init(SSISlave *ss) s->dirty_page = -1; s->storage = blk_blockalign(s->blk, s->size); + /* FIXME use a qdev drive property instead of drive_get_next() */ dinfo = drive_get_next(IF_MTD); if (dinfo) { diff --git a/hw/isa/pc87312.c b/hw/isa/pc87312.c index 40a1106..2849e8d 100644 --- a/hw/isa/pc87312.c +++ b/hw/isa/pc87312.c @@ -319,11 +319,13 @@ static void pc87312_realize(DeviceState *dev, Error **errp) d = DEVICE(isa); qdev_prop_set_uint32(d, "iobase", get_fdc_iobase(s)); qdev_prop_set_uint32(d, "irq", 6); + /* FIXME use a qdev drive property instead of drive_get() */ drive = drive_get(IF_FLOPPY, 0, 0); if (drive != NULL) { qdev_prop_set_drive_nofail(d, "driveA", blk_by_legacy_dinfo(drive)); } + /* FIXME use a qdev drive property instead of drive_get() */ drive = drive_get(IF_FLOPPY, 0, 1); if (drive != NULL) { qdev_prop_set_drive_nofail(d, "driveB", diff --git a/hw/sd/milkymist-memcard.c b/hw/sd/milkymist-memcard.c index 9661eaf..0cc53d9 100644 --- a/hw/sd/milkymist-memcard.c +++ b/hw/sd/milkymist-memcard.c @@ -255,6 +255,7 @@ static int milkymist_memcard_init(SysBusDevice *dev) DriveInfo *dinfo; BlockBackend *blk; + /* FIXME use a qdev drive property instead of drive_get_next() */ dinfo = drive_get_next(IF_SD); blk = dinfo ? blk_by_legacy_dinfo(dinfo) : NULL; s->card = sd_init(blk, false); diff --git a/hw/sd/pl181.c b/hw/sd/pl181.c index e704b6e..bf37da6 100644 --- a/hw/sd/pl181.c +++ b/hw/sd/pl181.c @@ -490,6 +490,7 @@ static int pl181_init(SysBusDevice *sbd) sysbus_init_irq(sbd, &s->irq[0]); sysbus_init_irq(sbd, &s->irq[1]); qdev_init_gpio_out(dev, s->cardstatus, 2); + /* FIXME use a qdev drive property instead of drive_get_next() */ dinfo = drive_get_next(IF_SD); s->card = sd_init(dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, false); if (s->card == NULL) { diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c index 27b914a..f056c52 100644 --- a/hw/sd/sdhci.c +++ b/hw/sd/sdhci.c @@ -1146,6 +1146,7 @@ static void sdhci_initfn(SDHCIState *s) { DriveInfo *di; + /* FIXME use a qdev drive property instead of drive_get_next() */ di = drive_get_next(IF_SD); s->card = sd_init(di ? blk_by_legacy_dinfo(di) : NULL, false); if (s->card == NULL) { diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c index a71fbca..e4b2d4f 100644 --- a/hw/sd/ssi-sd.c +++ b/hw/sd/ssi-sd.c @@ -255,6 +255,7 @@ static int ssi_sd_init(SSISlave *d) DriveInfo *dinfo; s->mode = SSI_SD_CMD; + /* FIXME use a qdev drive property instead of drive_get_next() */ dinfo = drive_get_next(IF_SD); s->sd = sd_init(dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, true); if (s->sd == NULL) {