aboutsummaryrefslogtreecommitdiff
path: root/qga
diff options
context:
space:
mode:
Diffstat (limited to 'qga')
-rw-r--r--qga/commands-win32.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 318d760a74..98d9735389 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -865,6 +865,19 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
GuestFilesystemTrimResponse *resp;
HANDLE handle;
WCHAR guid[MAX_PATH] = L"";
+ OSVERSIONINFO osvi;
+ BOOL win8_or_later;
+
+ ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
+ osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&osvi);
+ win8_or_later = (osvi.dwMajorVersion > 6 ||
+ ((osvi.dwMajorVersion == 6) &&
+ (osvi.dwMinorVersion >= 2)));
+ if (!win8_or_later) {
+ error_setg(errp, "fstrim is only supported for Win8+");
+ return NULL;
+ }
handle = FindFirstVolumeW(guid, ARRAYSIZE(guid));
if (handle == INVALID_HANDLE_VALUE) {