qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qga: Support for Windows Server 2019 in the get-osinfo command
@ 2018-12-19  8:40 Bishara AbuHattoum
  2018-12-19  8:40 ` [Qemu-devel] [PATCH] qga-win: Adding support for Windows Server 2019 " Bishara AbuHattoum
  0 siblings, 1 reply; 3+ messages in thread
From: Bishara AbuHattoum @ 2018-12-19  8:40 UTC (permalink / raw)
  To: qemu-devel, Michael Roth; +Cc: Yan Vugenfirer, Samee Jubran

This patch of a one commit fixes a bug that has been reported in the bugzilla:
https://bugzilla.redhat.com/show_bug.cgi?id=1659071

In which the command get-osinfo doesnt work as expected when the ga is running
on a Windows Server 2019 guest.

Bishara AbuHattoum (1):
  qga-win: Adding support for Windows Server 2019 get-osinfo command

 qga/commands-win32.c | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Qemu-devel] [PATCH] qga-win: Adding support for Windows Server 2019 get-osinfo command
  2018-12-19  8:40 [Qemu-devel] [PATCH] qga: Support for Windows Server 2019 in the get-osinfo command Bishara AbuHattoum
@ 2018-12-19  8:40 ` Bishara AbuHattoum
  2019-02-13 14:04   ` Tomáš Golembiovský
  0 siblings, 1 reply; 3+ messages in thread
From: Bishara AbuHattoum @ 2018-12-19  8:40 UTC (permalink / raw)
  To: qemu-devel, Michael Roth; +Cc: Yan Vugenfirer, Samee Jubran

Since Windows Server 2016, Microsoft stopped upgrading the major and minor
versions of their new Windows Server product, so, the current functionality
of checking major and minor version numbers to determine the Windows Server
version wont work as expected.
The implemented solution here is to use the build number in addition to the
major and minor version numbers of the product to determine the Windows
Server product version.
The final build number of Windows Server 2016 is 14939, and
the final build number of Windows Server 2019 is 17764, so any Windows
Server product that has the major version of 10 and minor version of 0
with a build number lower or equal to 14939 will resemble 2016 and if the
build number is lower or equal to 17763 will resemble 2019.

Reference:
https://techcommunity.microsoft.com/t5/Windows-Server-Insiders/Windows-Server-2019-version-info/m-p/293112/highlight/true#M859

Signed-off-by: Bishara AbuHattoum <bishara@daynix.com>
---
 qga/commands-win32.c | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 62e1b51..3985b40 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -2009,12 +2009,24 @@ static ga_matrix_lookup_t const WIN_VERSION_MATRIX[2][8] = {
         { 6, 1, "Microsoft Windows Server 2008 R2",     "2008r2"},
         { 6, 2, "Microsoft Windows Server 2012",        "2012"},
         { 6, 3, "Microsoft Windows Server 2012 R2",     "2012r2"},
-        {10, 0, "Microsoft Windows Server 2016",        "2016"},
+        { 0, 0, 0},
         { 0, 0, 0},
         { 0, 0, 0}
     }
 };
 
+typedef struct _ga_win_10_0_server_t {
+    int final_build;
+    char const *version;
+    char const *version_id;
+} ga_win_10_0_server_t;
+
+static ga_win_10_0_server_t const WIN_10_0_SERVER_VERSION_MATRIX[3] = {
+    {14393, "Microsoft Windows Server 2016",    "2016"},
+    {17763, "Microsoft Windows Server 2019",    "2019"},
+    {0, 0}
+};
+
 static void ga_get_win_version(RTL_OSVERSIONINFOEXW *info, Error **errp)
 {
     typedef NTSTATUS(WINAPI * rtl_get_version_t)(
@@ -2039,10 +2051,23 @@ static char *ga_get_win_name(OSVERSIONINFOEXW const *os_version, bool id)
 {
     DWORD major = os_version->dwMajorVersion;
     DWORD minor = os_version->dwMinorVersion;
+    DWORD build = os_version->dwBuildNumber;
     int tbl_idx = (os_version->wProductType != VER_NT_WORKSTATION);
     ga_matrix_lookup_t const *table = WIN_VERSION_MATRIX[tbl_idx];
+    ga_win_10_0_server_t const *win_10_0_table = WIN_10_0_SERVER_VERSION_MATRIX;
     while (table->version != NULL) {
-        if (major == table->major && minor == table->minor) {
+        if (major == 10 && minor == 0 && tbl_idx) {
+            while (win_10_0_table->version != NULL) {
+                if (build <= win_10_0_table->final_build) {
+                    if (id) {
+                        return g_strdup(win_10_0_table->version_id);
+                    } else {
+                        return g_strdup(win_10_0_table->version);
+                    }
+                }
+                win_10_0_table++;
+            }
+        } else if (major == table->major && minor == table->minor) {
             if (id) {
                 return g_strdup(table->version_id);
             } else {
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] qga-win: Adding support for Windows Server 2019 get-osinfo command
  2018-12-19  8:40 ` [Qemu-devel] [PATCH] qga-win: Adding support for Windows Server 2019 " Bishara AbuHattoum
@ 2019-02-13 14:04   ` Tomáš Golembiovský
  0 siblings, 0 replies; 3+ messages in thread
From: Tomáš Golembiovský @ 2019-02-13 14:04 UTC (permalink / raw)
  To: Bishara AbuHattoum; +Cc: qemu-devel, Michael Roth, Yan Vugenfirer, Samee Jubran

On Wed, 19 Dec 2018 10:40:51 +0200
Bishara AbuHattoum <bishara@daynix.com> wrote:

> Since Windows Server 2016, Microsoft stopped upgrading the major and minor
> versions of their new Windows Server product, so, the current functionality
> of checking major and minor version numbers to determine the Windows Server
> version wont work as expected.
> The implemented solution here is to use the build number in addition to the
> major and minor version numbers of the product to determine the Windows
> Server product version.
> The final build number of Windows Server 2016 is 14939, and
> the final build number of Windows Server 2019 is 17764, so any Windows
> Server product that has the major version of 10 and minor version of 0
> with a build number lower or equal to 14939 will resemble 2016 and if the
> build number is lower or equal to 17763 will resemble 2019.
> 
> Reference:
> https://techcommunity.microsoft.com/t5/Windows-Server-Insiders/Windows-Server-2019-version-info/m-p/293112/highlight/true#M859
> 
> Signed-off-by: Bishara AbuHattoum <bishara@daynix.com>
> ---
>  qga/commands-win32.c | 29 +++++++++++++++++++++++++++--
>  1 file changed, 27 insertions(+), 2 deletions(-)
> 
> diff --git a/qga/commands-win32.c b/qga/commands-win32.c
> index 62e1b51..3985b40 100644
> --- a/qga/commands-win32.c
> +++ b/qga/commands-win32.c
> @@ -2009,12 +2009,24 @@ static ga_matrix_lookup_t const WIN_VERSION_MATRIX[2][8] = {
>          { 6, 1, "Microsoft Windows Server 2008 R2",     "2008r2"},
>          { 6, 2, "Microsoft Windows Server 2012",        "2012"},
>          { 6, 3, "Microsoft Windows Server 2012 R2",     "2012r2"},
> -        {10, 0, "Microsoft Windows Server 2016",        "2016"},
> +        { 0, 0, 0},
>          { 0, 0, 0},
>          { 0, 0, 0}
>      }
>  };
>  
> +typedef struct _ga_win_10_0_server_t {
> +    int final_build;
> +    char const *version;
> +    char const *version_id;
> +} ga_win_10_0_server_t;
> +
> +static ga_win_10_0_server_t const WIN_10_0_SERVER_VERSION_MATRIX[3] = {
> +    {14393, "Microsoft Windows Server 2016",    "2016"},
> +    {17763, "Microsoft Windows Server 2019",    "2019"},
> +    {0, 0}
> +};
> +
>  static void ga_get_win_version(RTL_OSVERSIONINFOEXW *info, Error **errp)
>  {
>      typedef NTSTATUS(WINAPI * rtl_get_version_t)(
> @@ -2039,10 +2051,23 @@ static char *ga_get_win_name(OSVERSIONINFOEXW const *os_version, bool id)
>  {
>      DWORD major = os_version->dwMajorVersion;
>      DWORD minor = os_version->dwMinorVersion;
> +    DWORD build = os_version->dwBuildNumber;
>      int tbl_idx = (os_version->wProductType != VER_NT_WORKSTATION);
>      ga_matrix_lookup_t const *table = WIN_VERSION_MATRIX[tbl_idx];
> +    ga_win_10_0_server_t const *win_10_0_table = WIN_10_0_SERVER_VERSION_MATRIX;
>      while (table->version != NULL) {
> -        if (major == table->major && minor == table->minor) {
> +        if (major == 10 && minor == 0 && tbl_idx) {
> +            while (win_10_0_table->version != NULL) {
> +                if (build <= win_10_0_table->final_build) {

You should reverse the order of entries in you table for this to work,
or break after first match. Otherwise you will always match the last
entry.

    Tomas

> +                    if (id) {
> +                        return g_strdup(win_10_0_table->version_id);
> +                    } else {
> +                        return g_strdup(win_10_0_table->version);
> +                    }
> +                }
> +                win_10_0_table++;
> +            }
> +        } else if (major == table->major && minor == table->minor) {
>              if (id) {
>                  return g_strdup(table->version_id);
>              } else {
> -- 
> 1.8.3.1
> 
> 


-- 
Tomáš Golembiovský <tgolembi@redhat.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-02-13 14:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-19  8:40 [Qemu-devel] [PATCH] qga: Support for Windows Server 2019 in the get-osinfo command Bishara AbuHattoum
2018-12-19  8:40 ` [Qemu-devel] [PATCH] qga-win: Adding support for Windows Server 2019 " Bishara AbuHattoum
2019-02-13 14:04   ` Tomáš Golembiovský

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).