[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 10/41] hd-geometry: Factor out guess_chs_for_size()
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 10/41] hd-geometry: Factor out guess_chs_for_size() |
Date: |
Tue, 17 Jul 2012 18:00:07 +0200 |
From: Markus Armbruster <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
hw/hd-geometry.c | 32 ++++++++++++++++++++------------
1 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/hw/hd-geometry.c b/hw/hd-geometry.c
index db47846..1a58894 100644
--- a/hw/hd-geometry.c
+++ b/hw/hd-geometry.c
@@ -97,14 +97,31 @@ static int guess_disk_lchs(BlockDriverState *bs,
return -1;
}
+static void guess_chs_for_size(BlockDriverState *bs,
+ int *pcyls, int *pheads, int *psecs)
+{
+ uint64_t nb_sectors;
+ int cylinders;
+
+ bdrv_get_geometry(bs, &nb_sectors);
+
+ cylinders = nb_sectors / (16 * 63);
+ if (cylinders > 16383) {
+ cylinders = 16383;
+ } else if (cylinders < 2) {
+ cylinders = 2;
+ }
+ *pcyls = cylinders;
+ *pheads = 16;
+ *psecs = 63;
+}
+
void hd_geometry_guess(BlockDriverState *bs,
int *pcyls, int *pheads, int *psecs)
{
int translation, lba_detected = 0;
int cylinders, heads, secs;
- uint64_t nb_sectors;
- bdrv_get_geometry(bs, &nb_sectors);
bdrv_get_geometry_hint(bs, &cylinders, &heads, &secs);
translation = bdrv_get_translation_hint(bs);
@@ -119,16 +136,7 @@ void hd_geometry_guess(BlockDriverState *bs,
if (guess_disk_lchs(bs, &cylinders, &heads, &secs) < 0) {
/* no LCHS guess: use a standard physical disk geometry */
default_geometry:
- cylinders = nb_sectors / (16 * 63);
-
- if (cylinders > 16383) {
- cylinders = 16383;
- } else if (cylinders < 2) {
- cylinders = 2;
- }
- *pcyls = cylinders;
- *pheads = 16;
- *psecs = 63;
+ guess_chs_for_size(bs, pcyls, pheads, psecs);
if ((lba_detected == 1) && (translation == BIOS_ATA_TRANSLATION_AUTO))
{
if ((*pcyls * *pheads) <= 131072) {
bdrv_set_translation_hint(bs,
--
1.7.6.5
- [Qemu-devel] [PULL 00/41] Block patches, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 01/41] sheepdog: always use coroutine-based network functions, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 02/41] sheepdog: do not blindly memset all read buffers, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 03/41] fdc: Move floppy geometry guessing back from block.c, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 09/41] hd-geometry: Unnest conditional in hd_geometry_guess(), Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 07/41] hd-geometry: Move disk geometry guessing back from block.c, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 05/41] vvfat: Do not clobber the user's geometry, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 11/41] hd-geometry: Clean up gratuitous goto in hd_geometry_guess(), Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 06/41] qtest: Add hard disk geometry test, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 04/41] vvfat: Fix partition table, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 10/41] hd-geometry: Factor out guess_chs_for_size(),
Kevin Wolf <=
- [Qemu-devel] [PATCH 08/41] hd-geometry: Add tracepoints, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 13/41] hd-geometry: Cut out block layer translation middleman, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 15/41] blockdev: Save geometry in DriveInfo, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 16/41] qdev: Introduce block geometry properties, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 14/41] ide pc: Cut out the block layer geometry middleman, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 29/41] hd-geometry: Compute BIOS CHS translation in one place, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 22/41] qdev: Collect private helpers in one place, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 33/41] hw/block-common: Factor out fall back to legacy -drive serial=..., Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 30/41] blockdev: Drop redundant CHS validation for if=ide, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 27/41] ide pc: Put hard disk info into CMOS only for hard disks, Kevin Wolf, 2012/07/17