Skip to contentSkip to conversation

hw/core/machine: Extract compat properties to machine-compat.c

PATCH In review Philippe Mathieu-Daudé 3 participants 5 messages Sep 30, 2024 – Oct 8, 2024 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover hw/core/machine: Extract compat properties to machine-compat.c

Extract machine compat properties to machine-compat.c, make the unit target specific to be able to compile with target specific compat properties.

Philippe Mathieu-Daudé (2):
hw/core/machine: Add missing 'units.h' and 'error-report.h' headers hw/core/machine: Extract compat properties to machine-compat.c

 MAINTAINERS              |   1 +
 hw/core/machine-compat.c | 287 +++++++++++++++++++++++++++++++++++++++
 hw/core/machine.c        | 279 +------------------------------------
 hw/core/meson.build      |   3 +
 4 files changed, 293 insertions(+), 277 deletions(-)
 create mode 100644 hw/core/machine-compat.c
Signature · 1 line
2.45.2
#1 lore raw

PATCH 1/2 hw/core/machine: Add missing 'units.h' and 'error-report.h' headers

Include the missing "qemu/units.h" to fix when refactoring code:

../hw/core/machine.c:743:34: error: use of undeclared identifier 'MiB'
743 | mc->default_ram_size = 128 * MiB;
| ^
../hw/core/machine.c:750:44: error: use of undeclared identifier 'TiB'
750 | mc->smbios_memory_device_size = 2047 * TiB;
| ^

and "qemu/error-report.h" to fix:

../hw/core/machine.c:1029:13: error: call to undeclared function 'error_report' [-Wimplicit-function-declaration]

 1029 |             error_report("NUMA node %" PRIu16 " is missing, use "
      |             ^
  ../hw/core/machine.c:1240:9: error: call to undeclared function 'warn_report' [-Wimplicit-function-declaration]
 1240 |         warn_report("CPU model %s is deprecated -- %s",
      |         ^
---
 hw/core/machine.c | 2 ++
 1 file changed, 2 insertions(+)
hw/core/machine.c +2 -0
index adaba17eba..94d3b11a53 100644
@@ -11,10 +11,12 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/units.h"
 #include "qemu/accel.h"
 #include "sysemu/replay.h"
 #include "hw/boards.h"
 #include "hw/loader.h"
+#include "qemu/error-report.h"
 #include "qapi/error.h"
 #include "qapi/qapi-visit-machine.h"
 #include "qemu/madvise.h"
Signature · 1 line
2.45.2
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] hw/core/machine: Add missing 'units.h' and 'error-report.h' headers

Quoted 24 lines · Philippe Mathieu-Daudé

Date: Tue, 1 Oct 2024 00:18:59 +0200
From: Philippe Mathieu-Daudé <[email protected]>
Subject: [PATCH 1/2] hw/core/machine: Add missing 'units.h' and
'error-report.h' headers
X-Mailer: git-send-email 2.45.2

Include the missing "qemu/units.h" to fix when refactoring code:

../hw/core/machine.c:743:34: error: use of undeclared identifier 'MiB'
743 | mc->default_ram_size = 128 * MiB;
| ^
../hw/core/machine.c:750:44: error: use of undeclared identifier 'TiB'
750 | mc->smbios_memory_device_size = 2047 * TiB;
| ^

and "qemu/error-report.h" to fix:

../hw/core/machine.c:1029:13: error: call to undeclared function 'error_report' [-Wimplicit-function-declaration]

 1029 |             error_report("NUMA node %" PRIu16 " is missing, use "
      |             ^
  ../hw/core/machine.c:1240:9: error: call to undeclared function 'warn_report' [-Wimplicit-function-declaration]
 1240 |         warn_report("CPU model %s is deprecated -- %s",
      |         ^
Quoted 4 lines
---
 hw/core/machine.c | 2 ++
 1 file changed, 2 insertions(+)
#3 lore raw

PATCH 2/2 hw/core/machine: Extract compat properties to machine-compat.c

In reply to Philippe Mathieu-Daudé

Extract machine compat properties to machine-compat.c. Add the unit to the meson specific_ss[] source set so we can use target specific (poisoned) definitions.

---
 MAINTAINERS              |   1 +
 hw/core/machine-compat.c | 287 +++++++++++++++++++++++++++++++++++++++
 hw/core/machine.c        | 277 -------------------------------------
 hw/core/meson.build      |   3 +
 4 files changed, 291 insertions(+), 277 deletions(-)
 create mode 100644 hw/core/machine-compat.c
MAINTAINERS +1 -0
index 62f5255f40..b89e2dae9e 100644
@@ -1886,6 +1886,7 @@ F: hw/core/cpu-common.c
 F: hw/core/cpu-sysemu.c
 F: hw/core/machine-qmp-cmds.c
 F: hw/core/machine.c
+F: hw/core/machine-compat.c
 F: hw/core/machine-smp.c
 F: hw/core/null-machine.c
 F: hw/core/numa.c
hw/core/machine-compat.c new file +287 -0

287 lines not on this page · raw message

hw/core/machine.c +0 -277

289 lines not on this page · raw message

hw/core/meson.build +3 -0
index a3d9bab9f4..1087f4bfad 100644
@@ -45,3 +45,6 @@ system_ss.add(files(
   'vm-change-state-handler.c',
   'clock-vmstate.c',
 ))
+specific_ss.add(files(
+  'machine-compat.c',
+))
Signature · 1 line
2.45.2
#4 lore raw
Quoted 3 lines · Philippe Mathieu-Daudé

Extract machine compat properties to machine-compat.c. Add the unit to the meson specific_ss[] source set so we can use target specific (poisoned) definitions.

Why is this required? Shouldn't target-specific settings rather be done in the various machine files instead?

Thomas