Remove AccelClass::available field
cover Remove AccelClass::available field
The only user of AccelClass::available was the qtest accelerator, to make it unavailable on non-POSIX systems. We can drop the field if we simply not compile the accelerator code on those systems.
Eduardo Habkost (3):
qtest: Move accel code to accel/qtest.c
qtest: Don't compile qtest accel on non-POSIX systems
accel: Remove unused AccelClass::available field
include/sysemu/accel.h | 1 - include/sysemu/qtest.h | 9 ------- accel/accel.c | 5 ---- accel/qtest.c | 54 ++++++++++++++++++++++++++++++++++++++++++ qtest.c | 34 -------------------------- accel/Makefile.objs | 1 + 6 files changed, 55 insertions(+), 49 deletions(-) create mode 100644 accel/qtest.c
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
PATCH 1/3 qtest: Move accel code to accel/qtest.c
QTest has two parts: the server (-qtest) and the accelerator (-machine accel=qtest). The accelerator depends on CONFIG_POSIX due to its usage of sigwait(), but the server doesn't.
Move the accel code to accel/qtest.c. Later we will disable compilation of accel/qtest.c on non-POSIX systems.
--- accel/qtest.c | 55 +++++++++++++++++++++++++++++++++++++++++++++ qtest.c | 34 ---------------------------- accel/Makefile.objs | 1 + 3 files changed, 56 insertions(+), 34 deletions(-) create mode 100644 accel/qtest.c
accel/qtest.c new file +55 -0
@@ -0,0 +1,55 @@ +/* +* QTest accelerator code +* +* Copyright IBM, Corp. 2011 +* +* Authors: +* Anthony Liguori <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* +*/ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu/module.h" +#include "qemu/option.h" +#include "qemu/config-file.h" +#include "sysemu/accel.h" +#include "sysemu/qtest.h" +#include "sysemu/cpus.h" + +static int qtest_init_accel (MachineState *ms) +{ +QemuOpts *opts =qemu_opts_create (qemu_find_opts ("icount" ),NULL ,0 , + &error_abort); +qemu_opt_set (opts,"shift" ,"0" , &error_abort); +configure_icount (opts, &error_abort); +qemu_opts_del (opts); +return 0 ; +} + +static void qtest_accel_class_init (ObjectClass *oc,void *data) +{ +AccelClass *ac =ACCEL_CLASS (oc); + ac->name ="QTest" ; + ac->available = qtest_available; + ac->init_machine = qtest_init_accel; + ac->allowed = &qtest_allowed; +} + +#define TYPE_QTEST_ACCEL ACCEL_CLASS_NAME("qtest") + +static const TypeInfo qtest_accel_type = { + .name =TYPE_QTEST_ACCEL , + .parent =TYPE_ACCEL , + .class_init = qtest_accel_class_init, +}; + +static void qtest_type_init (void ) +{ +type_register_static (&qtest_accel_type); +} + +type_init (qtest_type_init);
qtest.c +0 -34
@@ -749,16 +749,6 @@ static void qtest_event(void *opaque, int event) } } -static int qtest_init_accel (MachineState *ms) -{ -QemuOpts *opts =qemu_opts_create (qemu_find_opts ("icount" ),NULL ,0 , - &error_abort); -qemu_opt_set (opts,"shift" ,"0" , &error_abort); -configure_icount (opts, &error_abort); -qemu_opts_del (opts); -return 0 ; -} -void qtest_init (const char *qtest_chrdev,const char *qtest_log,Error **errp) {Chardev *chr;
@@ -791,27 +781,3 @@ bool qtest_driver(void) {return qtest_chr.chr !=NULL ; } - -static void qtest_accel_class_init (ObjectClass *oc,void *data) -{ -AccelClass *ac =ACCEL_CLASS (oc); - ac->name ="QTest" ; - ac->available = qtest_available; - ac->init_machine = qtest_init_accel; - ac->allowed = &qtest_allowed; -} - -#define TYPE_QTEST_ACCEL ACCEL_CLASS_NAME("qtest") - -static const TypeInfo qtest_accel_type = { - .name =TYPE_QTEST_ACCEL , - .parent =TYPE_ACCEL , - .class_init = qtest_accel_class_init, -}; - -static void qtest_type_init (void ) -{ -type_register_static (&qtest_accel_type); -} - -type_init (qtest_type_init);
accel/Makefile.objs +1 -0
@@ -1,4 +1,5 @@ obj-$(CONFIG_SOFTMMU) += accel.o +obj-$(CONFIG_SOFTMMU) += qtest.o obj-$(CONFIG_KVM) += kvm/ obj-$(CONFIG_TCG) += tcg/ obj-y += stubs/
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
Re: [Qemu-devel] [PATCH 1/3] qtest: Move accel code to accel/qtest.c
Hi Eduardo,
Quoted 27 lines · Eduardo Habkost
QTest has two parts: the server (-qtest) and the accelerator (-machine accel=qtest). The accelerator depends on
CONFIG_POSIXdue to its usage ofsigwait(), but the server doesn't.Move the accel code to
accel/qtest.c. Later we will disable compilation ofaccel/qtest.con non-POSIX systems.Signed-off-by Eduardo Habkost <[email protected]>--- accel/qtest.c | 55 +++++++++++++++++++++++++++++++++++++++++++++ qtest.c | 34 ---------------------------- accel/Makefile.objs | 1 + 3 files changed, 56 insertions(+), 34 deletions(-) create mode 100644 accel/qtest.caccel/qtest.c new file +6
-0@@ -0,0 +1,55 @@ +/* +* QTest accelerator code +* +* Copyright IBM, Corp. 2011 +* +* Authors:
accel/qtest.c line 16
Quoted 10 lines
accel/qtest.c new file +10
-0+* Anthony Liguori <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* +*/ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu/module.h"
Why include "qemu/module.h"?
I guess you don't need it.
Quoted 94 lines
accel/qtest.c new file +39
-0+#include "qemu/option.h" +#include "qemu/config-file.h" +#include "sysemu/accel.h" +#include "sysemu/qtest.h" +#include "sysemu/cpus.h" + +static int qtest_init_accel (MachineState *ms) +{ +QemuOpts *opts =qemu_opts_create (qemu_find_opts ("icount" ),NULL ,0 , + &error_abort); +qemu_opt_set (opts,"shift" ,"0" , &error_abort); +configure_icount (opts, &error_abort); +qemu_opts_del (opts); +return 0 ; +} + +static void qtest_accel_class_init (ObjectClass *oc,void *data) +{ +AccelClass *ac =ACCEL_CLASS (oc); + ac->name ="QTest" ; + ac->available = qtest_available; + ac->init_machine = qtest_init_accel; + ac->allowed = &qtest_allowed; +} + +#define TYPE_QTEST_ACCEL ACCEL_CLASS_NAME("qtest") + +static const TypeInfo qtest_accel_type = { + .name =TYPE_QTEST_ACCEL , + .parent =TYPE_ACCEL , + .class_init = qtest_accel_class_init, +}; + +static void qtest_type_init (void ) +{ +type_register_static (&qtest_accel_type); +} + +type_init (qtest_type_init);qtest.c +0
-34@@ -749,16 +749,6 @@ static void qtest_event(void *opaque, int event) } } -static int qtest_init_accel (MachineState *ms) -{ -QemuOpts *opts =qemu_opts_create (qemu_find_opts ("icount" ),NULL ,0 , - &error_abort); -qemu_opt_set (opts,"shift" ,"0" , &error_abort); -configure_icount (opts, &error_abort); -qemu_opts_del (opts); -return 0 ; -} -void qtest_init (const char *qtest_chrdev,const char *qtest_log,Error **errp) {Chardev *chr;@@ -791,27 +781,3 @@ bool qtest_driver(void) {return qtest_chr.chr !=NULL ; } - -static void qtest_accel_class_init (ObjectClass *oc,void *data) -{ -AccelClass *ac =ACCEL_CLASS (oc); - ac->name ="QTest" ; - ac->available = qtest_available; - ac->init_machine = qtest_init_accel; - ac->allowed = &qtest_allowed; -} - -#define TYPE_QTEST_ACCEL ACCEL_CLASS_NAME("qtest") - -static const TypeInfo qtest_accel_type = { - .name =TYPE_QTEST_ACCEL , - .parent =TYPE_ACCEL , - .class_init = qtest_accel_class_init, -}; - -static void qtest_type_init (void ) -{ -type_register_static (&qtest_accel_type); -} - -type_init (qtest_type_init);accel/Makefile.objs +0
-0
accel/Makefile.objs line 5
Quoted 5 lines
accel/Makefile.objs +1
-0@@ -1,4 +1,5 @@ obj-$(CONFIG_SOFTMMU) += accel.o +obj-$(CONFIG_SOFTMMU) += qtest.o obj-$(CONFIG_KVM) += kvm/ obj-$(CONFIG_TCG) += tcg/ obj-y += stubs/
Re: [Qemu-devel] [PATCH 1/3] qtest: Move accel code to accel/qtest.c
Quoted 10 lines · Philippe Mathieu-Daudé
Hi Eduardo,
Quoted 7 lines · Eduardo Habkost
QTest has two parts: the server (-qtest) and the accelerator (-machine accel=qtest). The accelerator depends on
CONFIG_POSIXdue to its usage ofsigwait(), but the server doesn't.Move the accel code to
accel/qtest.c. Later we will disable compilation ofaccel/qtest.con non-POSIX systems.
[...]
Quoted 4 lines
Quoted 1 line
+#include "
qemu/module.h"Why include "
qemu/module.h"?
I guess you don't need it.
That's where the type_init() macro is defined.
Quoted 1 line
Quoted 1 line
+type_init(qtest_type_init);
[...]
Quoted 2 lines
Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Thanks!
Signature · 1 line
Eduardo
Re: [Qemu-devel] [PATCH 1/3] qtest: Move accel code to accel/qtest.c
Quoted 11 lines · Eduardo Habkost
Quoted 10 lines · Philippe Mathieu-Daudé
Hi Eduardo,
Quoted 7 lines · Eduardo Habkost
QTest has two parts: the server (-qtest) and the accelerator (-machine accel=qtest). The accelerator depends on
CONFIG_POSIXdue to its usage ofsigwait(), but the server doesn't.Move the accel code to
accel/qtest.c. Later we will disable compilation ofaccel/qtest.con non-POSIX systems.
Quoted 7 lines
[...]
Quoted 4 lines
Quoted 1 line
+#include "
qemu/module.h"Why include "
qemu/module.h"?
I guess you don't need it.That's where the
type_init()macro is defined.
Oh correct...
I tried to remove it/compile and it worked because it is pulled by:
"sysemu/cpus.h"
-> "qemu/timer.h"
-> "qemu-common.h"
-> "qemu/module.h"Thanks!
Quoted 9 lines
Quoted 1 line
Quoted 1 line
+type_init(qtest_type_init);
[...]
Quoted 2 lines
Reviewed-by Philippe Mathieu-Daudé <[email protected]>Thanks!
Re: [Qemu-devel] [PATCH 1/3] qtest: Move accel code to accel/qtest.c
In reply to Eduardo HabkostQuoted 10 lines · Eduardo Habkost
QTest has two parts: the server (-qtest) and the accelerator (-machine accel=qtest). The accelerator depends on
CONFIG_POSIXdue to its usage ofsigwait(), but the server doesn't.Move the accel code to
accel/qtest.c. Later we will disable compilation ofaccel/qtest.con non-POSIX systems.Signed-off-by Eduardo Habkost <[email protected]>--- accel/qtest.c | 55 +++++++++++++++++++++++++++++++++++++++++++++
New file ==> You should update MAINTAINERS here as well.
Thomas
PATCH 1/1 fixup! qtest: Move accel code to accel/qtest.c
Quoted 5 lines · Thomas Huth
Quoted 4 lines · Eduardo Habkost
QTest has two parts: the server (-qtest) and the accelerator (-machine accel=qtest). The accelerator depends on
CONFIG_POSIXdue to its usage ofsigwait(), but the server doesn't.
Quoted 8 lines
Quoted 6 lines
Move the accel code to
accel/qtest.c. Later we will disable compilation ofaccel/qtest.con non-POSIX systems.Signed-off-by Eduardo Habkost <[email protected]>--- accel/qtest.c | 55 +++++++++++++++++++++++++++++++++++++++++++++New file ==> You should update
MAINTAINERShere as well.
Oops, sorry! Fixup below.
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -2024,6 +2024,7 @@ M: Laurent Vivier <[email protected]> R: Paolo Bonzini <[email protected]> S: Maintained F: qtest.c +F: accel/qtest.c F: tests/libqtest.* F: tests/libqos/ F: tests/*-test.c
Signature · 4 lines
2.18.0.rc1.1.g3f1ff2140 -- Eduardo
Re: [Qemu-devel] [PATCH] fixup! qtest: Move accel code to accel/qtest.c
Quoted 27 lines · Eduardo Habkost
Quoted 5 lines · Thomas Huth
Quoted 4 lines · Eduardo Habkost
QTest has two parts: the server (-qtest) and the accelerator (-machine accel=qtest). The accelerator depends on
CONFIG_POSIXdue to its usage ofsigwait(), but the server doesn't.Quoted 8 lines
Quoted 6 lines
Move the accel code to
accel/qtest.c. Later we will disable compilation ofaccel/qtest.con non-POSIX systems.Signed-off-by Eduardo Habkost <[email protected]>--- accel/qtest.c | 55 +++++++++++++++++++++++++++++++++++++++++++++New file ==> You should update
MAINTAINERShere as well.Oops, sorry! Fixup below.
Signed-off-by Eduardo Habkost <[email protected]>--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)MAINTAINERS +0
-0
MAINTAINERS M: Laurent Vivier <[email protected]> · line 2030
Quoted 7 lines
MAINTAINERS +1
-0@@ -2024,6 +2024,7 @@ M: Laurent Vivier <[email protected]> R: Paolo Bonzini <[email protected]> S: Maintained F: qtest.c +F: accel/qtest.c F: tests/libqtest.* F: tests/libqos/ F: tests/*-test.c
All right, queued the patches on my qtest-next branch:
https://gitlab.com/huth/qemu/tree/qtest-next
Thanks,
Thomas
PATCH 2/3 qtest: Don't compile qtest accel on non-POSIX systems
In reply to Eduardo Habkostqtest_available() will always return 0 on non-POSIX systems. It's simpler to just not compile the accelerator code on those systems instead of relying on the AccelClass::available function.
--- include/sysemu/qtest.h | 9 --------- accel/qtest.c | 1 - accel/Makefile.objs | 2 +- 3 files changed, 1 insertion(+), 11 deletions(-)
include/sysemu/qtest.h +0 -9
@@ -27,13 +27,4 @@ bool qtest_driver(void);void qtest_init (const char *qtest_chrdev,const char *qtest_log,Error **errp); -static inline int qtest_available (void ) -{ -#ifdef CONFIG_POSIX -return 1 ; -#else -return 0 ; -#endif -} -#endif
accel/qtest.c +0 -1
@@ -34,7 +34,6 @@ static void qtest_accel_class_init(ObjectClass *oc, void *data) {AccelClass *ac =ACCEL_CLASS (oc); ac->name ="QTest" ; - ac->available = qtest_available; ac->init_machine = qtest_init_accel; ac->allowed = &qtest_allowed; }
accel/Makefile.objs +1 -1
@@ -1,5 +1,5 @@ obj-$(CONFIG_SOFTMMU) += accel.o -obj-$(CONFIG_SOFTMMU) += qtest.o +obj-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_POSIX)) += qtest.o obj-$(CONFIG_KVM) += kvm/ obj-$(CONFIG_TCG) += tcg/ obj-y += stubs/
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
Re: [Qemu-devel] [PATCH 2/3] qtest: Don't compile qtest accel on non-POSIX systems
Quoted 5 lines · Eduardo Habkost
qtest_available()will always return 0 on non-POSIX systems. It's simpler to just not compile the accelerator code on those systems instead of relying on theAccelClass::availablefunction.Signed-off-by Eduardo Habkost <[email protected]>
mingw64:
Quoted 48 lines
--- include/sysemu/qtest.h | 9 --------- accel/qtest.c | 1 - accel/Makefile.objs | 2 +- 3 files changed, 1 insertion(+), 11 deletions(-)include/sysemu/qtest.h +0
-9@@ -27,13 +27,4 @@ bool qtest_driver(void);void qtest_init (const char *qtest_chrdev,const char *qtest_log,Error **errp); -static inline int qtest_available (void ) -{ -#ifdef CONFIG_POSIX -return 1 ; -#else -return 0 ; -#endif -} -#endif accel/qtest.c +0
-1@@ -34,7 +34,6 @@ static void qtest_accel_class_init(ObjectClass *oc, void *data) {AccelClass *ac =ACCEL_CLASS (oc); ac->name ="QTest" ; - ac->available = qtest_available; ac->init_machine = qtest_init_accel; ac->allowed = &qtest_allowed; }accel/Makefile.objs +1
-1@@ -1,5 +1,5 @@ obj-$(CONFIG_SOFTMMU) += accel.o -obj-$(CONFIG_SOFTMMU) += qtest.o +obj-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_POSIX)) += qtest.o obj-$(CONFIG_KVM) += kvm/ obj-$(CONFIG_TCG) += tcg/ obj-y += stubs/
Re: [Qemu-devel] [PATCH 2/3] qtest: Don't compile qtest accel on non-POSIX systems
In reply to Eduardo HabkostQuoted 10 lines · Eduardo Habkost
qtest_available()will always return 0 on non-POSIX systems. It's simpler to just not compile the accelerator code on those systems instead of relying on theAccelClass::availablefunction.Signed-off-by Eduardo Habkost <[email protected]>--- include/sysemu/qtest.h | 9 --------- accel/qtest.c | 1 - accel/Makefile.objs | 2 +- 3 files changed, 1 insertion(+), 11 deletions(-)
PATCH 3/3 accel: Remove unused AccelClass::available field
In reply to Eduardo HabkostThe field is not used anymore, we can remove it.
--- include/sysemu/accel.h | 1 - accel/accel.c | 5 ----- 2 files changed, 6 deletions(-)
include/sysemu/accel.h +0 -1
@@ -38,7 +38,6 @@ typedef struct AccelClass {const char *opt_name;const char *name; -int (*available)(void );int (*init_machine)(MachineState *ms);void (*setup_post)(MachineState *ms,AccelState *accel);bool *allowed;
accel/accel.c +0 -5
@@ -107,11 +107,6 @@ void configure_accelerator(MachineState *ms, const char *progname)if (!acc) {continue ; } -if (acc->available && !acc->available ()) { -printf ("%s not supported for this target\n" , - acc->name); -continue ; - } ret =accel_init_machine (acc, ms);if (ret <0 ) { init_failed = true;
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
Re: [Qemu-devel] [PATCH 3/3] accel: Remove unused AccelClass::available field
Quoted 3 lines · Eduardo Habkost
The field is not used anymore, we can remove it.
Signed-off-by Eduardo Habkost <[email protected]>
mingw64:
Quoted 34 lines
--- include/sysemu/accel.h | 1 - accel/accel.c | 5 ----- 2 files changed, 6 deletions(-)include/sysemu/accel.h +0
-1@@ -38,7 +38,6 @@ typedef struct AccelClass {const char *opt_name;const char *name; -int (*available)(void );int (*init_machine)(MachineState *ms);void (*setup_post)(MachineState *ms,AccelState *accel);bool *allowed;accel/accel.c +0
-5@@ -107,11 +107,6 @@ void configure_accelerator(MachineState *ms, const char *progname)if (!acc) {continue ; } -if (acc->available && !acc->available ()) { -printf ("%s not supported for this target\n" , - acc->name); -continue ; - } ret =accel_init_machine (acc, ms);if (ret <0 ) { init_failed = true;
Re: [Qemu-devel] [PATCH 3/3] accel: Remove unused AccelClass::available field
In reply to Eduardo HabkostQuoted 7 lines · Eduardo Habkost
The field is not used anymore, we can remove it.
Signed-off-by Eduardo Habkost <[email protected]>--- include/sysemu/accel.h | 1 - accel/accel.c | 5 ----- 2 files changed, 6 deletions(-)