Skip to contentSkip to conversation

softmmu: List CPU types again

PATCH-for-7.0 Philippe Mathieu-Daudé 4 participants 5 messages Mar 10, 2022 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

From: Philippe Mathieu-Daudé <[email protected]>

Commit e0220bb5b2 made cpus.c target-agnostic but didn't notice the cpu_list() function is only defined in target-specific code in "cpu.h". Extract list_cpus() from the generic cpus.c into a new target-specific unit.

Fixes e0220bb5b2 ("softmmu: Build target-agnostic objects once")
---
 softmmu/cpus.c      |  8 --------
 softmmu/cpus_list.c | 36 ++++++++++++++++++++++++++++++++++++
 softmmu/meson.build |  1 +
 3 files changed, 37 insertions(+), 8 deletions(-)
 create mode 100644 softmmu/cpus_list.c
softmmu/cpus.c +0 -8
index e1d84c8ccb..7b75bb66d5 100644
@@ -728,14 +728,6 @@ int vm_stop_force_state(RunState state)
     }
 }
 
-void list_cpus(const char *optarg)
-{
-    /* XXX: implement xxx_cpu_list for targets that still miss it */
-#if defined(cpu_list)
-    cpu_list();
-#endif
-}
-
 void qmp_memsave(int64_t addr, int64_t size, const char *filename,
                  bool has_cpu, int64_t cpu_index, Error **errp)
 {
softmmu/cpus_list.c new file +36 -0
new file mode 100644
index 0000000000..59ef604423
@@ -0,0 +1,36 @@
+/*
+ * QEMU per target CPU list
+ *
+ * Copyright (c) 2003-2008 Fabrice Bellard
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "qemu/osdep.h"
+#include "sysemu/cpus.h"
+#include "cpu.h"
+
+void list_cpus(const char *optarg)
+{
+    /* XXX: implement xxx_cpu_list for targets that still miss it */
+#if defined(cpu_list)
+    cpu_list();
+#endif
+}
+
softmmu/meson.build +1 -0
index 8138248661..1df0ad286a 100644
@@ -1,5 +1,6 @@
 specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files(
   'arch_init.c',
+  'cpus_list.c',
   'ioport.c',
   'memory.c',
   'physmem.c',
Signature · 1 line
2.34.1
#1 lore raw

softmmu/cpus_list.c

Quoted 41 lines · Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <[email protected]>

Commit e0220bb5b2 made cpus.c target-agnostic but didn't notice the cpu_list() function is only defined in target-specific code in "cpu.h". Extract list_cpus() from the generic cpus.c into a new target-specific unit.

Fixes e0220bb5b2 ("softmmu: Build target-agnostic objects once")
---
  softmmu/cpus.c      |  8 --------
  softmmu/cpus_list.c | 36 ++++++++++++++++++++++++++++++++++++
  softmmu/meson.build |  1 +
  3 files changed, 37 insertions(+), 8 deletions(-)

create mode 100644 softmmu/cpus_list.c

softmmu/cpus.c +0 -8
index e1d84c8ccb..7b75bb66d5 100644
@@ -728,14 +728,6 @@ int vm_stop_force_state(RunState state)
      }
  }
 
-void list_cpus(const char *optarg)
-{
-    /* XXX: implement xxx_cpu_list for targets that still miss it */
-#if defined(cpu_list)
-    cpu_list();
-#endif
-}
-
  void qmp_memsave(int64_t addr, int64_t size, const char *filename,
                   bool has_cpu, int64_t cpu_index, Error **errp)
  {
softmmu/cpus_list.c new file +0 -0
new file mode 100644
index 0000000000..59ef604423

The other cpu*.c files in softmmu use a "-" instead of "_", so I'd also use a "-" for cpu-list.c.

softmmu/cpus_list.c line 4

Quoted 5 lines
softmmu/cpus_list.c new file +4 -0
@@ -0,0 +1,36 @@
+/*
+ * QEMU per target CPU list
+ *
+ * Copyright (c) 2003-2008 Fabrice Bellard

If you look at the history, Fabrice was hardly involved in this function, so I think it should be ok to drop this line in the new file.

Quoted 21 lines
softmmu/cpus_list.c new file +21 -0
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "qemu/osdep.h"
+#include "sysemu/cpus.h"

softmmu/cpus_list.c line 36

Quoted 10 lines
softmmu/cpus_list.c new file +10 -0
+#include "cpu.h"
+
+void list_cpus(const char *optarg)
+{
+    /* XXX: implement xxx_cpu_list for targets that still miss it */
+#if defined(cpu_list)
+    cpu_list();
+#endif
+}
+

No empty new lines at the end of files, please.

Thomas

#2 lore raw
Quoted 7 lines · Thomas Huth
Quoted 6 lines · Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <[email protected]>

Commit e0220bb5b2 made cpus.c target-agnostic but didn't notice the cpu_list() function is only defined in target-specific code in "cpu.h". Extract list_cpus() from the generic cpus.c into a new target-specific unit.

Let's just use cpu.c in the root, and move the prototype to include/exec/cpu-common.h. The function can be used just fine by linux-user and bsd-user as well, it's not softmmu-specific.

Paolo

Quoted 93 lines

softmmu/cpus_list.c

Quoted 33 lines
Fixes e0220bb5b2 ("softmmu: Build target-agnostic objects once")

---
  softmmu/cpus.c      |  8 -------- softmmu/cpus_list.c | 36 ++++++++++++++++++++++++++++++++++++ softmmu/meson.build |  1 +

  3 files changed, 37 insertions(+), 8 deletions(-)

  create mode 100644 softmmu/cpus_list.c

softmmu/cpus.c +0 -8
index e1d84c8ccb..7b75bb66d5 100644
@@ -728,14 +728,6 @@ int vm_stop_force_state(RunState state)
       }
   }
-void list_cpus(const char *optarg)
-{
-    /* XXX: implement xxx_cpu_list for targets that still miss it */
-#if defined(cpu_list)
-    cpu_list();
-#endif
-}
-
   void qmp_memsave(int64_t addr, int64_t size, const char *filename,
                    bool has_cpu, int64_t cpu_index, Error **errp)
   {
softmmu/cpus_list.c new file +0 -0
new file mode 100644
index 0000000000..59ef604423

The other cpu*.c files in softmmu use a "-" instead of "_", so I'd also use a "-" for cpu-list.c.

softmmu/cpus_list.c line 4

Quoted 5 lines
softmmu/cpus_list.c new file +4 -0
@@ -0,0 +1,36 @@
+/*
+ * QEMU per target CPU list
+ *
+ * Copyright (c) 2003-2008 Fabrice Bellard

If you look at the history, Fabrice was hardly involved in this function, so I think it should be ok to drop this line in the new file.

Quoted 32 lines
softmmu/cpus_list.c new file +1 -0
+ * Permission is hereby granted, free of charge, to any person 

obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */

softmmu/cpus_list.c new file +3 -0
+
+#include "qemu/osdep.h"
+#include "sysemu/cpus.h"

softmmu/cpus_list.c line 36

Quoted 10 lines
softmmu/cpus_list.c new file +10 -0
+#include "cpu.h"
+
+void list_cpus(const char *optarg)
+{
+    /* XXX: implement xxx_cpu_list for targets that still miss it */
+#if defined(cpu_list)
+    cpu_list();
+#endif
+}
+

No empty new lines at the end of files, please.

 Thomas

#3 lore raw
In reply to Thomas Huth
Quoted 35 lines · Thomas Huth
Quoted 34 lines · Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <[email protected]>

Commit e0220bb5b2 made cpus.c target-agnostic but didn't notice the cpu_list() function is only defined in target-specific code in "cpu.h". Extract list_cpus() from the generic cpus.c into a new target-specific unit.

Fixes e0220bb5b2 ("softmmu: Build target-agnostic objects once")

---
  softmmu/cpus.c      |  8 -------- softmmu/cpus_list.c | 36 ++++++++++++++++++++++++++++++++++++ softmmu/meson.build |  1 +

  3 files changed, 37 insertions(+), 8 deletions(-)

  create mode 100644 softmmu/cpus_list.c

softmmu/cpus.c +0 -8
index e1d84c8ccb..7b75bb66d5 100644
@@ -728,14 +728,6 @@ int vm_stop_force_state(RunState state)
       }
   }
-void list_cpus(const char *optarg)
-{
-    /* XXX: implement xxx_cpu_list for targets that still miss it */
-#if defined(cpu_list)
-    cpu_list();
-#endif
-}
-
   void qmp_memsave(int64_t addr, int64_t size, const char *filename,
                    bool has_cpu, int64_t cpu_index, Error **errp)
Quoted 8 lines

softmmu/cpus_list.c

Quoted 6 lines
softmmu/cpus.c +0 -0
   {
softmmu/cpus_list.c new file +0 -0
new file mode 100644
index 0000000000..59ef604423

The other cpu*.c files in softmmu use a "-" instead of "_", so I'd also use a "-" for cpu-list.c.

I guess I used '_' copy/pasting from arch_init.c:

specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files(
'arch_init.c',
+ 'cpus_list.c',
'ioport.c',

I don't mind changing, but it would be better to standardize that on a project scope / level.

Tested-by
#4 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 11 lines · Philippe Mathieu-Daudé

From: Philippe Mathieu-Daudé <[email protected]>

Commit e0220bb5b2 made cpus.c target-agnostic but didn't notice the cpu_list() function is only defined in target-specific code in "cpu.h". Extract list_cpus() from the generic cpus.c into a new target-specific unit.

Fixes e0220bb5b2 ("softmmu: Build target-agnostic objects once")
Quoted 6 lines
---
 softmmu/cpus.c      |  8 --------
 softmmu/cpus_list.c | 36 ++++++++++++++++++++++++++++++++++++
 softmmu/meson.build |  1 +
 3 files changed, 37 insertions(+), 8 deletions(-)
 create mode 100644 softmmu/cpus_list.c
Signature · 2 lines
Thanks.
-- Max