qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 03/39] block: implement is_allocated for raw


From: Alexander Graf
Subject: Re: [Qemu-devel] [PATCH 03/39] block: implement is_allocated for raw
Date: Tue, 19 Jun 2012 14:37:05 +0200

On 15.06.2012, at 15:33, Kevin Wolf wrote:

> From: Paolo Bonzini <address@hidden>
> 
> Either FIEMAP, or SEEK_DATA+SEEK_HOLE can be used to implement the
> is_allocated callback for raw files.  On Linux ext4, btrfs and XFS
> all support it.
> 
> Signed-off-by: Paolo Bonzini <address@hidden>
> Signed-off-by: Kevin Wolf <address@hidden>
> ---
> block/raw-posix.c |   98 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> block/raw.c       |    8 ++++
> 2 files changed, 106 insertions(+), 0 deletions(-)
> 
> diff --git a/block/raw-posix.c b/block/raw-posix.c
> index 03fcfcc..bf7700a 100644
> --- a/block/raw-posix.c
> +++ b/block/raw-posix.c
> @@ -52,6 +52,10 @@
> #include <sys/param.h>
> #include <linux/cdrom.h>
> #include <linux/fd.h>
> +#include <linux/fs.h>
> +#endif
> +#ifdef CONFIG_FIEMAP
> +#include <linux/fiemap.h>
> #endif
> #if defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
> #include <sys/disk.h>
> @@ -583,6 +587,99 @@ static int raw_create(const char *filename, 
> QEMUOptionParameter *options)
>     return result;
> }
> 
> +/*
> + * Returns true iff the specified sector is present in the disk image. 
> Drivers
> + * not implementing the functionality are assumed to not support backing 
> files,
> + * hence all their sectors are reported as allocated.
> + *
> + * If 'sector_num' is beyond the end of the disk image the return value is 0
> + * and 'pnum' is set to 0.
> + *
> + * 'pnum' is set to the number of sectors (including and immediately 
> following
> + * the specified sector) that are known to be in the same
> + * allocated/unallocated state.
> + *
> + * 'nb_sectors' is the max value 'pnum' should be set to.  If nb_sectors goes
> + * beyond the end of the disk image it will be clamped.
> + */
> +static int coroutine_fn raw_co_is_allocated(BlockDriverState *bs,
> +                                            int64_t sector_num,
> +                                            int nb_sectors, int *pnum)
> +{
> +    BDRVRawState *s = bs->opaque;

cc1: warnings being treated as errors
block/raw-posix.c: In function ‘raw_co_is_allocated’:
block/raw-posix.c:609: error: unused variable ‘s’


Alex




reply via email to

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