From patchwork Tue Sep 23 16:48:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 392590 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 9C42A1400B2 for ; Wed, 24 Sep 2014 02:51:18 +1000 (EST) Received: from localhost ([::1]:54514 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XWTJ6-0005Ie-Ql for incoming@patchwork.ozlabs.org; Tue, 23 Sep 2014 12:51:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50396) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XWTGQ-0000cQ-47 for qemu-devel@nongnu.org; Tue, 23 Sep 2014 12:48:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XWTGJ-0001P4-Vs for qemu-devel@nongnu.org; Tue, 23 Sep 2014 12:48:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58789) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XWTGJ-0001Lq-G2 for qemu-devel@nongnu.org; Tue, 23 Sep 2014 12:48:23 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8NGmH58031578 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 23 Sep 2014 12:48:17 -0400 Received: from dhcp-17-12.bos.redhat.com (vpn-59-93.rdu2.redhat.com [10.10.59.93]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s8NGmCMW027020; Tue, 23 Sep 2014 12:48:16 -0400 From: John Snow To: qemu-devel@nongnu.org Date: Tue, 23 Sep 2014 12:48:03 -0400 Message-Id: <1411490885-29782-5-git-send-email-jsnow@redhat.com> In-Reply-To: <1411490885-29782-1-git-send-email-jsnow@redhat.com> References: <1411490885-29782-1-git-send-email-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, John Snow , armbru@redhat.com, stefanha@redhat.com, mst@redhat.com Subject: [Qemu-devel] [PATCH 4/6] ide: Update ide_drive_get to be HBA agnostic 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 Instead of duplicating the logic for the if_ide (bus,unit) mappings, rely on the blockdev layer for managing those mappings for us, and use the drive_get_by_index call instead. This allows ide_drive_get to work for AHCI HBAs as well, and can be used in the Q35 initialization. Signed-off-by: John Snow --- hw/ide/core.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index 6fba056..1e43d50 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -2551,13 +2551,15 @@ const VMStateDescription vmstate_ide_bus = { void ide_drive_get(DriveInfo **hd, int max_bus) { int i; + int max_devs = if_get_max_devs(IF_IDE) * max_bus; + int buses = drive_get_max_bus(IF_IDE) + 1; - if (drive_get_max_bus(IF_IDE) >= max_bus) { - fprintf(stderr, "qemu: too many IDE bus: %d\n", max_bus); - exit(1); + if (buses > max_bus) { + fprintf(stderr, "Warning: Too many IDE buses defined (%d > %d)\n", + buses, max_bus); } - for(i = 0; i < max_bus * MAX_IDE_DEVS; i++) { - hd[i] = drive_get(IF_IDE, i / MAX_IDE_DEVS, i % MAX_IDE_DEVS); + for (i = 0; i < max_devs; i++) { + hd[i] = drive_get_by_index(IF_IDE, i); } }