* [PATCH 1/7] monitor/misc: Remove unused "chardev/char-mux.h" include
2020-04-23 20:21 [PATCH 0/7] chardev: Reduce system emulation specific code Philippe Mathieu-Daudé
@ 2020-04-23 20:21 ` Philippe Mathieu-Daudé
2020-04-23 20:42 ` Marc-André Lureau
2020-04-23 20:21 ` [PATCH 2/7] tests/test-char: " Philippe Mathieu-Daudé
` (6 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-23 20:21 UTC (permalink / raw)
To: qemu-devel
Cc: Elena Ufimtseva, John G Johnson, Jagannathan Raman,
Dr. David Alan Gilbert, Markus Armbruster,
Marc-André Lureau, Paolo Bonzini,
Philippe Mathieu-Daudé
monitor/misc.c never required "chardev/char-mux.h", remove it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
monitor/misc.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/monitor/misc.c b/monitor/misc.c
index 6c45fa490f..5d68026a7f 100644
--- a/monitor/misc.c
+++ b/monitor/misc.c
@@ -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
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 1/7] monitor/misc: Remove unused "chardev/char-mux.h" include
2020-04-23 20:21 ` [PATCH 1/7] monitor/misc: Remove unused "chardev/char-mux.h" include Philippe Mathieu-Daudé
@ 2020-04-23 20:42 ` Marc-André Lureau
0 siblings, 0 replies; 16+ messages in thread
From: Marc-André Lureau @ 2020-04-23 20:42 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Elena Ufimtseva, John G Johnson, Jagannathan Raman, QEMU,
Markus Armbruster, Paolo Bonzini, Dr. David Alan Gilbert
On Thu, Apr 23, 2020 at 10:23 PM Philippe Mathieu-Daudé
<philmd@redhat.com> wrote:
>
> monitor/misc.c never required "chardev/char-mux.h", remove it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> monitor/misc.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/monitor/misc.c b/monitor/misc.c
> index 6c45fa490f..5d68026a7f 100644
> --- a/monitor/misc.c
> +++ b/monitor/misc.c
> @@ -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
>
>
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 2/7] tests/test-char: Remove unused "chardev/char-mux.h" include
2020-04-23 20:21 [PATCH 0/7] chardev: Reduce system emulation specific code Philippe Mathieu-Daudé
2020-04-23 20:21 ` [PATCH 1/7] monitor/misc: Remove unused "chardev/char-mux.h" include Philippe Mathieu-Daudé
@ 2020-04-23 20:21 ` Philippe Mathieu-Daudé
2020-04-23 20:51 ` Marc-André Lureau
2020-04-23 20:21 ` [PATCH 3/7] chardev: Restrict msmouse / wctablet / testdev to system emulation Philippe Mathieu-Daudé
` (5 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-23 20:21 UTC (permalink / raw)
To: qemu-devel
Cc: Elena Ufimtseva, John G Johnson, Jagannathan Raman,
Dr. David Alan Gilbert, Markus Armbruster,
Marc-André Lureau, Paolo Bonzini,
Philippe Mathieu-Daudé
This test never required "chardev/char-mux.h", remove it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
tests/test-char.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/tests/test-char.c b/tests/test-char.c
index 3afc9b1b8d..f08a39790e 100644
--- a/tests/test-char.c
+++ b/tests/test-char.c
@@ -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
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 2/7] tests/test-char: Remove unused "chardev/char-mux.h" include
2020-04-23 20:21 ` [PATCH 2/7] tests/test-char: " Philippe Mathieu-Daudé
@ 2020-04-23 20:51 ` Marc-André Lureau
0 siblings, 0 replies; 16+ messages in thread
From: Marc-André Lureau @ 2020-04-23 20:51 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Elena Ufimtseva, John G Johnson, Jagannathan Raman, QEMU,
Markus Armbruster, Paolo Bonzini, Dr. David Alan Gilbert
On Thu, Apr 23, 2020 at 10:22 PM Philippe Mathieu-Daudé
<philmd@redhat.com> wrote:
>
> This test never required "chardev/char-mux.h", remove it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> tests/test-char.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/tests/test-char.c b/tests/test-char.c
> index 3afc9b1b8d..f08a39790e 100644
> --- a/tests/test-char.c
> +++ b/tests/test-char.c
> @@ -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
>
>
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 3/7] chardev: Restrict msmouse / wctablet / testdev to system emulation
2020-04-23 20:21 [PATCH 0/7] chardev: Reduce system emulation specific code Philippe Mathieu-Daudé
2020-04-23 20:21 ` [PATCH 1/7] monitor/misc: Remove unused "chardev/char-mux.h" include Philippe Mathieu-Daudé
2020-04-23 20:21 ` [PATCH 2/7] tests/test-char: " Philippe Mathieu-Daudé
@ 2020-04-23 20:21 ` Philippe Mathieu-Daudé
2020-04-23 20:51 ` Marc-André Lureau
2020-04-23 20:21 ` [PATCH 4/7] chardev: Reduce "char-mux.h" scope, rename it "chardev-internal.h" Philippe Mathieu-Daudé
` (4 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-23 20:21 UTC (permalink / raw)
To: qemu-devel
Cc: Elena Ufimtseva, John G Johnson, Jagannathan Raman,
Dr. David Alan Gilbert, Markus Armbruster,
Marc-André Lureau, Paolo Bonzini,
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é <philmd@redhat.com>
---
chardev/Makefile.objs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/chardev/Makefile.objs b/chardev/Makefile.objs
index d68e1347f9..15ee7f47da 100644
--- a/chardev/Makefile.objs
+++ b/chardev/Makefile.objs
@@ -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
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 3/7] chardev: Restrict msmouse / wctablet / testdev to system emulation
2020-04-23 20:21 ` [PATCH 3/7] chardev: Restrict msmouse / wctablet / testdev to system emulation Philippe Mathieu-Daudé
@ 2020-04-23 20:51 ` Marc-André Lureau
0 siblings, 0 replies; 16+ messages in thread
From: Marc-André Lureau @ 2020-04-23 20:51 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Elena Ufimtseva, John G Johnson, Jagannathan Raman, QEMU,
Markus Armbruster, Paolo Bonzini, Dr. David Alan Gilbert
On Thu, Apr 23, 2020 at 10:22 PM Philippe Mathieu-Daudé
<philmd@redhat.com> wrote:
>
> 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é <philmd@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> chardev/Makefile.objs | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/chardev/Makefile.objs b/chardev/Makefile.objs
> index d68e1347f9..15ee7f47da 100644
> --- a/chardev/Makefile.objs
> +++ b/chardev/Makefile.objs
> @@ -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
>
>
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 4/7] chardev: Reduce "char-mux.h" scope, rename it "chardev-internal.h"
2020-04-23 20:21 [PATCH 0/7] chardev: Reduce system emulation specific code Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2020-04-23 20:21 ` [PATCH 3/7] chardev: Restrict msmouse / wctablet / testdev to system emulation Philippe Mathieu-Daudé
@ 2020-04-23 20:21 ` Philippe Mathieu-Daudé
2020-04-23 21:34 ` Marc-André Lureau
2020-04-23 20:21 ` [PATCH 5/7] chardev: Extract system emulation specific code Philippe Mathieu-Daudé
` (3 subsequent siblings)
7 siblings, 1 reply; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-23 20:21 UTC (permalink / raw)
To: qemu-devel
Cc: Elena Ufimtseva, John G Johnson, Jagannathan Raman,
Dr. David Alan Gilbert, Markus Armbruster,
Marc-André Lureau, Paolo Bonzini,
Philippe Mathieu-Daudé
No file out of chardev/ requires access to this header,
restrict its scope.
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
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%)
diff --git a/include/chardev/char-mux.h b/chardev/chardev-internal.h
similarity index 96%
rename from include/chardev/char-mux.h
rename to chardev/chardev-internal.h
index 417fe32eed..e0264ac349 100644
--- a/include/chardev/char-mux.h
+++ b/chardev/chardev-internal.h
@@ -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];
diff --git a/chardev/char-fe.c b/chardev/char-fe.c
index f3530a90e6..474715c5a9 100644
--- a/chardev/char-fe.c
+++ b/chardev/char-fe.c
@@ -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)
{
diff --git a/chardev/char-mux.c b/chardev/char-mux.c
index 46c44af67c..6f980bb836 100644
--- a/chardev/char-mux.c
+++ b/chardev/char-mux.c
@@ -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 */
diff --git a/chardev/char.c b/chardev/char.c
index e77564060d..b672a41150 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -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
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 4/7] chardev: Reduce "char-mux.h" scope, rename it "chardev-internal.h"
2020-04-23 20:21 ` [PATCH 4/7] chardev: Reduce "char-mux.h" scope, rename it "chardev-internal.h" Philippe Mathieu-Daudé
@ 2020-04-23 21:34 ` Marc-André Lureau
0 siblings, 0 replies; 16+ messages in thread
From: Marc-André Lureau @ 2020-04-23 21:34 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Elena Ufimtseva, John G Johnson, Jagannathan Raman, QEMU,
Markus Armbruster, Paolo Bonzini, Dr. David Alan Gilbert
On Thu, Apr 23, 2020 at 10:24 PM Philippe Mathieu-Daudé
<philmd@redhat.com> wrote:
>
> No file out of chardev/ requires access to this header,
> restrict its scope.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> 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%)
>
> diff --git a/include/chardev/char-mux.h b/chardev/chardev-internal.h
> similarity index 96%
> rename from include/chardev/char-mux.h
> rename to chardev/chardev-internal.h
> index 417fe32eed..e0264ac349 100644
> --- a/include/chardev/char-mux.h
> +++ b/chardev/chardev-internal.h
> @@ -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];
> diff --git a/chardev/char-fe.c b/chardev/char-fe.c
> index f3530a90e6..474715c5a9 100644
> --- a/chardev/char-fe.c
> +++ b/chardev/char-fe.c
> @@ -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)
> {
> diff --git a/chardev/char-mux.c b/chardev/char-mux.c
> index 46c44af67c..6f980bb836 100644
> --- a/chardev/char-mux.c
> +++ b/chardev/char-mux.c
> @@ -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 */
>
> diff --git a/chardev/char.c b/chardev/char.c
> index e77564060d..b672a41150 100644
> --- a/chardev/char.c
> +++ b/chardev/char.c
> @@ -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
>
>
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 5/7] chardev: Extract system emulation specific code
2020-04-23 20:21 [PATCH 0/7] chardev: Reduce system emulation specific code Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2020-04-23 20:21 ` [PATCH 4/7] chardev: Reduce "char-mux.h" scope, rename it "chardev-internal.h" Philippe Mathieu-Daudé
@ 2020-04-23 20:21 ` Philippe Mathieu-Daudé
2020-04-23 21:34 ` Marc-André Lureau
2020-04-24 13:19 ` Jag Raman
2020-04-23 20:21 ` [PATCH 6/7] stubs: Split machine-init-done as machine-init and machine-notify Philippe Mathieu-Daudé
` (2 subsequent siblings)
7 siblings, 2 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-23 20:21 UTC (permalink / raw)
To: qemu-devel
Cc: Elena Ufimtseva, John G Johnson, Jagannathan Raman,
Dr. David Alan Gilbert, Markus Armbruster,
Marc-André Lureau, Paolo Bonzini,
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é <philmd@redhat.com>
---
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
diff --git a/chardev/chardev-internal.h b/chardev/chardev-internal.h
index e0264ac349..f4d0429763 100644
--- a/chardev/chardev-internal.h
+++ b/chardev/chardev-internal.h
@@ -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 */
diff --git a/chardev/char.c b/chardev/char.c
index b672a41150..555bb0448e 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -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);
diff --git a/chardev/chardev-sysemu.c b/chardev/chardev-sysemu.c
new file mode 100644
index 0000000000..eecdc615ee
--- /dev/null
+++ b/chardev/chardev-sysemu.c
@@ -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);
diff --git a/chardev/Makefile.objs b/chardev/Makefile.objs
index 15ee7f47da..a10acbc2b8 100644
--- a/chardev/Makefile.objs
+++ b/chardev/Makefile.objs
@@ -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
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 5/7] chardev: Extract system emulation specific code
2020-04-23 20:21 ` [PATCH 5/7] chardev: Extract system emulation specific code Philippe Mathieu-Daudé
@ 2020-04-23 21:34 ` Marc-André Lureau
2020-04-24 13:19 ` Jag Raman
1 sibling, 0 replies; 16+ messages in thread
From: Marc-André Lureau @ 2020-04-23 21:34 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Elena Ufimtseva, John G Johnson, Jagannathan Raman, QEMU,
Markus Armbruster, Paolo Bonzini, Dr. David Alan Gilbert
On Thu, Apr 23, 2020 at 10:24 PM Philippe Mathieu-Daudé
<philmd@redhat.com> wrote:
>
> Split out code only used during system emulation,
> to reduce code pulled in user emulation and tools.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> 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
>
> diff --git a/chardev/chardev-internal.h b/chardev/chardev-internal.h
> index e0264ac349..f4d0429763 100644
> --- a/chardev/chardev-internal.h
> +++ b/chardev/chardev-internal.h
> @@ -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 */
> diff --git a/chardev/char.c b/chardev/char.c
> index b672a41150..555bb0448e 100644
> --- a/chardev/char.c
> +++ b/chardev/char.c
> @@ -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);
> diff --git a/chardev/chardev-sysemu.c b/chardev/chardev-sysemu.c
> new file mode 100644
> index 0000000000..eecdc615ee
> --- /dev/null
> +++ b/chardev/chardev-sysemu.c
> @@ -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);
> diff --git a/chardev/Makefile.objs b/chardev/Makefile.objs
> index 15ee7f47da..a10acbc2b8 100644
> --- a/chardev/Makefile.objs
> +++ b/chardev/Makefile.objs
> @@ -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
>
>
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 5/7] chardev: Extract system emulation specific code
2020-04-23 20:21 ` [PATCH 5/7] chardev: Extract system emulation specific code Philippe Mathieu-Daudé
2020-04-23 21:34 ` Marc-André Lureau
@ 2020-04-24 13:19 ` Jag Raman
1 sibling, 0 replies; 16+ messages in thread
From: Jag Raman @ 2020-04-24 13:19 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Elena Ufimtseva, John G Johnson, Markus Armbruster, qemu-devel,
Dr. David Alan Gilbert, Marc-André Lureau, Paolo Bonzini
> On Apr 23, 2020, at 4:21 PM, Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
>
> Split out code only used during system emulation,
> to reduce code pulled in user emulation and tools.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> 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
>
> diff --git a/chardev/chardev-internal.h b/chardev/chardev-internal.h
> index e0264ac349..f4d0429763 100644
> --- a/chardev/chardev-internal.h
> +++ b/chardev/chardev-internal.h
> @@ -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 */
> diff --git a/chardev/char.c b/chardev/char.c
> index b672a41150..555bb0448e 100644
> --- a/chardev/char.c
> +++ b/chardev/char.c
> @@ -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);
> diff --git a/chardev/chardev-sysemu.c b/chardev/chardev-sysemu.c
> new file mode 100644
> index 0000000000..eecdc615ee
> --- /dev/null
> +++ b/chardev/chardev-sysemu.c
> @@ -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);
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?
> diff --git a/chardev/Makefile.objs b/chardev/Makefile.objs
> index 15ee7f47da..a10acbc2b8 100644
> --- a/chardev/Makefile.objs
> +++ b/chardev/Makefile.objs
> @@ -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
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 6/7] stubs: Split machine-init-done as machine-init and machine-notify
2020-04-23 20:21 [PATCH 0/7] chardev: Reduce system emulation specific code Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2020-04-23 20:21 ` [PATCH 5/7] chardev: Extract system emulation specific code Philippe Mathieu-Daudé
@ 2020-04-23 20:21 ` Philippe Mathieu-Daudé
2020-04-23 20:43 ` Marc-André Lureau
2020-04-23 20:21 ` [PATCH 7/7] multi-process: Refactor machine_init and exit notifiers Philippe Mathieu-Daudé
2020-04-24 3:49 ` [PATCH 0/7] chardev: Reduce system emulation specific code Richard Henderson
7 siblings, 1 reply; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-23 20:21 UTC (permalink / raw)
To: qemu-devel
Cc: Elena Ufimtseva, John G Johnson, Jagannathan Raman,
Dr. David Alan Gilbert, Markus Armbruster,
Marc-André Lureau, Paolo Bonzini,
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é <philmd@redhat.com>
---
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%)
diff --git a/stubs/machine-init.c b/stubs/machine-init.c
new file mode 100644
index 0000000000..7622930ee0
--- /dev/null
+++ b/stubs/machine-init.c
@@ -0,0 +1,4 @@
+#include "qemu/osdep.h"
+#include "sysemu/sysemu.h"
+
+bool machine_init_done = true;
diff --git a/stubs/machine-init-done.c b/stubs/machine-notify.c
similarity index 78%
rename from stubs/machine-init-done.c
rename to stubs/machine-notify.c
index cd8e81392d..d164ecccb9 100644
--- a/stubs/machine-init-done.c
+++ b/stubs/machine-notify.c
@@ -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)
{
}
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index 45be5dc0ed..765659a3f9 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -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
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 6/7] stubs: Split machine-init-done as machine-init and machine-notify
2020-04-23 20:21 ` [PATCH 6/7] stubs: Split machine-init-done as machine-init and machine-notify Philippe Mathieu-Daudé
@ 2020-04-23 20:43 ` Marc-André Lureau
0 siblings, 0 replies; 16+ messages in thread
From: Marc-André Lureau @ 2020-04-23 20:43 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Elena Ufimtseva, John G Johnson, Jagannathan Raman, QEMU,
Markus Armbruster, Paolo Bonzini, Dr. David Alan Gilbert
On Thu, Apr 23, 2020 at 10:22 PM Philippe Mathieu-Daudé
<philmd@redhat.com> wrote:
>
> 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é <philmd@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> 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%)
>
> diff --git a/stubs/machine-init.c b/stubs/machine-init.c
> new file mode 100644
> index 0000000000..7622930ee0
> --- /dev/null
> +++ b/stubs/machine-init.c
> @@ -0,0 +1,4 @@
> +#include "qemu/osdep.h"
> +#include "sysemu/sysemu.h"
> +
> +bool machine_init_done = true;
> diff --git a/stubs/machine-init-done.c b/stubs/machine-notify.c
> similarity index 78%
> rename from stubs/machine-init-done.c
> rename to stubs/machine-notify.c
> index cd8e81392d..d164ecccb9 100644
> --- a/stubs/machine-init-done.c
> +++ b/stubs/machine-notify.c
> @@ -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)
> {
> }
> diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
> index 45be5dc0ed..765659a3f9 100644
> --- a/stubs/Makefile.objs
> +++ b/stubs/Makefile.objs
> @@ -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
>
>
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 7/7] multi-process: Refactor machine_init and exit notifiers
2020-04-23 20:21 [PATCH 0/7] chardev: Reduce system emulation specific code Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2020-04-23 20:21 ` [PATCH 6/7] stubs: Split machine-init-done as machine-init and machine-notify Philippe Mathieu-Daudé
@ 2020-04-23 20:21 ` Philippe Mathieu-Daudé
2020-04-24 3:49 ` [PATCH 0/7] chardev: Reduce system emulation specific code Richard Henderson
7 siblings, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-04-23 20:21 UTC (permalink / raw)
To: qemu-devel
Cc: Elena Ufimtseva, John G Johnson, Jagannathan Raman,
Dr. David Alan Gilbert, Markus Armbruster,
Marc-André Lureau, Paolo Bonzini,
Philippe Mathieu-Daudé
From: Elena Ufimtseva <elena.ufimtseva@oracle.com>
Relocate machine_int and exit notifiers into common code
Signed-off-by: Elena Ufimtseva <elena.ufimtseva@oracle.com>
Signed-off-by: John G Johnson <john.g.johnson@oracle.com>
Signed-off-by: Jagannathan Raman <jag.raman@oracle.com>
[PMD: Removed NotifierList machine_init_done_notifiers stub]
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
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
diff --git a/Makefile.objs b/Makefile.objs
index a7c967633a..bfb9271862 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -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
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index ef81302e1a..2438dd7bea 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -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;
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 32c0047889..39cbb6b50d 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -172,12 +172,6 @@ int icount_align_option;
QemuUUID qemu_uuid;
bool qemu_uuid_set;
-static NotifierList exit_notifiers =
- NOTIFIER_LIST_INITIALIZER(exit_notifiers);
-
-static NotifierList machine_init_done_notifiers =
- NOTIFIER_LIST_INITIALIZER(machine_init_done_notifiers);
-
bool xen_allowed;
uint32_t xen_domid;
enum xen_mode xen_mode = XEN_EMULATE;
@@ -2325,21 +2319,6 @@ static MachineClass *machine_parse(const char *name, GSList *machines)
return mc;
}
-void qemu_add_exit_notifier(Notifier *notify)
-{
- notifier_list_add(&exit_notifiers, notify);
-}
-
-void qemu_remove_exit_notifier(Notifier *notify)
-{
- notifier_remove(notify);
-}
-
-static void qemu_run_exit_notifiers(void)
-{
- notifier_list_notify(&exit_notifiers, NULL);
-}
-
static const char *pid_file;
static Notifier qemu_unlink_pidfile_notifier;
@@ -2350,27 +2329,6 @@ static void qemu_unlink_pidfile(Notifier *n, void *data)
}
}
-bool machine_init_done;
-
-void qemu_add_machine_init_done_notifier(Notifier *notify)
-{
- notifier_list_add(&machine_init_done_notifiers, notify);
- if (machine_init_done) {
- notify->notify(notify, NULL);
- }
-}
-
-void qemu_remove_machine_init_done_notifier(Notifier *notify)
-{
- notifier_remove(notify);
-}
-
-static void qemu_run_machine_init_done_notifiers(void)
-{
- machine_init_done = true;
- notifier_list_notify(&machine_init_done_notifiers, NULL);
-}
-
static const QEMUOption *lookup_opt(int argc, char **argv,
const char **poptarg, int *poptind)
{
diff --git a/stubs/machine-notify.c b/stubs/machine-notify.c
index d164ecccb9..71eba45b0f 100644
--- a/stubs/machine-notify.c
+++ b/stubs/machine-notify.c
@@ -4,3 +4,7 @@
void qemu_add_machine_init_done_notifier(Notifier *notify)
{
}
+
+void qemu_remove_machine_init_done_notifier(Notifier *notify)
+{
+}
diff --git a/util/machine-notify.c b/util/machine-notify.c
new file mode 100644
index 0000000000..718af79335
--- /dev/null
+++ b/util/machine-notify.c
@@ -0,0 +1,69 @@
+/*
+ * Machine notifiers.
+ *
+ * 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 "qemu/notify.h"
+#include "sysemu/sysemu.h"
+
+static NotifierList machine_init_done_notifiers =
+ NOTIFIER_LIST_INITIALIZER(machine_init_done_notifiers);
+
+static NotifierList exit_notifiers =
+ NOTIFIER_LIST_INITIALIZER(exit_notifiers);
+
+bool machine_init_done;
+
+void qemu_add_machine_init_done_notifier(Notifier *notify)
+{
+ notifier_list_add(&machine_init_done_notifiers, notify);
+ if (machine_init_done) {
+ notify->notify(notify, NULL);
+ }
+}
+
+void qemu_remove_machine_init_done_notifier(Notifier *notify)
+{
+ notifier_remove(notify);
+}
+
+void qemu_run_machine_init_done_notifiers(void)
+{
+ machine_init_done = true;
+ notifier_list_notify(&machine_init_done_notifiers, NULL);
+}
+
+void qemu_add_exit_notifier(Notifier *notify)
+{
+ notifier_list_add(&exit_notifiers, notify);
+}
+
+void qemu_remove_exit_notifier(Notifier *notify)
+{
+ notifier_remove(notify);
+}
+
+void qemu_run_exit_notifiers(void)
+{
+ notifier_list_notify(&exit_notifiers, NULL);
+}
diff --git a/MAINTAINERS b/MAINTAINERS
index 8cbc1fac2b..04b19ac56c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -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 <dgilbert@redhat.com>
--
2.21.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 0/7] chardev: Reduce system emulation specific code
2020-04-23 20:21 [PATCH 0/7] chardev: Reduce system emulation specific code Philippe Mathieu-Daudé
` (6 preceding siblings ...)
2020-04-23 20:21 ` [PATCH 7/7] multi-process: Refactor machine_init and exit notifiers Philippe Mathieu-Daudé
@ 2020-04-24 3:49 ` Richard Henderson
7 siblings, 0 replies; 16+ messages in thread
From: Richard Henderson @ 2020-04-24 3:49 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Elena Ufimtseva, John G Johnson, Jagannathan Raman,
Dr. David Alan Gilbert, Markus Armbruster, Paolo Bonzini,
Marc-André Lureau
On 4/23/20 1:21 PM, Philippe Mathieu-Daudé wrote:
> chardev cleanup while reviewing 'Refactor machine_init and exit
> notifiers' from the multi-process series:
> https://www.mail-archive.com/qemu-devel@nongnu.org/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
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 16+ messages in thread