accel/common: Remove last bit of target-specific code
PATCH 1/1 accel/common: Remove last bit of target-specific code
Initialize the TypeInfo structure at runtime using the TargetInfo API to resolve TYPE_ACCEL_CPU, replacing CPU_RESOLVING_TYPE by target_cpu_type(). Since the code is no more target-specific, move it to accel-common.c, removing the need for accel-target.c.
---
Cc: Pierrick Bouvier <[email protected]>
Pierrick, this is an alternative for both [email protected] and [email protected] for your "single-binary: fix compilation/execution for {arm, aarch32, microblaze}" series. WDYT?
--- accel/accel-common.c | 15 +++++++++++++++ accel/accel-target.c | 41 ----------------------------------------- accel/meson.build | 1 - 3 files changed, 15 insertions(+), 42 deletions(-) delete mode 100644 accel/accel-target.c
accel/accel-common.c +15 -0
@@ -134,3 +134,18 @@ static const TypeInfo accel_types[] = { };DEFINE_TYPES (accel_types) + +static void register_accel_target_type(void) +{ + g_autofree char *name = g_strconcat("accel-", target_cpu_type(), NULL); +const TypeInfo accel_cpu_type = { + .name = name, + .parent =TYPE_OBJECT , + .abstract = true, + .class_size =sizeof (AccelCPUClass), + }; + +type_register_static (&accel_cpu_type); +} + +type_init (register_accel_target_type);
accel/accel-target.c deleted +0 -41
41 lines not on this page · raw message
accel/meson.build +0 -1
@@ -1,5 +1,4 @@ common_ss.add(files('accel-common.c')) -specific_ss.add(files('accel-target.c')) system_ss.add(files('accel-system.c', 'accel-blocker.c', 'accel-qmp.c', 'accel-irq.c')) user_ss.add(files('accel-user.c'))
Signature · 1 line
2.53.0
Quoted 33 lines · Philippe Mathieu-Daudé
Initialize the TypeInfo structure at runtime using the TargetInfo API to resolve
TYPE_ACCEL_CPU, replacingCPU_RESOLVING_TYPEbytarget_cpu_type(). Since the code is no more target-specific, move it toaccel-common.c, removing the need foraccel-target.c.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Cc: Pierrick Bouvier <[email protected]>Pierrick, this is an alternative for both [email protected] and [email protected] for your "single-binary: fix compilation/execution for {arm, aarch32, microblaze}" series. WDYT?
--- accel/accel-common.c | 15 +++++++++++++++ accel/accel-target.c | 41 ----------------------------------------- accel/meson.build | 1 - 3 files changed, 15 insertions(+), 42 deletions(-) delete mode 100644 accel/accel-target.caccel/accel-common.c +3
-0@@ -134,3 +134,18 @@ static const TypeInfo accel_types[] = { };DEFINE_TYPES (accel_types) + +static void register_accel_target_type(void) +{
accel/accel-common.c static const TypeInfo accel_types[] = { · line 149
Quoted 10 lines
accel/accel-common.c +10
-0+ g_autofree char *name = g_strconcat("accel-", target_cpu_type(), NULL); +const TypeInfo accel_cpu_type = { + .name = name, + .parent =TYPE_OBJECT , + .abstract = true, + .class_size =sizeof (AccelCPUClass), + }; + +type_register_static (&accel_cpu_type); +}
I think this is a nice solution compared to including accel_target_c in every target/.
Quoted 97 lines · Philippe Mathieu-Daudé
Initialize the TypeInfo structure at runtime using the TargetInfo API to resolve
TYPE_ACCEL_CPU, replacingCPU_RESOLVING_TYPEbytarget_cpu_type(). Since the code is no more target-specific, move it toaccel-common.c, removing the need foraccel-target.c.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Cc: Pierrick Bouvier <[email protected]>Pierrick, this is an alternative for both [email protected] and [email protected] for your "single-binary: fix compilation/execution for {arm, aarch32, microblaze}" series. WDYT?
--- accel/accel-common.c | 15 +++++++++++++++ accel/accel-target.c | 41 ----------------------------------------- accel/meson.build | 1 - 3 files changed, 15 insertions(+), 42 deletions(-) delete mode 100644 accel/accel-target.caccel/accel-common.c +15
-0@@ -134,3 +134,18 @@ static const TypeInfo accel_types[] = { };DEFINE_TYPES (accel_types) + +static void register_accel_target_type(void) +{ + g_autofree char *name = g_strconcat("accel-", target_cpu_type(), NULL); +const TypeInfo accel_cpu_type = { + .name = name, + .parent =TYPE_OBJECT , + .abstract = true, + .class_size =sizeof (AccelCPUClass), + }; + +type_register_static (&accel_cpu_type); +} + +type_init (register_accel_target_type);accel/accel-target.c deleted +0
-41@@ -1,41 +0,0 @@ -/* -* QEMU accel class, components common to system emulation and user mode -* -* Copyright (c) 2003-2008 Fabrice Bellard -* Copyright (c) 2014 Red Hat Inc. -* -* 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 "accel/accel-cpu-target.h" - -static const TypeInfo accel_cpu_type = { - .name =TYPE_ACCEL_CPU , - .parent =TYPE_OBJECT , - .abstract = true, - .class_size =sizeof (AccelCPUClass), -}; - -static void register_accel_types (void ) -{ -type_register_static (&accel_cpu_type); -} - -type_init (register_accel_types);accel/meson.build +0
-0
accel/meson.build line 4
Quoted 5 lines
accel/meson.build +0
-1@@ -1,5 +1,4 @@ common_ss.add(files('accel-common.c')) -specific_ss.add(files('accel-target.c')) system_ss.add(files('accel-system.c', 'accel-blocker.c', 'accel-qmp.c', 'accel-irq.c')) user_ss.add(files('accel-user.c'))
I'm open to follow this approach first .
The only downside is that it limits to a single accelerator parent type, which will be a problem as soon as we have two arch using this framework for tcg. Nothing we can't solve later though.
Regards,
Pierrick
Pierrick Bouvier
Reviewed-byQuoted 109 lines · Pierrick Bouvier
Quoted 97 lines · Philippe Mathieu-Daudé
Initialize the TypeInfo structure at runtime using the TargetInfo API to resolve
TYPE_ACCEL_CPU, replacingCPU_RESOLVING_TYPEbytarget_cpu_type(). Since the code is no more target-specific, move it toaccel-common.c, removing the need foraccel-target.c.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Cc: Pierrick Bouvier <[email protected]>Pierrick, this is an alternative for both [email protected] and [email protected] for your "single-binary: fix compilation/execution for {arm, aarch32, microblaze}" series. WDYT?
--- accel/accel-common.c | 15 +++++++++++++++ accel/accel-target.c | 41 ----------------------------------------- accel/meson.build | 1 - 3 files changed, 15 insertions(+), 42 deletions(-) delete mode 100644 accel/accel-target.caccel/accel-common.c +15
-0@@ -134,3 +134,18 @@ static const TypeInfo accel_types[] = { };DEFINE_TYPES (accel_types) + +static void register_accel_target_type(void) +{ + g_autofree char *name = g_strconcat("accel-", target_cpu_type(), NULL); +const TypeInfo accel_cpu_type = { + .name = name, + .parent =TYPE_OBJECT , + .abstract = true, + .class_size =sizeof (AccelCPUClass), + }; + +type_register_static (&accel_cpu_type); +} + +type_init (register_accel_target_type);accel/accel-target.c deleted +0
-41@@ -1,41 +0,0 @@ -/* -* QEMU accel class, components common to system emulation and user mode -* -* Copyright (c) 2003-2008 Fabrice Bellard -* Copyright (c) 2014 Red Hat Inc. -* -* 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 "accel/accel-cpu-target.h" - -static const TypeInfo accel_cpu_type = { - .name =TYPE_ACCEL_CPU , - .parent =TYPE_OBJECT , - .abstract = true, - .class_size =sizeof (AccelCPUClass), -}; - -static void register_accel_types (void ) -{ -type_register_static (&accel_cpu_type); -} - -type_init (register_accel_types);accel/meson.build +0
-0accel/meson.build line 4
Quoted 5 lines
accel/meson.build +0
-1@@ -1,5 +1,4 @@ common_ss.add(files('accel-common.c')) -specific_ss.add(files('accel-target.c')) system_ss.add(files('accel-system.c', 'accel-blocker.c', 'accel-qmp.c', 'accel-irq.c')) user_ss.add(files('accel-user.c'))I'm open to follow this approach first .
The only downside is that it limits to a single accelerator parent type, which will be a problem as soon as we have two arch using this framework for tcg. Nothing we can't solve later though.
Quoted 2 lines
Regards,
Pierrick
Forgot :)
Quoted 101 lines · Pierrick Bouvier
Quoted 100 lines · Pierrick Bouvier
Quoted 99 lines · Philippe Mathieu-Daudé
Initialize the TypeInfo structure at runtime using the TargetInfo API to resolve
TYPE_ACCEL_CPU, replacingCPU_RESOLVING_TYPEbytarget_cpu_type(). Since the code is no more target-specific, move it toaccel-common.c, removing the need foraccel-target.c.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Cc: Pierrick Bouvier <[email protected]>Pierrick, this is an alternative for both [email protected] and [email protected] for your "single-binary: fix compilation/execution for {arm, aarch32, microblaze}" series. WDYT?
--- accel/accel-common.c | 15 +++++++++++++++ accel/accel-target.c | 41 ----------------------------------------- accel/meson.build | 1 - 3 files changed, 15 insertions(+), 42 deletions(-)delete mode 100644
accel/accel-target.caccel/accel-common.c +15
-0@@ -134,3 +134,18 @@ static const TypeInfo accel_types[] = { };DEFINE_TYPES (accel_types) + +static void register_accel_target_type(void) +{ + g_autofree char *name = g_strconcat("accel-", target_cpu_type(), NULL); +const TypeInfo accel_cpu_type = { + .name = name, + .parent =TYPE_OBJECT , + .abstract = true, + .class_size =sizeof (AccelCPUClass), + }; + +type_register_static (&accel_cpu_type); +} + +type_init (register_accel_target_type);accel/accel-target.c deleted +0
-41@@ -1,41 +0,0 @@ -/* -* QEMU accel class, components common to system emulation and user mode -* -* Copyright (c) 2003-2008 Fabrice Bellard -* Copyright (c) 2014 Red Hat Inc. -* -* 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 "accel/accel-cpu-target.h" - -static const TypeInfo accel_cpu_type = { - .name =TYPE_ACCEL_CPU , - .parent =TYPE_OBJECT , - .abstract = true, - .class_size =sizeof (AccelCPUClass), -}; - -static void register_accel_types (void ) -{ -type_register_static (&accel_cpu_type); -} - -type_init (register_accel_types);accel/meson.build +0
-1@@ -1,5 +1,4 @@ common_ss.add(files('accel-common.c')) -specific_ss.add(files('accel-target.c'))
Quoted 8 lines
Quoted 8 lines
accel/meson.build line 4
Quoted 3 lines
accel/meson.build +0
-0system_ss.add(files('accel-system.c', 'accel-blocker.c', 'accel-qmp.c', 'accel-irq.c')) user_ss.add(files('accel-user.c'))I'm open to follow this approach first .
The only downside is that it limits to a single accelerator parent type, which will be a problem as soon as we have two arch using this framework for tcg. Nothing we can't solve later though.
Good point. I'll see how to handle that (as a following up patch).
Quoted 6 lines
Quoted 3 lines
Regards,
PierrickForgot :)
Reviewed-by Pierrick Bouvier <[email protected]>
Quoted 125 lines · Philippe Mathieu-Daudé
Quoted 115 lines · Pierrick Bouvier
Quoted 114 lines · Pierrick Bouvier
Quoted 113 lines · Philippe Mathieu-Daudé
Initialize the TypeInfo structure at runtime using the TargetInfo API to resolve
TYPE_ACCEL_CPU, replacingCPU_RESOLVING_TYPEbytarget_cpu_type(). Since the code is no more target-specific, move it toaccel-common.c, removing the need foraccel-target.c.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Cc: Pierrick Bouvier <[email protected]>Pierrick, this is an alternative for both [email protected] and [email protected] for your "single-binary: fix compilation/execution for {arm, aarch32, microblaze}" series. WDYT?
---
accel/accel-common.c| 15 +++++++++++++++accel/accel-target.c| 41 ----------------------------------------- accel/meson.build | 1 -3 files changed, 15 insertions(+), 42 deletions(-)delete mode 100644
accel/accel-target.caccel/accel-common.c +15
-0@@ -134,3 +134,18 @@ static const TypeInfo accel_types[] = { }; DEFINE_TYPES(accel_types) + +static void register_accel_target_type(void) +{ + g_autofree char *name = g_strconcat("accel-",target_cpu_type (),NULL ); + const TypeInfo accel_cpu_type = { + .name = name, + .parent = TYPE_OBJECT, + .abstract = true, + .class_size = sizeof(AccelCPUClass), + }; + + type_register_static(&accel_cpu_type); +} + +type_init (register_accel_target_type);accel/accel-target.c deleted +0
-2@@ -1,41 +0,0 @@ -/* -* QEMU accel class, components common to system emulation and user mode
- *
- * Copyright (c) 2003-2008 Fabrice Bellard
- * Copyright (c) 2014 Red Hat Inc.
- *
- * 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.
- */accel/accel-target.c deleted +0
-17- -#include "qemu/osdep.h" -#include "accel/accel-cpu-target.h" - -static const TypeInfo accel_cpu_type = { - .name = TYPE_ACCEL_CPU, - .parent = TYPE_OBJECT, - .abstract = true, - .class_size = sizeof(AccelCPUClass), -}; - -static void register_accel_types (void ) -{ - type_register_static(&accel_cpu_type); -} - -type_init (register_accel_types);accel/meson.build +0
-1@@ -1,5 +1,4 @@ common_ss.add(files('accel-common.c')) -specific_ss.add(files('accel-target.c'))system_ss.add(files('accel-system.c', '
accel-blocker.c', 'accel-Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
qmp.c', 'accel-irq.c'))
user_ss.add(files('accel-user.c'))I'm open to follow this approach first .
The only downside is that it limits to a single accelerator parent type, which will be a problem as soon as we have two arch using this framework for tcg. Nothing we can't solve later though.
Quoted 2 lines
Good point. I'll see how to handle that (as a following up patch).
Maybe we need to duplicate this struct for each base architecture? :)
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
Regards,
PierrickForgot :)
Reviewed-by Pierrick Bouvier <[email protected]>
Quoted 44 lines · Pierrick Bouvier
Quoted 43 lines · Philippe Mathieu-Daudé
Quoted 41 lines · Pierrick Bouvier
Quoted 40 lines · Pierrick Bouvier
Quoted 29 lines · Philippe Mathieu-Daudé
Initialize the TypeInfo structure at runtime using the TargetInfo API to resolve
TYPE_ACCEL_CPU, replacingCPU_RESOLVING_TYPEbytarget_cpu_type(). Since the code is no more target-specific, move it toaccel-common.c, removing the need foraccel-target.c.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Cc: Pierrick Bouvier <[email protected]>Pierrick, this is an alternative for both [email protected] and [email protected] for your "single-binary: fix compilation/execution for {arm, aarch32, microblaze}" series. WDYT?
--- accel/accel-common.c | 15 +++++++++++++++ accel/accel-target.c | 41 ----------------------------------------- accel/meson.build | 1 - 3 files changed, 15 insertions(+), 42 deletions(-)delete mode 100644
accel/accel-target.caccel/meson.build +0
-0accel/meson.build line 4
Quoted 5 lines
accel/meson.build +0
-1@@ -1,5 +1,4 @@ common_ss.add(files('accel-common.c')) -specific_ss.add(files('accel-target.c')) system_ss.add(files('accel-system.c', 'accel-blocker.c', 'accel- qmp.c', 'accel-irq.c')) user_ss.add(files('accel-user.c'))I'm open to follow this approach first .
The only downside is that it limits to a single accelerator parent type, which will be a problem as soon as we have two arch using this framework for tcg. Nothing we can't solve later though.
Quoted 4 lines
Quoted 2 lines
Good point. I'll see how to handle that (as a following up patch).
Maybe we need to duplicate this struct for each base architecture? :)
Back to your patch? I was never fond of AccelCPUClass and its QOM use, ended to ditch it completly:
https://lore.kernel.org/qemu-devel/[email protected]/
Quoted 9 lines
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Regards,
PierrickForgot :)
Reviewed-by Pierrick Bouvier <[email protected]>
Quoted 51 lines · Philippe Mathieu-Daudé
Quoted 50 lines · Pierrick Bouvier
Quoted 48 lines · Philippe Mathieu-Daudé
Quoted 36 lines · Pierrick Bouvier
Quoted 35 lines · Pierrick Bouvier
Quoted 34 lines · Philippe Mathieu-Daudé
Initialize the TypeInfo structure at runtime using the TargetInfo API to resolve
TYPE_ACCEL_CPU, replacingCPU_RESOLVING_TYPEbytarget_cpu_type(). Since the code is no more target-specific, move it toaccel-common.c, removing the need foraccel-target.c.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Cc: Pierrick Bouvier <[email protected]>Pierrick, this is an alternative for both [email protected] and [email protected] for your "single-binary: fix compilation/execution for {arm, aarch32, microblaze}" series. WDYT?
---
accel/accel-common.c| 15 +++++++++++++++accel/accel-target.c| 41
-----------------------------------------
accel/meson.build | 1 -3 files changed, 15 insertions(+), 42 deletions(-)delete mode 100644
accel/accel-target.caccel/meson.build +0
-1@@ -1,5 +1,4 @@ common_ss.add(files('accel-common.c')) -specific_ss.add(files('accel-target.c'))
system_ss.add(files('accel-system.c', 'accel-blocker.c', 'accel- qmp.c', 'accel-irq.c'))user_ss.add(files('accel-user.c'))Quoted 8 lines
Quoted 8 lines
Quoted 1 line
I'm open to follow this approach first .
The only downside is that it limits to a single accelerator parent type,
which will be a problem as soon as we have two arch using this framework
for tcg. Nothing we can't solve later though.Good point. I'll see how to handle that (as a following up patch).
Quoted 7 lines
Quoted 1 line
Maybe we need to duplicate this struct for each base architecture? :)
Back to your patch? I was never fond of AccelCPUClass and its QOM use, ended to ditch it completly:
https://lore.kernel.org/qemu-devel/20260529142434.87880-1-
[email protected]/
Great! I'll take a look.
Quoted 10 lines
Quoted 9 lines
Quoted 8 lines
Quoted 7 lines
Quoted 4 lines
Regards,
PierrickForgot :)
Reviewed-by Pierrick Bouvier <[email protected]>