qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 2/3] geometry detection: use HDIO_GETGEO


From: Alexander Graf
Subject: Re: [Qemu-devel] [PATCH 2/3] geometry detection: use HDIO_GETGEO
Date: Thu, 26 Apr 2012 16:39:03 +0200

On 26.04.2012, at 15:49, Christian Borntraeger wrote:

> From: Einar Lueck <address@hidden>
> 
> This patch uses ioctl HDIO_GETGEO to guess geometry of a disk in
> case nothing is specified explicitly.
> 
> Signed-off-by: Einar Lueck <address@hidden>
> Signed-off-by: Christian Borntraeger <address@hidden>
> ---
> block.c |   12 ++++++++++++
> 1 files changed, 12 insertions(+), 0 deletions(-)
> 
> diff --git a/block.c b/block.c
> index fe74ddd..8af4d19 100644
> --- a/block.c
> +++ b/block.c
> @@ -32,6 +32,10 @@
> #include "qmp-commands.h"
> #include "qemu-timer.h"
> 
> +#ifdef __linux__
> +#include <linux/hdreg.h>
> +#endif
> +
> #ifdef CONFIG_BSD
> #include <sys/types.h>
> #include <sys/stat.h>
> @@ -2054,6 +2058,7 @@ void bdrv_guess_geometry(BlockDriverState *bs, int 
> *pcyls, int *pheads, int *pse
>     int translation, lba_detected = 0;
>     int cylinders, heads, secs;
>     uint64_t nb_sectors;
> +    struct hd_geometry geo;

This one certainly belongs in the block below, otherwise you get an unused 
variable warning (== error) on other OSs.


Alex

> 
>     /* if a geometry hint is available, use it */
>     bdrv_get_geometry(bs, &nb_sectors);
> @@ -2063,6 +2068,13 @@ void bdrv_guess_geometry(BlockDriverState *bs, int 
> *pcyls, int *pheads, int *pse
>         *pcyls = cylinders;
>         *pheads = heads;
>         *psecs = secs;
> +#ifdef __linux__
> +    } else if (bdrv_ioctl(bs, HDIO_GETGEO, &geo) == 0) {
> +        *pcyls = geo.cylinders;
> +        *pheads = geo.heads;
> +        *psecs = geo.sectors;
> +        bdrv_set_geometry_hint(bs, *pcyls, *pheads, *psecs);
> +#endif
>     } else {
>         if (guess_disk_lchs(bs, &cylinders, &heads, &secs) == 0) {
>             if (heads > 16) {
> -- 
> 1.7.0.1
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]