chardev: Reduce system emulation specific code
cover chardev: Reduce system emulation specific code
chardev cleanup while reviewing 'Refactor machine_init and exit notifiers' from the multi-process series:
https://www.mail-archive.com/[email protected]/msg697510.html
Elena Ufimtseva (1):
multi-process: Refactor machine_init and exit notifiers
Philippe Mathieu-Daudé (6):
monitor/misc: Remove unused "chardev/char-mux.h" include tests/test-char: Remove unused "chardev/char-mux.h" include
chardev: Restrict msmouse / wctablet / testdev to system emulation
chardev: Reduce "char-mux.h" scope, rename it "chardev-internal.h"
chardev: Extract system emulation specific code
stubs: Split machine-init-done as machine-init and machine-notify
Makefile.objs | 1 +
.../char-mux.h => chardev/chardev-internal.h | 10 ++-
include/sysemu/sysemu.h | 2 +
chardev/char-fe.c | 2 +-
chardev/char-mux.c | 2 +-
chardev/char.c | 37 +---------
chardev/chardev-sysemu.c | 69 +++++++++++++++++++
monitor/misc.c | 1 -
softmmu/vl.c | 42 -----------
stubs/machine-init.c | 4 ++
.../{machine-init-done.c => machine-notify.c} | 6 +-
tests/test-char.c | 1 -
util/machine-notify.c | 69 +++++++++++++++++++
MAINTAINERS | 1 +
chardev/Makefile.objs | 3 +-
stubs/Makefile.objs | 3 +-
16 files changed, 165 insertions(+), 88 deletions(-)
rename include/chardev/char-mux.h => chardev/chardev-internal.h (93%)
create mode 100644 chardev/chardev-sysemu.c
create mode 100644 stubs/machine-init.c
rename stubs/{machine-init-done.c => machine-notify.c} (63%)
create mode 100644 util/machine-notify.cSignature · 1 line
2.21.1
PATCH 1/7 monitor/misc: Remove unused "chardev/char-mux.h" include
monitor/misc.c never required "chardev/char-mux.h", remove it.
--- monitor/misc.c | 1 - 1 file changed, 1 deletion(-)
monitor/misc.c +0 -1
@@ -33,7 +33,6 @@#include "exec/gdbstub.h" #include "net/net.h" #include "net/slirp.h" -#include "chardev/char-mux.h" #include "ui/qemu-spice.h" #include "qemu/config-file.h" #include "qemu/ctype.h"
Signature · 1 line
2.21.1
Re: [PATCH 1/7] monitor/misc: Remove unused "chardev/char-mux.h" include
Quoted 4 lines · Philippe Mathieu-Daudé
monitor/misc.cnever required "chardev/char-mux.h", remove it.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 20 lines
--- monitor/misc.c | 1 - 1 file changed, 1 deletion(-)monitor/misc.c +0
-2@@ -33,7 +33,6 @@#include "exec/gdbstub.h" #include "net/net.h" #include "net/slirp.h" -#include "chardev/char-mux.h" #include "ui/qemu-spice.h" #include "qemu/config-file.h" #include "qemu/ctype.h" --2.21.1
Signature · 1 line
Marc-André Lureau
PATCH 2/7 tests/test-char: Remove unused "chardev/char-mux.h" include
In reply to Philippe Mathieu-DaudéThis test never required "chardev/char-mux.h", remove it.
--- tests/test-char.c | 1 - 1 file changed, 1 deletion(-)
tests/test-char.c +0 -1
@@ -6,7 +6,6 @@#include "qemu/option.h" #include "qemu/sockets.h" #include "chardev/char-fe.h" -#include "chardev/char-mux.h" #include "sysemu/sysemu.h" #include "qapi/error.h" #include "qapi/qapi-commands-char.h"
Signature · 1 line
2.21.1
Re: [PATCH 2/7] tests/test-char: Remove unused "chardev/char-mux.h" include
Quoted 4 lines · Philippe Mathieu-Daudé
This test never required "
chardev/char-mux.h", remove it.Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 20 lines
--- tests/test-char.c | 1 - 1 file changed, 1 deletion(-)tests/test-char.c +0
-2@@ -6,7 +6,6 @@#include "qemu/option.h" #include "qemu/sockets.h" #include "chardev/char-fe.h" -#include "chardev/char-mux.h" #include "sysemu/sysemu.h" #include "qapi/error.h" #include "qapi/qapi-commands-char.h" --2.21.1
Signature · 1 line
Marc-André Lureau
PATCH 3/7 chardev: Restrict msmouse / wctablet / testdev to system emulation
In reply to Philippe Mathieu-DaudéThe msmouse / wctablet / testdev character devices are only used by system emulation. Remove them from user mode and tools.
--- chardev/Makefile.objs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
chardev/Makefile.objs +1 -1
@@ -17,7 +17,7 @@ chardev-obj-y += char-udp.o chardev-obj-$(CONFIG_WIN32) += char-win.o chardev-obj-$(CONFIG_WIN32) += char-win-stdio.o -common-obj-y += msmouse.o wctablet.o testdev.o +common-obj-$(CONFIG_SOFTMMU) += msmouse.o wctablet.o testdev.o common-obj-$(CONFIG_BRLAPI) += baum.o baum.o-cflags := $(SDL_CFLAGS) baum.o-libs := $(BRLAPI_LIBS)
Signature · 1 line
2.21.1
Re: [PATCH 3/7] chardev: Restrict msmouse / wctablet / testdev to system emulation
Quoted 5 lines · Philippe Mathieu-Daudé
The msmouse / wctablet / testdev character devices are only used by system emulation. Remove them from user mode and tools.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 21 lines
--- chardev/Makefile.objs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)chardev/Makefile.objs +1
-2@@ -17,7 +17,7 @@ chardev-obj-y += char-udp.o chardev-obj-$(CONFIG_WIN32) += char-win.o chardev-obj-$(CONFIG_WIN32) += char-win-stdio.o -common-obj-y += msmouse.o wctablet.o testdev.o +common-obj-$(CONFIG_SOFTMMU) += msmouse.o wctablet.o testdev.o common-obj-$(CONFIG_BRLAPI) += baum.o baum.o-cflags := $(SDL_CFLAGS) baum.o-libs := $(BRLAPI_LIBS) --2.21.1
Signature · 1 line
Marc-André Lureau
PATCH 4/7 chardev: Reduce "char-mux.h" scope, rename it "chardev-internal.h"
In reply to Philippe Mathieu-DaudéNo file out of chardev/ requires access to this header, restrict its scope.
--- include/chardev/char-mux.h => chardev/chardev-internal.h | 7 ++++--- chardev/char-fe.c | 2 +- chardev/char-mux.c | 2 +- chardev/char.c | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) rename include/chardev/char-mux.h => chardev/chardev-internal.h (96%)
chardev/chardev-internal.h renamed from include/chardev/char-mux.h +4 -3
@@ -1,5 +1,5 @@/* -* QEMU System Emulator +* QEMU Character device internals * * Copyright (c) 2003-2008 Fabrice Bellard *
@@ -21,8 +21,8 @@* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#ifndef CHAR_MUX_H -#define CHAR_MUX_H +#ifndef CHARDEV_INTERNAL_H +#define CHARDEV_INTERNAL_H #include "chardev/char.h" #include "chardev/char-fe.h"
@@ -30,6 +30,7 @@#define MAX_MUX 4#define MUX_BUFFER_SIZE 32/* Must be a power of 2. */ #define MUX_BUFFER_MASK (MUX_BUFFER_SIZE - 1) + typedef struct MuxChardev { Chardev parent; CharBackend *backends[MAX_MUX];
chardev/char-fe.c +1 -1
@@ -29,7 +29,7 @@#include "chardev/char-fe.h" #include "chardev/char-io.h" -#include "chardev/char-mux.h" +#include "chardev-internal.h" int qemu_chr_fe_write (CharBackend *be,const uint8_t *buf,int len) {
chardev/char-mux.c +1 -1
@@ -29,7 +29,7 @@#include "chardev/char.h" #include "sysemu/block-backend.h" #include "sysemu/sysemu.h" -#include "chardev/char-mux.h" +#include "chardev-internal.h" /* MUX driver for serial I/O splitting */
chardev/char.c +1 -1
@@ -39,7 +39,7 @@#include "qemu/option.h" #include "qemu/id.h" -#include "chardev/char-mux.h" +#include "chardev-internal.h" /***********************************************************/ /* character device */
Signature · 1 line
2.21.1
Re: [PATCH 4/7] chardev: Reduce "char-mux.h" scope, rename it "chardev-internal.h"
Quoted 5 lines · Philippe Mathieu-Daudé
No file out of chardev/ requires access to this header, restrict its scope.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 84 lines
--- include/chardev/char-mux.h => chardev/chardev-internal.h | 7 ++++--- chardev/char-fe.c | 2 +- chardev/char-mux.c | 2 +- chardev/char.c | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) rename include/chardev/char-mux.h => chardev/chardev-internal.h (96%)chardev/chardev-internal.h renamed from include/chardev/char-mux.h +4
-3@@ -1,5 +1,5 @@/* -* QEMU System Emulator +* QEMU Character device internals * * Copyright (c) 2003-2008 Fabrice Bellard * @@ -21,8 +21,8 @@* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -#ifndef CHAR_MUX_H -#define CHAR_MUX_H +#ifndef CHARDEV_INTERNAL_H +#define CHARDEV_INTERNAL_H #include "chardev/char.h" #include "chardev/char-fe.h" @@ -30,6 +30,7 @@#define MAX_MUX 4#define MUX_BUFFER_SIZE 32/* Must be a power of 2. */ #define MUX_BUFFER_MASK (MUX_BUFFER_SIZE - 1) + typedef struct MuxChardev { Chardev parent; CharBackend *backends[MAX_MUX];chardev/char-fe.c +1
-1@@ -29,7 +29,7 @@#include "chardev/char-fe.h" #include "chardev/char-io.h" -#include "chardev/char-mux.h" +#include "chardev-internal.h" int qemu_chr_fe_write (CharBackend *be,const uint8_t *buf,int len) {chardev/char-mux.c +1
-1@@ -29,7 +29,7 @@#include "chardev/char.h" #include "sysemu/block-backend.h" #include "sysemu/sysemu.h" -#include "chardev/char-mux.h" +#include "chardev-internal.h" /* MUX driver for serial I/O splitting */ chardev/char.c +1
-2@@ -39,7 +39,7 @@#include "qemu/option.h" #include "qemu/id.h" -#include "chardev/char-mux.h" +#include "chardev-internal.h" /***********************************************************/ /* character device */ --2.21.1
Signature · 1 line
Marc-André Lureau
PATCH 5/7 chardev: Extract system emulation specific code
In reply to Philippe Mathieu-DaudéSplit out code only used during system emulation, to reduce code pulled in user emulation and tools.
--- chardev/chardev-internal.h | 3 ++ chardev/char.c | 35 +------------------ chardev/chardev-sysemu.c | 69 ++++++++++++++++++++++++++++++++++++++ chardev/Makefile.objs | 1 + 4 files changed, 74 insertions(+), 34 deletions(-) create mode 100644 chardev/chardev-sysemu.c
chardev/chardev-internal.h +3 -0
@@ -26,6 +26,7 @@#include "chardev/char.h" #include "chardev/char-fe.h" +#include "qom/object.h" #define MAX_MUX 4#define MUX_BUFFER_SIZE 32/* Must be a power of 2. */
@@ -59,4 +60,6 @@ typedef struct MuxChardev {void mux_set_focus (Chardev *chr,int focus);void mux_chr_send_all_event (Chardev *chr,QEMUChrEvent event); +Object *get_chardevs_root (void ); +#endif /* CHAR_MUX_H */
chardev/char.c +1 -34
@@ -44,7 +44,7 @@/***********************************************************/ /* character device */ -static Object *get_chardevs_root (void ) +Object *get_chardevs_root (void ) {return container_get (object_get_root (),"/chardevs" ); }
@@ -300,33 +300,6 @@ static const TypeInfo char_type_info = { .class_init = char_class_init, }; -static int chardev_machine_done_notify_one (Object *child,void *opaque) -{ -Chardev *chr = (Chardev *)child; -ChardevClass *class =CHARDEV_GET_CLASS (chr); - -if (class->chr_machine_done) { -return class->chr_machine_done (chr); - } - -return 0 ; -} - -static void chardev_machine_done_hook (Notifier *notifier,void *unused) -{ -int ret =object_child_foreach (get_chardevs_root (), - chardev_machine_done_notify_one,NULL ); - -if (ret) { -error_report ("Failed to call chardev machine_done hooks" ); -exit (1 ); - } -} - -static Notifier chardev_machine_done_notify = { - .notify = chardev_machine_done_hook, -}; -static bool qemu_chr_is_busy (Chardev *s) {if (CHARDEV_IS_MUX (s)) {
@@ -1187,12 +1160,6 @@ void qemu_chr_cleanup(void)static void register_types (void ) {type_register_static (&char_type_info); - -/* this must be done after machine init, since we register FEs with muxes -* as part of realize functions like serial_isa_realizefn when -nographic -* is specified -*/ -qemu_add_machine_init_done_notifier (&chardev_machine_done_notify); }type_init (register_types);
chardev/chardev-sysemu.c new file +69 -0
69 lines not on this page · raw message
chardev/Makefile.objs +1 -0
@@ -1,4 +1,5 @@ chardev-obj-y += char.o +chardev-obj-$(CONFIG_SOFTMMU) += chardev-sysemu.o chardev-obj-$(CONFIG_WIN32) += char-console.o chardev-obj-$(CONFIG_POSIX) += char-fd.o chardev-obj-y += char-fe.o
Signature · 1 line
2.21.1
Re: [PATCH 5/7] chardev: Extract system emulation specific code
Quoted 5 lines · Philippe Mathieu-Daudé
Split out code only used during system emulation, to reduce code pulled in user emulation and tools.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 176 lines
--- chardev/chardev-internal.h | 3 ++ chardev/char.c | 35 +------------------ chardev/chardev-sysemu.c | 69 ++++++++++++++++++++++++++++++++++++++ chardev/Makefile.objs | 1 + 4 files changed, 74 insertions(+), 34 deletions(-) create mode 100644 chardev/chardev-sysemu.cchardev/chardev-internal.h +3
-0@@ -26,6 +26,7 @@#include "chardev/char.h" #include "chardev/char-fe.h" +#include "qom/object.h" #define MAX_MUX 4#define MUX_BUFFER_SIZE 32/* Must be a power of 2. */ @@ -59,4 +60,6 @@ typedef struct MuxChardev {void mux_set_focus (Chardev *chr,int focus);void mux_chr_send_all_event (Chardev *chr,QEMUChrEvent event); +Object *get_chardevs_root (void ); +#endif /* CHAR_MUX_H */ chardev/char.c +1
-34@@ -44,7 +44,7 @@/***********************************************************/ /* character device */ -static Object *get_chardevs_root (void ) +Object *get_chardevs_root (void ) {return container_get (object_get_root (),"/chardevs" ); }@@ -300,33 +300,6 @@ static const TypeInfo char_type_info = { .class_init = char_class_init, }; -static int chardev_machine_done_notify_one (Object *child,void *opaque) -{ -Chardev *chr = (Chardev *)child; -ChardevClass *class =CHARDEV_GET_CLASS (chr); - -if (class->chr_machine_done) { -return class->chr_machine_done (chr); - } - -return 0 ; -} - -static void chardev_machine_done_hook (Notifier *notifier,void *unused) -{ -int ret =object_child_foreach (get_chardevs_root (), - chardev_machine_done_notify_one,NULL ); - -if (ret) { -error_report ("Failed to call chardev machine_done hooks" ); -exit (1 ); - } -} - -static Notifier chardev_machine_done_notify = { - .notify = chardev_machine_done_hook, -}; -static bool qemu_chr_is_busy (Chardev *s) {if (CHARDEV_IS_MUX (s)) {@@ -1187,12 +1160,6 @@ void qemu_chr_cleanup(void)static void register_types (void ) {type_register_static (&char_type_info); - -/* this must be done after machine init, since we register FEs with muxes -* as part of realize functions like serial_isa_realizefn when -nographic -* is specified -*/ -qemu_add_machine_init_done_notifier (&chardev_machine_done_notify); }type_init (register_types);chardev/chardev-sysemu.c new file +69
-0@@ -0,0 +1,69 @@ +/* +* QEMU System Emulator +* +* 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/sysemu.h" +#include "chardev/char.h" +#include "qemu/error-report.h" +#include "chardev-internal.h" + +static int chardev_machine_done_notify_one (Object *child,void *opaque) +{ +Chardev *chr = (Chardev *)child; +ChardevClass *class =CHARDEV_GET_CLASS (chr); + +if (class->chr_machine_done) { +return class->chr_machine_done (chr); + } + +return 0 ; +} + +static void chardev_machine_done_hook (Notifier *notifier,void *unused) +{ +int ret =object_child_foreach (get_chardevs_root (), + chardev_machine_done_notify_one,NULL ); + +if (ret) { +error_report ("Failed to call chardev machine_done hooks" ); +exit (1 ); + } +} + + +static Notifier chardev_machine_done_notify = { + .notify = chardev_machine_done_hook, +}; + +static void register_types (void ) +{ +/* +* This must be done after machine init, since we register FEs with muxes +* as part of realize functions like serial_isa_realizefn when -nographic +* is specified. +*/ +qemu_add_machine_init_done_notifier (&chardev_machine_done_notify); +} + +type_init (register_types);chardev/Makefile.objs +1
-1@@ -1,4 +1,5 @@ chardev-obj-y += char.o +chardev-obj-$(CONFIG_SOFTMMU) += chardev-sysemu.o chardev-obj-$(CONFIG_WIN32) += char-console.o chardev-obj-$(CONFIG_POSIX) += char-fd.o chardev-obj-y += char-fe.o --2.21.1
Signature · 1 line
Marc-André Lureau
Re: [PATCH 5/7] chardev: Extract system emulation specific code
In reply to Philippe Mathieu-DaudéQuoted 160 lines · Philippe Mathieu-Daudé
Split out code only used during system emulation, to reduce code pulled in user emulation and tools.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
chardev/chardev-internal.h | 3 ++ chardev/char.c | 35 +------------------ chardev/chardev-sysemu.c | 69 ++++++++++++++++++++++++++++++++++++++ chardev/Makefile.objs | 1 + 4 files changed, 74 insertions(+), 34 deletions(-)create mode 100644
chardev/chardev-sysemu.cchardev/chardev-internal.h +3
-0@@ -26,6 +26,7 @@#include "chardev/char.h" #include "chardev/char-fe.h" +#include "qom/object.h" #define MAX_MUX 4#define MUX_BUFFER_SIZE 32/* Must be a power of 2. */ @@ -59,4 +60,6 @@ typedef struct MuxChardev {void mux_set_focus (Chardev *chr,int focus);void mux_chr_send_all_event (Chardev *chr,QEMUChrEvent event); +Object *get_chardevs_root (void ); +#endif /* CHAR_MUX_H */ chardev/char.c +1
-34@@ -44,7 +44,7 @@/***********************************************************/ /* character device */ -static Object *get_chardevs_root (void ) +Object *get_chardevs_root (void ) {return container_get (object_get_root (),"/chardevs" ); }@@ -300,33 +300,6 @@ static const TypeInfo char_type_info = { .class_init = char_class_init, }; -static int chardev_machine_done_notify_one (Object *child,void *opaque) -{ -Chardev *chr = (Chardev *)child; -ChardevClass *class =CHARDEV_GET_CLASS (chr); - -if (class->chr_machine_done) { -return class->chr_machine_done (chr); - } - -return 0 ; -} - -static void chardev_machine_done_hook (Notifier *notifier,void *unused) -{ -int ret =object_child_foreach (get_chardevs_root (), - chardev_machine_done_notify_one,NULL ); - -if (ret) { -error_report ("Failed to call chardev machine_done hooks" ); -exit (1 ); - } -} - -static Notifier chardev_machine_done_notify = { - .notify = chardev_machine_done_hook, -}; -static bool qemu_chr_is_busy (Chardev *s) {if (CHARDEV_IS_MUX (s)) {@@ -1187,12 +1160,6 @@ void qemu_chr_cleanup(void)static void register_types (void ) {type_register_static (&char_type_info); - -/* this must be done after machine init, since we register FEs with muxes -* as part of realize functions like serial_isa_realizefn when -nographic -* is specified -*/ -qemu_add_machine_init_done_notifier (&chardev_machine_done_notify); }type_init (register_types);chardev/chardev-sysemu.c new file +59
-0@@ -0,0 +1,69 @@ +/* +* QEMU System Emulator +* +* 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/sysemu.h" +#include "chardev/char.h" +#include "qemu/error-report.h" +#include "chardev-internal.h" + +static int chardev_machine_done_notify_one (Object *child,void *opaque) +{ +Chardev *chr = (Chardev *)child; +ChardevClass *class =CHARDEV_GET_CLASS (chr); + +if (class->chr_machine_done) { +return class->chr_machine_done (chr); + } + +return 0 ; +} + +static void chardev_machine_done_hook (Notifier *notifier,void *unused) +{ +int ret =object_child_foreach (get_chardevs_root (), + chardev_machine_done_notify_one,NULL ); + +if (ret) { +error_report ("Failed to call chardev machine_done hooks" ); +exit (1 ); + } +} + + +static Notifier chardev_machine_done_notify = { + .notify = chardev_machine_done_hook, +}; + +static void register_types (void )
chardev/chardev-sysemu.c line 69
Quoted 10 lines
chardev/chardev-sysemu.c new file +10
-0+{ +/* +* This must be done after machine init, since we register FEs with muxes +* as part of realize functions like serial_isa_realizefn when -nographic +* is specified. +*/ +qemu_add_machine_init_done_notifier (&chardev_machine_done_notify); +} + +type_init (register_types);
Could you please confirm if we could use “type_init” for something other than a class?
May be the chardev machine init notified could be initialized by vl.c?
Quoted 13 lines
chardev/Makefile.objs +0
-0@@ -1,4 +1,5 @@chardev-obj-y += char.o +chardev-obj-$(CONFIG_SOFTMMU) += chardev-sysemu.o chardev-obj-$(CONFIG_WIN32) += char-console.o chardev-obj-$(CONFIG_POSIX) += char-fd.o chardev-obj-y += char-fe.o
Signature · 1 line
2.21.1
PATCH 6/7 stubs: Split machine-init-done as machine-init and machine-notify
In reply to Philippe Mathieu-DaudéAs the machine notify handlers are only used in system emulation, split the current file in two, and only build the notifier when system emulation is used.
---
stubs/machine-init.c | 4 ++++
stubs/{machine-init-done.c => machine-notify.c} | 2 --
stubs/Makefile.objs | 3 ++-
3 files changed, 6 insertions(+), 3 deletions(-)
create mode 100644 stubs/machine-init.c
rename stubs/{machine-init-done.c => machine-notify.c} (78%)stubs/machine-init.c new file +4 -0
@@ -0,0 +1,4 @@ +#include "qemu/osdep.h" +#include "sysemu/sysemu.h" + +bool machine_init_done = true;
stubs/machine-notify.c renamed from stubs/machine-init-done.c +0 -2
@@ -1,8 +1,6 @@#include "qemu/osdep.h" #include "sysemu/sysemu.h" -bool machine_init_done = true; -void qemu_add_machine_init_done_notifier (Notifier *notify) { }
stubs/Makefile.objs +2 -1
@@ -15,7 +15,8 @@ stub-obj-y += iothread-lock.o stub-obj-y += is-daemonized.o stub-obj-$(CONFIG_LINUX_AIO) += linux-aio.o stub-obj-$(CONFIG_LINUX_IO_URING) += io_uring.o -stub-obj-y += machine-init-done.o +stub-obj-y += machine-init.o +stub-obj-$(CONFIG_SOFTMMU) += machine-notify.o stub-obj-y += migr-blocker.o stub-obj-y += change-state-handler.o stub-obj-y += monitor.o
Signature · 1 line
2.21.1
Re: [PATCH 6/7] stubs: Split machine-init-done as machine-init and machine-notify
Quoted 6 lines · Philippe Mathieu-Daudé
As the machine notify handlers are only used in system emulation, split the current file in two, and only build the notifier when system emulation is used.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>
Quoted 52 lines
--- stubs/machine-init.c | 4 ++++ stubs/{machine-init-done.c => machine-notify.c} | 2 -- stubs/Makefile.objs | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 stubs/machine-init.c rename stubs/{machine-init-done.c => machine-notify.c} (78%)stubs/machine-init.c new file +4
-0@@ -0,0 +1,4 @@ +#include "qemu/osdep.h" +#include "sysemu/sysemu.h" + +bool machine_init_done = true;stubs/machine-notify.c renamed from stubs/machine-init-done.c +0
-2@@ -1,8 +1,6 @@#include "qemu/osdep.h" #include "sysemu/sysemu.h" -bool machine_init_done = true; -void qemu_add_machine_init_done_notifier (Notifier *notify) { }stubs/Makefile.objs +2
-2@@ -15,7 +15,8 @@ stub-obj-y += iothread-lock.o stub-obj-y += is-daemonized.o stub-obj-$(CONFIG_LINUX_AIO) += linux-aio.o stub-obj-$(CONFIG_LINUX_IO_URING) += io_uring.o -stub-obj-y += machine-init-done.o +stub-obj-y += machine-init.o +stub-obj-$(CONFIG_SOFTMMU) += machine-notify.o stub-obj-y += migr-blocker.o stub-obj-y += change-state-handler.o stub-obj-y += monitor.o --2.21.1
Signature · 1 line
Marc-André Lureau
PATCH 7/7 multi-process: Refactor machine_init and exit notifiers
In reply to Philippe Mathieu-DaudéFrom: Elena Ufimtseva <[email protected]>
Relocate machine_int and exit notifiers into common code
--- Makefile.objs | 1 + include/sysemu/sysemu.h | 2 ++ softmmu/vl.c | 42 ------------------------- stubs/machine-notify.c | 4 +++ util/machine-notify.c | 69 +++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + 6 files changed, 77 insertions(+), 42 deletions(-) create mode 100644 util/machine-notify.c
Makefile.objs +1 -0
@@ -79,6 +79,7 @@ qemu-seccomp.o-libs := $(SECCOMP_LIBS) common-obj-$(CONFIG_FDT) += device_tree.o common-obj-y += qapi/ +common-obj-y += util/machine-notify.o endif # CONFIG_SOFTMMU
include/sysemu/sysemu.h +2 -0
@@ -17,11 +17,13 @@ extern bool qemu_uuid_set;void qemu_add_exit_notifier (Notifier *notify);void qemu_remove_exit_notifier (Notifier *notify); +void qemu_run_exit_notifiers (void );extern bool machine_init_done;void qemu_add_machine_init_done_notifier (Notifier *notify);void qemu_remove_machine_init_done_notifier (Notifier *notify); +void qemu_run_machine_init_done_notifiers (void );extern int autostart;
softmmu/vl.c +0 -42
60 lines not on this page · raw message
stubs/machine-notify.c +4 -0
@@ -4,3 +4,7 @@void qemu_add_machine_init_done_notifier (Notifier *notify) { } + +void qemu_remove_machine_init_done_notifier (Notifier *notify) +{ +}
util/machine-notify.c new file +69 -0
69 lines not on this page · raw message
MAINTAINERS +1 -0
@@ -2133,6 +2133,7 @@ F: util/qemu-timer.c F: softmmu/vl.c F: softmmu/main.c F: qapi/run-state.json +F: util/machine-notify.c Human Monitor (HMP) M: Dr. David Alan Gilbert <[email protected]>
Signature · 1 line
2.21.1
Quoted 7 lines · Philippe Mathieu-Daudé
chardev cleanup while reviewing 'Refactor
machine_initand exit notifiers' from the multi-process series:
https://www.mail-archive.com/[email protected]/msg697510.htmlElena Ufimtseva (1):
multi-process: Refactormachine_initand exit notifiers
Quoted 7 lines
Philippe Mathieu-Daudé (6):
monitor/misc: Remove unused "chardev/char-mux.h" include tests/test-char: Remove unused "chardev/char-mux.h" include
chardev: Restrict msmouse / wctablet / testdev to system emulation
chardev: Reduce "char-mux.h" scope, rename it "chardev-internal.h"
chardev: Extract system emulation specific code
stubs: Split machine-init-done as machine-init and machine-notify
r~