[PATCH 8/8] system/globals: Build as common code

Philippe Mathieu-Daudé posted 8 patches 1 month, 3 weeks ago
There is a newer version of this series
[PATCH 8/8] system/globals: Build as common code
Posted by Philippe Mathieu-Daudé 1 month, 3 weeks ago
Now than all targets have the graphic dimension variables
initialized the same way, we can move them to the common
file unit, having them built once. Remove the now empty
globals-target.c file.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 system/globals-target.c | 14 --------------
 system/globals.c        |  3 +++
 system/meson.build      |  4 ----
 3 files changed, 3 insertions(+), 18 deletions(-)
 delete mode 100644 system/globals-target.c

diff --git a/system/globals-target.c b/system/globals-target.c
deleted file mode 100644
index ffa6c308b59..00000000000
--- a/system/globals-target.c
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * Global variables that should not exist (target specific)
- *
- * Copyright (c) 2003-2008 Fabrice Bellard
- *
- * SPDX-License-Identifier: MIT
- */
-
-#include "qemu/osdep.h"
-#include "system/system.h"
-
-int graphic_width;
-int graphic_height;
-int graphic_depth;
diff --git a/system/globals.c b/system/globals.c
index c33f6ed3902..34fd3ce9c72 100644
--- a/system/globals.c
+++ b/system/globals.c
@@ -49,6 +49,9 @@ bool enable_cpu_pm;
 int autostart = 1;
 int vga_interface_type = VGA_NONE;
 bool vga_interface_created;
+int graphic_width;
+int graphic_height;
+int graphic_depth;
 Chardev *parallel_hds[MAX_PARALLEL_PORTS];
 QEMUOptionRom option_rom[MAX_OPTION_ROMS];
 int nb_option_roms;
diff --git a/system/meson.build b/system/meson.build
index d91703d3dcc..579e8353d53 100644
--- a/system/meson.build
+++ b/system/meson.build
@@ -1,7 +1,3 @@
-specific_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_true: [files(
-  'globals-target.c',
-)])
-
 system_ss.add(files(
   'vl.c',
 ), sdl, libpmem, libdaxctl)
-- 
2.52.0


Re: [PATCH 8/8] system/globals: Build as common code
Posted by BALATON Zoltan 1 month, 3 weeks ago
On Sat, 14 Feb 2026, Philippe Mathieu-Daudé wrote:
> Now than all targets have the graphic dimension variables

Typo: ^^^^ that

> initialized the same way, we can move them to the common
> file unit, having them built once. Remove the now empty
> globals-target.c file.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> system/globals-target.c | 14 --------------
> system/globals.c        |  3 +++
> system/meson.build      |  4 ----
> 3 files changed, 3 insertions(+), 18 deletions(-)
> delete mode 100644 system/globals-target.c
>
> diff --git a/system/globals-target.c b/system/globals-target.c
> deleted file mode 100644
> index ffa6c308b59..00000000000
> --- a/system/globals-target.c
> +++ /dev/null
> @@ -1,14 +0,0 @@
> -/*
> - * Global variables that should not exist (target specific)
> - *
> - * Copyright (c) 2003-2008 Fabrice Bellard
> - *
> - * SPDX-License-Identifier: MIT
> - */
> -
> -#include "qemu/osdep.h"
> -#include "system/system.h"
> -
> -int graphic_width;
> -int graphic_height;
> -int graphic_depth;
> diff --git a/system/globals.c b/system/globals.c
> index c33f6ed3902..34fd3ce9c72 100644
> --- a/system/globals.c
> +++ b/system/globals.c
> @@ -49,6 +49,9 @@ bool enable_cpu_pm;
> int autostart = 1;
> int vga_interface_type = VGA_NONE;
> bool vga_interface_created;
> +int graphic_width;
> +int graphic_height;
> +int graphic_depth;

Where do other machines get their default values from now? This used to 
have #else 800x600x32 which is the default resolution when not specifying 
a -g option and some machines may depend on that. Where that default is
established now?

Regards,
BALATON Zoltan

> Chardev *parallel_hds[MAX_PARALLEL_PORTS];
> QEMUOptionRom option_rom[MAX_OPTION_ROMS];
> int nb_option_roms;
> diff --git a/system/meson.build b/system/meson.build
> index d91703d3dcc..579e8353d53 100644
> --- a/system/meson.build
> +++ b/system/meson.build
> @@ -1,7 +1,3 @@
> -specific_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_true: [files(
> -  'globals-target.c',
> -)])
> -
> system_ss.add(files(
>   'vl.c',
> ), sdl, libpmem, libdaxctl)
>
Re: [PATCH 8/8] system/globals: Build as common code
Posted by Philippe Mathieu-Daudé 1 month, 3 weeks ago
On 14/2/26 12:53, BALATON Zoltan wrote:
> On Sat, 14 Feb 2026, Philippe Mathieu-Daudé wrote:
>> Now than all targets have the graphic dimension variables
> 
> Typo: ^^^^ that
> 
>> initialized the same way, we can move them to the common
>> file unit, having them built once. Remove the now empty
>> globals-target.c file.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>> system/globals-target.c | 14 --------------
>> system/globals.c        |  3 +++
>> system/meson.build      |  4 ----
>> 3 files changed, 3 insertions(+), 18 deletions(-)
>> delete mode 100644 system/globals-target.c
>>
>> diff --git a/system/globals-target.c b/system/globals-target.c
>> deleted file mode 100644
>> index ffa6c308b59..00000000000
>> --- a/system/globals-target.c
>> +++ /dev/null
>> @@ -1,14 +0,0 @@
>> -/*
>> - * Global variables that should not exist (target specific)
>> - *
>> - * Copyright (c) 2003-2008 Fabrice Bellard
>> - *
>> - * SPDX-License-Identifier: MIT
>> - */
>> -
>> -#include "qemu/osdep.h"
>> -#include "system/system.h"
>> -
>> -int graphic_width;
>> -int graphic_height;
>> -int graphic_depth;
>> diff --git a/system/globals.c b/system/globals.c
>> index c33f6ed3902..34fd3ce9c72 100644
>> --- a/system/globals.c
>> +++ b/system/globals.c
>> @@ -49,6 +49,9 @@ bool enable_cpu_pm;
>> int autostart = 1;
>> int vga_interface_type = VGA_NONE;
>> bool vga_interface_created;
>> +int graphic_width;
>> +int graphic_height;
>> +int graphic_depth;
> 
> Where do other machines get their default values from now?

These are the same globals... If you use -g WxH[xD] they will
be initialized from 0 -> W, 0 -> H, 0 -> D; then machine_init
code will notice the globals aren't 0 anymore.

> This used to 
> have #else 800x600x32 which is the default resolution when not 
> specifying a -g option and some machines may depend on that. Where that 
> default is
> established now?
> 
> Regards,
> BALATON Zoltan
> 
>> Chardev *parallel_hds[MAX_PARALLEL_PORTS];
>> QEMUOptionRom option_rom[MAX_OPTION_ROMS];
>> int nb_option_roms;
>> diff --git a/system/meson.build b/system/meson.build
>> index d91703d3dcc..579e8353d53 100644
>> --- a/system/meson.build
>> +++ b/system/meson.build
>> @@ -1,7 +1,3 @@
>> -specific_ss.add(when: 'CONFIG_SYSTEM_ONLY', if_true: [files(
>> -  'globals-target.c',
>> -)])
>> -
>> system_ss.add(files(
>>   'vl.c',
>> ), sdl, libpmem, libdaxctl)
>>


Re: [PATCH 8/8] system/globals: Build as common code
Posted by BALATON Zoltan 1 month, 3 weeks ago
On Sat, 14 Feb 2026, BALATON Zoltan wrote:
> On Sat, 14 Feb 2026, Philippe Mathieu-Daudé wrote:
>> Now than all targets have the graphic dimension variables
>
> Typo: ^^^^ that
>
>> initialized the same way, we can move them to the common
>> file unit, having them built once. Remove the now empty
>> globals-target.c file.
>> 
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>> system/globals-target.c | 14 --------------
>> system/globals.c        |  3 +++
>> system/meson.build      |  4 ----
>> 3 files changed, 3 insertions(+), 18 deletions(-)
>> delete mode 100644 system/globals-target.c
>> 
>> diff --git a/system/globals-target.c b/system/globals-target.c
>> deleted file mode 100644
>> index ffa6c308b59..00000000000
>> --- a/system/globals-target.c
>> +++ /dev/null
>> @@ -1,14 +0,0 @@
>> -/*
>> - * Global variables that should not exist (target specific)
>> - *
>> - * Copyright (c) 2003-2008 Fabrice Bellard
>> - *
>> - * SPDX-License-Identifier: MIT
>> - */
>> -
>> -#include "qemu/osdep.h"
>> -#include "system/system.h"
>> -
>> -int graphic_width;
>> -int graphic_height;
>> -int graphic_depth;
>> diff --git a/system/globals.c b/system/globals.c
>> index c33f6ed3902..34fd3ce9c72 100644
>> --- a/system/globals.c
>> +++ b/system/globals.c
>> @@ -49,6 +49,9 @@ bool enable_cpu_pm;
>> int autostart = 1;
>> int vga_interface_type = VGA_NONE;
>> bool vga_interface_created;
>> +int graphic_width;
>> +int graphic_height;
>> +int graphic_depth;
>
> Where do other machines get their default values from now? This used to have 
> #else 800x600x32 which is the default resolution when not specifying a -g 
> option and some machines may depend on that. Where that default is
> established now?

So it seems this reverts your commit 5dc4337f7908 from a year ago. The 
message linked in that commit message says these are only used by ppc and 
sparc machines. In that case maybe not needed here as global and better be 
moved to ppc.{h,c} after removing the special cases as I thought in 
previous patch.

Regards,
BALATON Zoltan
Re: [PATCH 8/8] system/globals: Build as common code
Posted by BALATON Zoltan 1 month, 3 weeks ago
On Sat, 14 Feb 2026, BALATON Zoltan wrote:
> On Sat, 14 Feb 2026, BALATON Zoltan wrote:
>> On Sat, 14 Feb 2026, Philippe Mathieu-Daudé wrote:
>>> Now than all targets have the graphic dimension variables
>> 
>> Typo: ^^^^ that
>> 
>>> initialized the same way, we can move them to the common
>>> file unit, having them built once. Remove the now empty
>>> globals-target.c file.
>>> 
>>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>> ---
>>> system/globals-target.c | 14 --------------
>>> system/globals.c        |  3 +++
>>> system/meson.build      |  4 ----
>>> 3 files changed, 3 insertions(+), 18 deletions(-)
>>> delete mode 100644 system/globals-target.c
>>> 
>>> diff --git a/system/globals-target.c b/system/globals-target.c
>>> deleted file mode 100644
>>> index ffa6c308b59..00000000000
>>> --- a/system/globals-target.c
>>> +++ /dev/null
>>> @@ -1,14 +0,0 @@
>>> -/*
>>> - * Global variables that should not exist (target specific)
>>> - *
>>> - * Copyright (c) 2003-2008 Fabrice Bellard
>>> - *
>>> - * SPDX-License-Identifier: MIT
>>> - */
>>> -
>>> -#include "qemu/osdep.h"
>>> -#include "system/system.h"
>>> -
>>> -int graphic_width;
>>> -int graphic_height;
>>> -int graphic_depth;
>>> diff --git a/system/globals.c b/system/globals.c
>>> index c33f6ed3902..34fd3ce9c72 100644
>>> --- a/system/globals.c
>>> +++ b/system/globals.c
>>> @@ -49,6 +49,9 @@ bool enable_cpu_pm;
>>> int autostart = 1;
>>> int vga_interface_type = VGA_NONE;
>>> bool vga_interface_created;
>>> +int graphic_width;
>>> +int graphic_height;
>>> +int graphic_depth;
>> 
>> Where do other machines get their default values from now? This used to 
>> have #else 800x600x32 which is the default resolution when not specifying a 
>> -g option and some machines may depend on that. Where that default is
>> established now?
>
> So it seems this reverts your commit 5dc4337f7908 from a year ago. The 
> message linked in that commit message says these are only used by ppc and 
> sparc machines. In that case maybe not needed here as global and better be 
> moved to ppc.{h,c} after removing the special cases as I thought in previous 
> patch.

Of course I should also think before speaking because then where do sparc 
and q800 get those variables and the command line parsing that sets 
them... So this needs to stay as globals for now but can be set to 
800x600x32 as global defaults (that sparc an 188 will replace with their 
own) so the ppc patch is not needed then.

Regards,
BALATON Zoltan
Re: [PATCH 8/8] system/globals: Build as common code
Posted by Pierrick Bouvier 1 month, 3 weeks ago
On 2/13/26 6:12 PM, Philippe Mathieu-Daudé wrote:
> Now than all targets have the graphic dimension variables
> initialized the same way, we can move them to the common
> file unit, having them built once. Remove the now empty
> globals-target.c file.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   system/globals-target.c | 14 --------------
>   system/globals.c        |  3 +++
>   system/meson.build      |  4 ----
>   3 files changed, 3 insertions(+), 18 deletions(-)
>   delete mode 100644 system/globals-target.c
> 

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>