qga: Improve Windows filesystem space info retrieval logic
Previously, disk space reporting only worked for volumes with drive letters,
skipping those without (e.g. System Reserved).
This change always calls GetDiskFreeSpaceEx with fs->name, which is a
volume GUID path. Windows APIs accept both drive letters (e.g. "C:\")
and volume GUIDs (e.g. "\\?\Volume{GUID}\") as valid lpDirectoryName
parameters, so space reporting is now consistent across all volumes.
Reference:
https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file
Signed-off-by: minglei.liu <minglei.liu@smartx.com>
Reviewed-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20250923113243.78244-1-minglei.liu@smartx.com
Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
This commit is contained in:
parent
c38e65a881
commit
c741c087b8
1 changed files with 9 additions and 9 deletions
|
|
@ -1164,15 +1164,15 @@ static GuestFilesystemInfo *build_guest_fsinfo(char *guid, Error **errp)
|
||||||
fs->mountpoint = g_strdup("System Reserved");
|
fs->mountpoint = g_strdup("System Reserved");
|
||||||
} else {
|
} else {
|
||||||
fs->mountpoint = g_strndup(mnt_point, len);
|
fs->mountpoint = g_strndup(mnt_point, len);
|
||||||
if (GetDiskFreeSpaceEx(fs->mountpoint,
|
}
|
||||||
(PULARGE_INTEGER) & i64FreeBytesToCaller,
|
if (GetDiskFreeSpaceEx(fs->name,
|
||||||
(PULARGE_INTEGER) & i64TotalBytes,
|
(PULARGE_INTEGER) & i64FreeBytesToCaller,
|
||||||
(PULARGE_INTEGER) & i64FreeBytes)) {
|
(PULARGE_INTEGER) & i64TotalBytes,
|
||||||
fs->used_bytes = i64TotalBytes - i64FreeBytes;
|
(PULARGE_INTEGER) & i64FreeBytes)) {
|
||||||
fs->total_bytes = i64TotalBytes;
|
fs->used_bytes = i64TotalBytes - i64FreeBytes;
|
||||||
fs->has_total_bytes = true;
|
fs->total_bytes = i64TotalBytes;
|
||||||
fs->has_used_bytes = true;
|
fs->has_total_bytes = true;
|
||||||
}
|
fs->has_used_bytes = true;
|
||||||
}
|
}
|
||||||
wcstombs(fs_name, wfs_name, sizeof(wfs_name));
|
wcstombs(fs_name, wfs_name, sizeof(wfs_name));
|
||||||
fs->type = g_strdup(fs_name);
|
fs->type = g_strdup(fs_name);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue