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