[PATCH 03/17] monitor: rename monitor_init* to monitor_new*

Daniel P. Berrangé posted 17 patches 1 day, 1 hour ago
Maintainers: "Marc-André Lureau" <marcandre.lureau@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>, "Dr. David Alan Gilbert" <dave@treblig.org>, Markus Armbruster <armbru@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Eric Blake <eblake@redhat.com>, Kevin Wolf <kwolf@redhat.com>
[PATCH 03/17] monitor: rename monitor_init* to monitor_new*
Posted by Daniel P. Berrangé 1 day, 1 hour ago
The current "monitor_init" functions will clash with the methods of the
same name that are required by QOM. To ease the transition to QOM,
rename them out of the way.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 chardev/char.c                       |  2 +-
 gdbstub/system.c                     |  2 +-
 include/monitor/monitor.h            |  8 ++++----
 monitor/hmp.c                        |  2 +-
 monitor/monitor.c                    | 10 +++++-----
 monitor/qmp.c                        |  2 +-
 storage-daemon/qemu-storage-daemon.c |  2 +-
 stubs/monitor-internal.c             |  2 +-
 system/vl.c                          |  2 +-
 9 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/chardev/char.c b/chardev/char.c
index 48b326d57b..b59972f325 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -786,7 +786,7 @@ static Chardev *qemu_chr_new_from_name(const char *label, const char *filename,
 
     if (qemu_opt_get_bool(opts, "mux", 0)) {
         assert(permit_mux_mon);
-        monitor_init_hmp(chr, true, &err);
+        monitor_new_hmp(chr, true, &err);
         if (err) {
             error_report_err(err);
             object_unparent(OBJECT(chr));
diff --git a/gdbstub/system.c b/gdbstub/system.c
index e86c5870ab..20dcf7878d 100644
--- a/gdbstub/system.c
+++ b/gdbstub/system.c
@@ -388,7 +388,7 @@ bool gdbserver_start(const char *device, Error **errp)
         /* Initialize a monitor terminal for gdb */
         mon_chr = qemu_chardev_new(NULL, TYPE_CHARDEV_GDB,
                                    NULL, NULL, &error_abort);
-        monitor_init_hmp(mon_chr, false, &error_abort);
+        monitor_new_hmp(mon_chr, false, &error_abort);
     } else {
         qemu_chr_fe_deinit(&gdbserver_system_state.chr, true);
         mon_chr = gdbserver_system_state.mon_chr;
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
index 296690e1f1..bfbb440550 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -19,10 +19,10 @@ bool monitor_cur_is_qmp(void);
 
 void monitor_init_globals(void);
 void monitor_init_globals_core(void);
-void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp);
-void monitor_init_hmp(Chardev *chr, bool use_readline, Error **errp);
-int monitor_init(MonitorOptions *opts, bool allow_hmp, Error **errp);
-int monitor_init_opts(QemuOpts *opts, Error **errp);
+void monitor_new_qmp(Chardev *chr, bool pretty, Error **errp);
+void monitor_new_hmp(Chardev *chr, bool use_readline, Error **errp);
+int monitor_new(MonitorOptions *opts, bool allow_hmp, Error **errp);
+int monitor_new_opts(QemuOpts *opts, Error **errp);
 void monitor_cleanup(void);
 
 int monitor_suspend(Monitor *mon);
diff --git a/monitor/hmp.c b/monitor/hmp.c
index af346d190b..6dfeca84b5 100644
--- a/monitor/hmp.c
+++ b/monitor/hmp.c
@@ -1516,7 +1516,7 @@ static void monitor_readline_flush(void *opaque)
     monitor_flush(&mon->parent);
 }
 
-void monitor_init_hmp(Chardev *chr, bool use_readline, Error **errp)
+void monitor_new_hmp(Chardev *chr, bool use_readline, Error **errp)
 {
     MonitorHMP *mon = g_new0(MonitorHMP, 1);
 
diff --git a/monitor/monitor.c b/monitor/monitor.c
index 6b183edcf5..393fb7795e 100644
--- a/monitor/monitor.c
+++ b/monitor/monitor.c
@@ -715,7 +715,7 @@ void monitor_init_globals(void)
     aio_co_schedule(iohandler_get_aio_context(), qmp_dispatcher_co);
 }
 
-int monitor_init(MonitorOptions *opts, bool allow_hmp, Error **errp)
+int monitor_new(MonitorOptions *opts, bool allow_hmp, Error **errp)
 {
     ERRP_GUARD();
     Chardev *chr;
@@ -732,7 +732,7 @@ int monitor_init(MonitorOptions *opts, bool allow_hmp, Error **errp)
 
     switch (opts->mode) {
     case MONITOR_MODE_CONTROL:
-        monitor_init_qmp(chr, opts->pretty, errp);
+        monitor_new_qmp(chr, opts->pretty, errp);
         break;
     case MONITOR_MODE_READLINE:
         if (!allow_hmp) {
@@ -743,7 +743,7 @@ int monitor_init(MonitorOptions *opts, bool allow_hmp, Error **errp)
             error_setg(errp, "'pretty' is not compatible with HMP monitors");
             return -1;
         }
-        monitor_init_hmp(chr, true, errp);
+        monitor_new_hmp(chr, true, errp);
         break;
     default:
         g_assert_not_reached();
@@ -752,7 +752,7 @@ int monitor_init(MonitorOptions *opts, bool allow_hmp, Error **errp)
     return *errp ? -1 : 0;
 }
 
-int monitor_init_opts(QemuOpts *opts, Error **errp)
+int monitor_new_opts(QemuOpts *opts, Error **errp)
 {
     Visitor *v;
     MonitorOptions *options;
@@ -765,7 +765,7 @@ int monitor_init_opts(QemuOpts *opts, Error **errp)
         return -1;
     }
 
-    ret = monitor_init(options, true, errp);
+    ret = monitor_new(options, true, errp);
     qapi_free_MonitorOptions(options);
     return ret;
 }
diff --git a/monitor/qmp.c b/monitor/qmp.c
index 69d9e40e32..9caee70624 100644
--- a/monitor/qmp.c
+++ b/monitor/qmp.c
@@ -513,7 +513,7 @@ static void monitor_qmp_setup_handlers_bh(void *opaque)
     monitor_list_append(&mon->parent);
 }
 
-void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp)
+void monitor_new_qmp(Chardev *chr, bool pretty, Error **errp)
 {
     MonitorQMP *mon = g_new0(MonitorQMP, 1);
 
diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-storage-daemon.c
index eb72561358..50dbfbd97a 100644
--- a/storage-daemon/qemu-storage-daemon.c
+++ b/storage-daemon/qemu-storage-daemon.c
@@ -330,7 +330,7 @@ static void process_options(int argc, char *argv[], bool pre_init_pass)
                 visit_free(v);
 
                 /* TODO Catch duplicate monitor IDs */
-                monitor_init(monitor, false, &error_fatal);
+                monitor_new(monitor, false, &error_fatal);
                 qapi_free_MonitorOptions(monitor);
                 break;
             }
diff --git a/stubs/monitor-internal.c b/stubs/monitor-internal.c
index 4fece49d53..23d58da184 100644
--- a/stubs/monitor-internal.c
+++ b/stubs/monitor-internal.c
@@ -8,6 +8,6 @@ int monitor_get_fd(Monitor *mon, const char *name, Error **errp)
     return -1;
 }
 
-void monitor_init_hmp(Chardev *chr, bool use_readline, Error **errp)
+void monitor_new_hmp(Chardev *chr, bool use_readline, Error **errp)
 {
 }
diff --git a/system/vl.c b/system/vl.c
index 246623b319..2391811a46 100644
--- a/system/vl.c
+++ b/system/vl.c
@@ -1244,7 +1244,7 @@ static int fsdev_init_func(void *opaque, QemuOpts *opts, Error **errp)
 
 static int mon_init_func(void *opaque, QemuOpts *opts, Error **errp)
 {
-    return monitor_init_opts(opts, errp);
+    return monitor_new_opts(opts, errp);
 }
 
 static void monitor_parse(const char *str, const char *mode, bool pretty)
-- 
2.53.0


Re: [PATCH 03/17] monitor: rename monitor_init* to monitor_new*
Posted by Dr. David Alan Gilbert 18 hours ago
* Daniel P. Berrangé (berrange@redhat.com) wrote:
> The current "monitor_init" functions will clash with the methods of the
> same name that are required by QOM. To ease the transition to QOM,
> rename them out of the way.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>

Reviewed-by: Dr. David Alan Gilbert <dave@treblig.org>

> ---
>  chardev/char.c                       |  2 +-
>  gdbstub/system.c                     |  2 +-
>  include/monitor/monitor.h            |  8 ++++----
>  monitor/hmp.c                        |  2 +-
>  monitor/monitor.c                    | 10 +++++-----
>  monitor/qmp.c                        |  2 +-
>  storage-daemon/qemu-storage-daemon.c |  2 +-
>  stubs/monitor-internal.c             |  2 +-
>  system/vl.c                          |  2 +-
>  9 files changed, 16 insertions(+), 16 deletions(-)
> 
> diff --git a/chardev/char.c b/chardev/char.c
> index 48b326d57b..b59972f325 100644
> --- a/chardev/char.c
> +++ b/chardev/char.c
> @@ -786,7 +786,7 @@ static Chardev *qemu_chr_new_from_name(const char *label, const char *filename,
>  
>      if (qemu_opt_get_bool(opts, "mux", 0)) {
>          assert(permit_mux_mon);
> -        monitor_init_hmp(chr, true, &err);
> +        monitor_new_hmp(chr, true, &err);
>          if (err) {
>              error_report_err(err);
>              object_unparent(OBJECT(chr));
> diff --git a/gdbstub/system.c b/gdbstub/system.c
> index e86c5870ab..20dcf7878d 100644
> --- a/gdbstub/system.c
> +++ b/gdbstub/system.c
> @@ -388,7 +388,7 @@ bool gdbserver_start(const char *device, Error **errp)
>          /* Initialize a monitor terminal for gdb */
>          mon_chr = qemu_chardev_new(NULL, TYPE_CHARDEV_GDB,
>                                     NULL, NULL, &error_abort);
> -        monitor_init_hmp(mon_chr, false, &error_abort);
> +        monitor_new_hmp(mon_chr, false, &error_abort);
>      } else {
>          qemu_chr_fe_deinit(&gdbserver_system_state.chr, true);
>          mon_chr = gdbserver_system_state.mon_chr;
> diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
> index 296690e1f1..bfbb440550 100644
> --- a/include/monitor/monitor.h
> +++ b/include/monitor/monitor.h
> @@ -19,10 +19,10 @@ bool monitor_cur_is_qmp(void);
>  
>  void monitor_init_globals(void);
>  void monitor_init_globals_core(void);
> -void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp);
> -void monitor_init_hmp(Chardev *chr, bool use_readline, Error **errp);
> -int monitor_init(MonitorOptions *opts, bool allow_hmp, Error **errp);
> -int monitor_init_opts(QemuOpts *opts, Error **errp);
> +void monitor_new_qmp(Chardev *chr, bool pretty, Error **errp);
> +void monitor_new_hmp(Chardev *chr, bool use_readline, Error **errp);
> +int monitor_new(MonitorOptions *opts, bool allow_hmp, Error **errp);
> +int monitor_new_opts(QemuOpts *opts, Error **errp);
>  void monitor_cleanup(void);
>  
>  int monitor_suspend(Monitor *mon);
> diff --git a/monitor/hmp.c b/monitor/hmp.c
> index af346d190b..6dfeca84b5 100644
> --- a/monitor/hmp.c
> +++ b/monitor/hmp.c
> @@ -1516,7 +1516,7 @@ static void monitor_readline_flush(void *opaque)
>      monitor_flush(&mon->parent);
>  }
>  
> -void monitor_init_hmp(Chardev *chr, bool use_readline, Error **errp)
> +void monitor_new_hmp(Chardev *chr, bool use_readline, Error **errp)
>  {
>      MonitorHMP *mon = g_new0(MonitorHMP, 1);
>  
> diff --git a/monitor/monitor.c b/monitor/monitor.c
> index 6b183edcf5..393fb7795e 100644
> --- a/monitor/monitor.c
> +++ b/monitor/monitor.c
> @@ -715,7 +715,7 @@ void monitor_init_globals(void)
>      aio_co_schedule(iohandler_get_aio_context(), qmp_dispatcher_co);
>  }
>  
> -int monitor_init(MonitorOptions *opts, bool allow_hmp, Error **errp)
> +int monitor_new(MonitorOptions *opts, bool allow_hmp, Error **errp)
>  {
>      ERRP_GUARD();
>      Chardev *chr;
> @@ -732,7 +732,7 @@ int monitor_init(MonitorOptions *opts, bool allow_hmp, Error **errp)
>  
>      switch (opts->mode) {
>      case MONITOR_MODE_CONTROL:
> -        monitor_init_qmp(chr, opts->pretty, errp);
> +        monitor_new_qmp(chr, opts->pretty, errp);
>          break;
>      case MONITOR_MODE_READLINE:
>          if (!allow_hmp) {
> @@ -743,7 +743,7 @@ int monitor_init(MonitorOptions *opts, bool allow_hmp, Error **errp)
>              error_setg(errp, "'pretty' is not compatible with HMP monitors");
>              return -1;
>          }
> -        monitor_init_hmp(chr, true, errp);
> +        monitor_new_hmp(chr, true, errp);
>          break;
>      default:
>          g_assert_not_reached();
> @@ -752,7 +752,7 @@ int monitor_init(MonitorOptions *opts, bool allow_hmp, Error **errp)
>      return *errp ? -1 : 0;
>  }
>  
> -int monitor_init_opts(QemuOpts *opts, Error **errp)
> +int monitor_new_opts(QemuOpts *opts, Error **errp)
>  {
>      Visitor *v;
>      MonitorOptions *options;
> @@ -765,7 +765,7 @@ int monitor_init_opts(QemuOpts *opts, Error **errp)
>          return -1;
>      }
>  
> -    ret = monitor_init(options, true, errp);
> +    ret = monitor_new(options, true, errp);
>      qapi_free_MonitorOptions(options);
>      return ret;
>  }
> diff --git a/monitor/qmp.c b/monitor/qmp.c
> index 69d9e40e32..9caee70624 100644
> --- a/monitor/qmp.c
> +++ b/monitor/qmp.c
> @@ -513,7 +513,7 @@ static void monitor_qmp_setup_handlers_bh(void *opaque)
>      monitor_list_append(&mon->parent);
>  }
>  
> -void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp)
> +void monitor_new_qmp(Chardev *chr, bool pretty, Error **errp)
>  {
>      MonitorQMP *mon = g_new0(MonitorQMP, 1);
>  
> diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-storage-daemon.c
> index eb72561358..50dbfbd97a 100644
> --- a/storage-daemon/qemu-storage-daemon.c
> +++ b/storage-daemon/qemu-storage-daemon.c
> @@ -330,7 +330,7 @@ static void process_options(int argc, char *argv[], bool pre_init_pass)
>                  visit_free(v);
>  
>                  /* TODO Catch duplicate monitor IDs */
> -                monitor_init(monitor, false, &error_fatal);
> +                monitor_new(monitor, false, &error_fatal);
>                  qapi_free_MonitorOptions(monitor);
>                  break;
>              }
> diff --git a/stubs/monitor-internal.c b/stubs/monitor-internal.c
> index 4fece49d53..23d58da184 100644
> --- a/stubs/monitor-internal.c
> +++ b/stubs/monitor-internal.c
> @@ -8,6 +8,6 @@ int monitor_get_fd(Monitor *mon, const char *name, Error **errp)
>      return -1;
>  }
>  
> -void monitor_init_hmp(Chardev *chr, bool use_readline, Error **errp)
> +void monitor_new_hmp(Chardev *chr, bool use_readline, Error **errp)
>  {
>  }
> diff --git a/system/vl.c b/system/vl.c
> index 246623b319..2391811a46 100644
> --- a/system/vl.c
> +++ b/system/vl.c
> @@ -1244,7 +1244,7 @@ static int fsdev_init_func(void *opaque, QemuOpts *opts, Error **errp)
>  
>  static int mon_init_func(void *opaque, QemuOpts *opts, Error **errp)
>  {
> -    return monitor_init_opts(opts, errp);
> +    return monitor_new_opts(opts, errp);
>  }
>  
>  static void monitor_parse(const char *str, const char *mode, bool pretty)
> -- 
> 2.53.0
> 
-- 
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\        dave @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/