aboutsummaryrefslogtreecommitdiff
path: root/hw/hd-geometry.c
AgeCommit message (Collapse)Author
2012-07-17hd-geometry: Compute BIOS CHS translation in one placeMarkus Armbruster
Currently, it is split between hd_geometry_guess() and pc_cmos_init_late(). Confusing. info qtree shows the result of the former. Also confusing. Fold the part done in pc_cmos_init_late() into hd_geometry_guess(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-07-17block: Geometry and translation hints are now useless, purge themMarkus Armbruster
There are two producers of these hints: drive_init() on behalf of -drive, and hd_geometry_guess(). The only consumer of the hint is hd_geometry_guess(). The callers of hd_geometry_guess() call it only when drive_init() didn't set the hints. Therefore, drive_init()'s hints are never used. Thus, hd_geometry_guess() only ever sees hints it produced itself in a prior call. Only the first call computes something, subsequent calls just repeat the first call's results. However, hd_geometry_guess() is never called more than once: the device models don't, and the block device is destroyed on unplug. Thus, dropping the repeat feature doesn't break anything now. If a block device wasn't destroyed on unplug and could be reused with a new device, then repeating old results would be wrong. Thus, dropping the repeat feature prevents future breakage. This renders the hints unused. Purge them from the block layer. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-07-17hd-geometry: Switch to uint32_t to match BlockConfMarkus Armbruster
Best to use the same type, to avoid unwanted truncation or sign extension. BlockConf can't use plain int for cyls, heads and secs, because integer properties require an exact width. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-07-17hd-geometry: Cut out block layer translation middlemanMarkus Armbruster
hd_geometry_guess() picks geometry and translation. Callers can get the geometry directly, via parameters, but for translation they need to go through the block layer. Add a parameter for translation, so it can optionally be gotten just like geometry. In preparation of purging translation from the block layer, which will happen later in this series. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-07-17hd-geometry: Clean up confusing use of prior translation hintMarkus Armbruster
When hd_geometry_guess() picks a geometry, it also picks the appropriate translation, but only when the prior translation hint is BIOS_ATA_TRANSLATION_AUTO. Looks wrong, because such a prior translation would be passed to the BIOS whether it's suitable for the geometry or not. Fortunately, that can't happen. There are just two ways for the translation hint to get set to something other than BIOS_ATA_TRANSLATION_AUTO: drive_init() on behalf of -drive trans=..., and hd_geometry_guess(). Both set it only when they also set a valid geometry hint, i.e. one with a non-zero number of cylinders. Since hd_geometry_guess() returns right away when it finds a valid geometry hint, translation can only be BIOS_ATA_TRANSLATION_AUTO in the remainder of the function. Assert this, and simplify accordingly. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-07-17hd-geometry: Clean up gratuitous goto in hd_geometry_guess()Markus Armbruster
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-07-17hd-geometry: Factor out guess_chs_for_size()Markus Armbruster
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-07-17hd-geometry: Unnest conditional in hd_geometry_guess()Markus Armbruster
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-07-17hd-geometry: Add tracepointsMarkus Armbruster
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-07-17hd-geometry: Move disk geometry guessing back from block.cMarkus Armbruster
Commit f3d54fc4 factored it out of hw/ide.c for reuse. Sensible, except it was put into block.c. Device-specific functionality should be kept in device code, not the block layer. Move it to hw/hd-geometry.c, and make stylistic changes required to keep checkpatch.pl happy. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>