diff mbox series

[v2,1/1] qga-win: Add support of Windows Server 2025 in get-osinfo command

Message ID 20240222025437.58996-2-demeng@redhat.com
State New
Headers show
Series update the array size | expand

Commit Message

Dehan Meng Feb. 22, 2024, 2:54 a.m. UTC
Add support of Windows Server 2025 in get-osinfo command

Signed-off-by: Dehan Meng <demeng@redhat.com>
---
 qga/commands-win32.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Philippe Mathieu-Daudé Feb. 22, 2024, 8:08 a.m. UTC | #1
Hi Dehan,

On 22/2/24 03:54, Dehan Meng wrote:
> Add support of Windows Server 2025 in get-osinfo command
> 
> Signed-off-by: Dehan Meng <demeng@redhat.com>
> ---
>   qga/commands-win32.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/qga/commands-win32.c b/qga/commands-win32.c
> index 697c65507c..b37fa7b5ba 100644
> --- a/qga/commands-win32.c
> +++ b/qga/commands-win32.c
> @@ -2150,10 +2150,11 @@ typedef struct _ga_win_10_0_t {
>       char const *version_id;
>   } ga_win_10_0_t;
>   
> -static ga_win_10_0_t const WIN_10_0_SERVER_VERSION_MATRIX[4] = {
> +static ga_win_10_0_t const WIN_10_0_SERVER_VERSION_MATRIX[5] = {

These arrays are NULL-terminated, they are iterated until
the NULL value is found:

    while (table->version != NULL) {

So setting their size isn't really useful.

>       {14393, "Microsoft Windows Server 2016",    "2016"},
>       {17763, "Microsoft Windows Server 2019",    "2019"},
>       {20344, "Microsoft Windows Server 2022",    "2022"},
> +    {26040, "MIcrosoft Windows Server 2025",    "2025"},
>       {0, 0}
>   };
>   

IMO this can be simplified in a preliminary patch as (untested):

-- >8 --
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index a1015757d8..c14c5cc4eb 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -2126,3 +2126,3 @@ typedef struct _ga_matrix_lookup_t {

-static ga_matrix_lookup_t const WIN_VERSION_MATRIX[2][7] = {
+static const ga_matrix_lookup_t WIN_VERSION_MATRIX[2][] = {
      {
@@ -2135,3 +2135,3 @@ static ga_matrix_lookup_t const 
WIN_VERSION_MATRIX[2][7] = {
          { 6, 3, "Microsoft Windows 8.1",    "8.1"},
-        { 0, 0, 0}
+        { }
      },{
@@ -2143,4 +2143,3 @@ static ga_matrix_lookup_t const 
WIN_VERSION_MATRIX[2][7] = {
          { 6, 3, "Microsoft Windows Server 2012 R2",     "2012r2"},
-        { 0, 0, 0},
-        { 0, 0, 0}
+        { },
      }
@@ -2154,3 +2153,3 @@ typedef struct _ga_win_10_0_t {

-static ga_win_10_0_t const WIN_10_0_SERVER_VERSION_MATRIX[4] = {
+static const ga_win_10_0_t WIN_10_0_SERVER_VERSION_MATRIX[] = {
      {14393, "Microsoft Windows Server 2016",    "2016"},
@@ -2158,9 +2157,9 @@ static ga_win_10_0_t const 
WIN_10_0_SERVER_VERSION_MATRIX[4] = {
      {20344, "Microsoft Windows Server 2022",    "2022"},
-    {0, 0}
+    { }
  };

-static ga_win_10_0_t const WIN_10_0_CLIENT_VERSION_MATRIX[3] = {
+static const ga_win_10_0_t WIN_10_0_CLIENT_VERSION_MATRIX[] = {
      {10240, "Microsoft Windows 10",    "10"},
      {22000, "Microsoft Windows 11",    "11"},
-    {0, 0}
+    { }
  };
---

Then your patch becomes a one-line one.

Regard,

Phil.
diff mbox series

Patch

diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 697c65507c..b37fa7b5ba 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -2150,10 +2150,11 @@  typedef struct _ga_win_10_0_t {
     char const *version_id;
 } ga_win_10_0_t;
 
-static ga_win_10_0_t const WIN_10_0_SERVER_VERSION_MATRIX[4] = {
+static ga_win_10_0_t const WIN_10_0_SERVER_VERSION_MATRIX[5] = {
     {14393, "Microsoft Windows Server 2016",    "2016"},
     {17763, "Microsoft Windows Server 2019",    "2019"},
     {20344, "Microsoft Windows Server 2022",    "2022"},
+    {26040, "MIcrosoft Windows Server 2025",    "2025"},
     {0, 0}
 };