Blame SOURCES/0001-qga-win-Detect-OS-based-on-Windows-10-by-first-build.patch

53c30d
From 4eb0bed855a3f2001a3438a58933164046eefb88 Mon Sep 17 00:00:00 2001
53c30d
From: Kostiantyn Kostiuk <konstantin@daynix.com>
53c30d
Date: Tue, 14 Sep 2021 10:28:44 +0000
53c30d
Subject: [PATCH 1/2] qga-win: Detect OS based on Windows 10 by first build
53c30d
 number
53c30d
53c30d
Windows Server 2016, 2019, 2022 are based on Windows 10 and
53c30d
have the same major and minor versions. So, the only way to
53c30d
detect the proper version is to use the build number.
53c30d
53c30d
Before this commit, the guest agent use the last build number
53c30d
for each OS, but it causes problems when new OS releases.
53c30d
There are few preview versions before release, and we
53c30d
can't update this list.
53c30d
53c30d
After this commit, the guest agent will use the first build
53c30d
number. For each new preview version or release version,
53c30d
Microsoft increases the build number, so we can add the number
53c30d
of the first preview build and this will work until the new
53c30d
OS release.
53c30d
53c30d
Signed-off-by: Kostiantyn Kostiuk <konstantin@daynix.com>
53c30d
---
53c30d
 qga/commands-win32.c | 18 +++++++++++-------
53c30d
 1 file changed, 11 insertions(+), 7 deletions(-)
53c30d
53c30d
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
53c30d
index 4e84afd83b..a8e9d40b31 100644
53c30d
--- a/qga/commands-win32.c
53c30d
+++ b/qga/commands-win32.c
53c30d
@@ -2179,7 +2179,7 @@ static ga_matrix_lookup_t const WIN_VERSION_MATRIX[2][8] = {
53c30d
 };
53c30d
53c30d
 typedef struct _ga_win_10_0_server_t {
53c30d
-    int final_build;
53c30d
+    int first_build;
53c30d
     char const *version;
53c30d
     char const *version_id;
53c30d
 } ga_win_10_0_server_t;
53c30d
@@ -2219,18 +2219,22 @@ static char *ga_get_win_name(OSVERSIONINFOEXW const *os_version, bool id)
53c30d
     int tbl_idx = (os_version->wProductType != VER_NT_WORKSTATION);
53c30d
     ga_matrix_lookup_t const *table = WIN_VERSION_MATRIX[tbl_idx];
53c30d
     ga_win_10_0_server_t const *win_10_0_table = WIN_10_0_SERVER_VERSION_MATRIX;
53c30d
+    ga_win_10_0_server_t const *win_10_0_version = NULL;
53c30d
     while (table->version != NULL) {
53c30d
         if (major == 10 && minor == 0 && tbl_idx) {
53c30d
             while (win_10_0_table->version != NULL) {
53c30d
-                if (build <= win_10_0_table->final_build) {
53c30d
-                    if (id) {
53c30d
-                        return g_strdup(win_10_0_table->version_id);
53c30d
-                    } else {
53c30d
-                        return g_strdup(win_10_0_table->version);
53c30d
-                    }
53c30d
+                if (build >= win_10_0_table->first_build) {
53c30d
+                    win_10_0_version = win_10_0_table;
53c30d
                 }
53c30d
                 win_10_0_table++;
53c30d
             }
53c30d
+            if (win_10_0_table) {
53c30d
+                if (id) {
53c30d
+                    return g_strdup(win_10_0_version->version_id);
53c30d
+                } else {
53c30d
+                    return g_strdup(win_10_0_version->version);
53c30d
+                }
53c30d
+            }
53c30d
         } else if (major == table->major && minor == table->minor) {
53c30d
             if (id) {
53c30d
                 return g_strdup(table->version_id);
53c30d
--
53c30d
2.33.0