From patchwork Tue Jul 17 16:00:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 171475 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C42382C00B9 for ; Wed, 18 Jul 2012 02:27:54 +1000 (EST) Received: from localhost ([::1]:33753 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrAcq-0006rm-Sm for incoming@patchwork.ozlabs.org; Tue, 17 Jul 2012 12:27:52 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38671) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrADI-0007c9-GP for qemu-devel@nongnu.org; Tue, 17 Jul 2012 12:01:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SrADC-0005vu-0f for qemu-devel@nongnu.org; Tue, 17 Jul 2012 12:01:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3294) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SrADB-0005vh-Nv for qemu-devel@nongnu.org; Tue, 17 Jul 2012 12:01:21 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6HG1KPx019968 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 17 Jul 2012 12:01:20 -0400 Received: from dhcp-5-188.str.redhat.com (vpn1-6-35.ams2.redhat.com [10.36.6.35]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q6HG0dqr007516; Tue, 17 Jul 2012 12:01:17 -0400 From: Kevin Wolf To: anthony@codemonkey.ws Date: Tue, 17 Jul 2012 18:00:21 +0200 Message-Id: <1342540838-9027-25-git-send-email-kwolf@redhat.com> In-Reply-To: <1342540838-9027-1-git-send-email-kwolf@redhat.com> References: <1342540838-9027-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 24/41] ide: qdev property for BIOS CHS translation 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 From: Markus Armbruster This isn't quite orthodox. CHS translation is firmware configuration, communicated via the RTC's CMOS RAM, not a property of the disk. But it's best to treat it just like geometry anyway. Maintain backward compatibility exactly like for geometry: fall back to DriveInfo's translation, set with -drive trans=... Bonus: info qtree now shows the translation. Except when it shows "auto": that's resolved by pc_cmos_init_late(). To be addressed shortly. Signed-off-by: Markus Armbruster Signed-off-by: Kevin Wolf --- hw/ide/internal.h | 1 + hw/ide/qdev.c | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/hw/ide/internal.h b/hw/ide/internal.h index 685e976..c3ecafc 100644 --- a/hw/ide/internal.h +++ b/hw/ide/internal.h @@ -474,6 +474,7 @@ struct IDEDevice { DeviceState qdev; uint32_t unit; BlockConf conf; + int chs_trans; char *version; char *serial; char *model; diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 3e297dc..f191dd3 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -144,7 +144,6 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind) IDEState *s = bus->ifs + dev->unit; const char *serial; DriveInfo *dinfo; - int trans; if (dev->conf.discard_granularity && dev->conf.discard_granularity != 512) { error_report("discard_granularity must be 512 for ide"); @@ -160,25 +159,24 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind) } } - trans = BIOS_ATA_TRANSLATION_AUTO; if (!dev->conf.cyls && !dev->conf.heads && !dev->conf.secs) { /* try to fall back to value set with legacy -drive cyls=... */ dinfo = drive_get_by_blockdev(dev->conf.bs); dev->conf.cyls = dinfo->cyls; dev->conf.heads = dinfo->heads; dev->conf.secs = dinfo->secs; - trans = dinfo->trans; + dev->chs_trans = dinfo->trans; } if (!dev->conf.cyls && !dev->conf.heads && !dev->conf.secs) { hd_geometry_guess(dev->conf.bs, &dev->conf.cyls, &dev->conf.heads, &dev->conf.secs, - &trans); + &dev->chs_trans); } if (ide_init_drive(s, dev->conf.bs, kind, dev->version, serial, dev->model, dev->wwn, dev->conf.cyls, dev->conf.heads, dev->conf.secs, - trans) < 0) { + dev->chs_trans) < 0) { return -1; } @@ -222,6 +220,8 @@ static int ide_drive_initfn(IDEDevice *dev) static Property ide_hd_properties[] = { DEFINE_IDE_DEV_PROPERTIES(), DEFINE_BLOCK_CHS_PROPERTIES(IDEDrive, dev.conf), + DEFINE_PROP_BIOS_CHS_TRANS("bios-chs-trans", + IDEDrive, dev.chs_trans, BIOS_ATA_TRANSLATION_AUTO), DEFINE_PROP_END_OF_LIST(), };