[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v5.1 2/2] qga-win: add driver path usage to Gues
From: |
Chen Hanxiao |
Subject: |
Re: [Qemu-devel] [PATCH v5.1 2/2] qga-win: add driver path usage to GuestFilesystemInfo |
Date: |
Sat, 2 Jun 2018 17:34:38 +0800 (CST) |
At 2018-06-02 01:15:14, "Eric Blake" <address@hidden> wrote:
>On 06/01/2018 11:57 AM, Chen Hanxiao wrote:
>> From: Chen Hanxiao <address@hidden>
...
>> fs->mountpoint = g_strdup("System Reserved");
>> } else {
>> fs->mountpoint = g_strndup(mnt_point, len);
>> + if (GetDiskFreeSpaceEx(fs->mountpoint,
>> + (PULARGE_INTEGER) & i64FreeBytesToCaller,
>> + (PULARGE_INTEGER) & i64TotalBytes,
>> + (PULARGE_INTEGER) & i64FreeBytes)) {
>> + fs->used_bytes = i64TotalBytes - i64FreeBytes;
>> + fs->total_bytes = i64TotalBytes;
>> + fs->has_total_bytes = true;
>> + fs->has_used_bytes = true;
>> + }
>
>I'm less familiar with Windows API, so I won't give this R-b. But now
>that I read this patch, I do have a question: since both statvfs() and
>GetDiskFreeSpaceEx() give you free bytes rather than used bytes, and you
>had to perform a subtraction to report 'used-bytes' over QGA, would it
>make any more sense to instead report 'free-bytes' over QGA for less
>subtraction work on your end and so that the QGA interface is more
>similar to existing interfaces?
>
All build-in tools report used-bytes for linux and windows.
For windows, GetDiskFreeSpaceEx would tell total and free bytes,
used bytes is total - free, which is exactly same
from the view of disk properties.
But for linux, df(1) do some calculation for showing used-bytes and free-bytes.
df(1) takes f_blocks - f_bfree for 'Used' ,
which take 'Used' + 'Available'(f_bavail) for non-root total,
which is different from 'Size'(f_blocks);
Then calculate 'Use%' by Used / non-root-total.
If we want get what df(3) outputs, we must report more members of struct
statvfs from STATVFS(3) ,
which windows does not need it.
And client had to do some calculation with if-else dealing with data from
windows/linux.
Customs usually take 'Use%' to monitor their disks,
so I think we should report nums that can easily get the right percentage of
usage from it,
for both linux and windows.
Regards,
- Chen