From patchwork Fri Jun 29 15:34:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 168232 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 E1641B6FA4 for ; Sat, 30 Jun 2012 03:37:28 +1000 (EST) Received: from localhost ([::1]:37245 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SkdEe-00047N-AT for incoming@patchwork.ozlabs.org; Fri, 29 Jun 2012 11:35:52 -0400 Received: from eggs.gnu.org ([208.118.235.92]:36798) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SkdDu-0002gU-PB for qemu-devel@nongnu.org; Fri, 29 Jun 2012 11:35:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SkdDn-0005ME-GL for qemu-devel@nongnu.org; Fri, 29 Jun 2012 11:35:06 -0400 Received: from oxygen.pond.sub.org ([78.46.104.156]:41218) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SkdDn-0005LI-5k for qemu-devel@nongnu.org; Fri, 29 Jun 2012 11:34:59 -0400 Received: from blackfin.pond.sub.org (p5B3298A7.dip.t-dialin.net [91.50.152.167]) by oxygen.pond.sub.org (Postfix) with ESMTPA id DFA5A9FE61; Fri, 29 Jun 2012 17:34:54 +0200 (CEST) Received: by blackfin.pond.sub.org (Postfix, from userid 500) id 42C316009B; Fri, 29 Jun 2012 17:34:54 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 29 Jun 2012 17:34:23 +0200 Message-Id: <1340984094-5451-2-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.7.6.5 In-Reply-To: <1340984094-5451-1-git-send-email-armbru@redhat.com> References: <1340984094-5451-1-git-send-email-armbru@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 78.46.104.156 Cc: kwolf@redhat.com, pbonzini@redhat.com, aliguori@us.ibm.com, stefanha@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH 01/32] fdc: Drop broken code for user-defined floppy geometry 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 bdrv_get_floppy_geometry_hint() fails to store through its parameter drive when bs has a geometry hint. Makes fd_revalidate() assign random crap to drv->drive. Has been broken that way for ages. Harmless, because: * The only way to set a geometry hint is -drive if=none,cyls=... Since commit c219331e, probably unintentional. * The only use of drv->drive is as argument to another bdrv_get_floppy_geometry_hint(). Which doesn't use it, since the geometry hint is still there. Drop the broken code, ignore -drive parameter cyls, heads and secs for floppies even with if=none, just like before commit c219331e. Matches -help, which explains cyls, heads, secs as "hard disk physical geometry". Signed-off-by: Markus Armbruster --- block.c | 62 ++++++++++++++++++++++++++++---------------------------------- hw/fdc.c | 3 --- 2 files changed, 28 insertions(+), 37 deletions(-) diff --git a/block.c b/block.c index 0acdcac..f5e7cb6 100644 --- a/block.c +++ b/block.c @@ -2308,46 +2308,40 @@ void bdrv_get_floppy_geometry_hint(BlockDriverState *bs, int *nb_heads, uint64_t nb_sectors, size; int i, first_match, match; - bdrv_get_geometry_hint(bs, nb_heads, max_track, last_sect); - if (*nb_heads != 0 && *max_track != 0 && *last_sect != 0) { - /* User defined disk */ - *rate = FDRIVE_RATE_500K; - } else { - bdrv_get_geometry(bs, &nb_sectors); - match = -1; - first_match = -1; - for (i = 0; ; i++) { - parse = &fd_formats[i]; - if (parse->drive == FDRIVE_DRV_NONE) { + bdrv_get_geometry(bs, &nb_sectors); + match = -1; + first_match = -1; + for (i = 0; ; i++) { + parse = &fd_formats[i]; + if (parse->drive == FDRIVE_DRV_NONE) { + break; + } + if (drive_in == parse->drive || + drive_in == FDRIVE_DRV_NONE) { + size = (parse->max_head + 1) * parse->max_track * + parse->last_sect; + if (nb_sectors == size) { + match = i; break; } - if (drive_in == parse->drive || - drive_in == FDRIVE_DRV_NONE) { - size = (parse->max_head + 1) * parse->max_track * - parse->last_sect; - if (nb_sectors == size) { - match = i; - break; - } - if (first_match == -1) { - first_match = i; - } - } - } - if (match == -1) { if (first_match == -1) { - match = 1; - } else { - match = first_match; + first_match = i; } - parse = &fd_formats[match]; } - *nb_heads = parse->max_head + 1; - *max_track = parse->max_track; - *last_sect = parse->last_sect; - *drive = parse->drive; - *rate = parse->rate; } + if (match == -1) { + if (first_match == -1) { + match = 1; + } else { + match = first_match; + } + parse = &fd_formats[match]; + } + *nb_heads = parse->max_head + 1; + *max_track = parse->max_track; + *last_sect = parse->last_sect; + *drive = parse->drive; + *rate = parse->rate; } int bdrv_get_translation_hint(BlockDriverState *bs) diff --git a/hw/fdc.c b/hw/fdc.c index 5b3224b..ec02e62 100644 --- a/hw/fdc.c +++ b/hw/fdc.c @@ -189,9 +189,6 @@ static void fd_revalidate(FDrive *drv) &last_sect, drv->drive, &drive, &rate); if (!bdrv_is_inserted(drv->bs)) { FLOPPY_DPRINTF("No disk in drive\n"); - } else if (nb_heads != 0 && max_track != 0 && last_sect != 0) { - FLOPPY_DPRINTF("User defined disk (%d %d %d)\n", - nb_heads - 1, max_track, last_sect); } else { FLOPPY_DPRINTF("Floppy disk (%d h %d t %d s) %s\n", nb_heads, max_track, last_sect, ro ? "ro" : "rw");