I have a sparse volume with a capacity of 1000M, and an allocation of a
little over 750M. 'du' prints the correct sizes, but 'virsh vol-dumpxml'
shows:
<capacity>1048576000</capacity>
<allocation>6406307840</allocation>
This is because we were calculating the allocation size using the
requested fs block size, instead of what stat actually uses as a block
size (DEV_BSIZE in sys/params.h). sys/params.h looks to be present in
mingw32-runtime, so I didn't add a configure check for it.
The attached patch fixes allocation listing for me.
Thanks,
Cole
diff --git a/src/storage_backend.c b/src/storage_backend.c
index 787630c..54e9289 100644
--- a/src/storage_backend.c
+++ b/src/storage_backend.c
@@ -36,6 +36,7 @@
#include <fcntl.h>
#include <stdint.h>
#include <sys/stat.h>
+#include <sys/param.h>
#include <dirent.h>
#if HAVE_SELINUX
@@ -204,8 +205,15 @@ virStorageBackendUpdateVolTargetInfoFD(virConnectPtr conn,
if (allocation) {
if (S_ISREG(sb.st_mode)) {
#ifndef __MINGW32__
- *allocation = (unsigned long long)sb.st_blocks *
- (unsigned long long)sb.st_blksize;
+
+ unsigned long long blksize;
+#ifdef DEV_BSIZE
+ blksize = (unsigned long long) DEV_BSIZE;
+#else
+ blksize = (unsigned long long)sb.st_blksize;
+#endif
+ *allocation = (unsigned long long)sb.st_blocks * blksize;
+
#else
*allocation = sb.st_size;
#endif
--
Libvir-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libvir-list