[libvirt] [PATCH 4/5] Implement virDomainGetBlockInfo in QEMU driver
Eric Blake
eblake at redhat.com
Tue Apr 27 22:43:08 UTC 2010
On 04/27/2010 01:35 PM, Daniel P. Berrange wrote:
> * src/qemu/qemu_driver.c: Implementation of virDomainGetBlockInfo
> * src/util/storage_file.h: Add DEV_BSIZE
> * src/storage/storage_backend.c: Remove DEV_BSIZE
> + if (S_ISREG(sb.st_mode)) {
> +#ifndef __MINGW32__
> + info->physical = (unsigned long long)sb.st_blocks *
> + (unsigned long long)DEV_BSIZE;
Is it worth checking sb.st_blksize rather than DEV_BSIZE on XSI systems
where that is part of struct stat? In particular, POSIX allows the
block size to be file-system dependent, and some file systems (like
NTFS) have 4k rather than 512 as the block size (is anyone daring enough
to use NTFS for raw file storage?).
>
> +#ifndef DEV_BSIZE
> +# define DEV_BSIZE 512
> +#endif
Maybe the right thing to do is rewrite a macro:
#if HAVE_STRUCT_STAT_ST_BLKSIZE
# define BSIZE(s) ((s).st_blksize)
#elif defined DEV_BSIZE
# define BSIZE(s) DEV_BSIZE
#else
# define BSIZE(s) 512
#endif
and use BSIZE(sb) instead of DEV_BSIZE; it also involves using a
configure check for AC_CHECK_MEMBERS([struct stat.st_blksize]).
But I think that can be an independent patch, so:
ACK.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100427/fa2567e8/attachment-0001.sig>
More information about the libvir-list
mailing list