[Qemu-devel] [PATCH 1/9] monitor: simplify monitor_qmp_setup_handlers_bh

Peter Xu posted 9 patches 7 years, 4 months ago
There is a newer version of this series
[Qemu-devel] [PATCH 1/9] monitor: simplify monitor_qmp_setup_handlers_bh
Posted by Peter Xu 7 years, 4 months ago
When we reach monitor_qmp_setup_handlers_bh() we must be using the
IOThread then, so no need to check against it any more.  Instead, we
assert.

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 monitor.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/monitor.c b/monitor.c
index 14af7b7ea6..0e3ac52d87 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4583,15 +4583,10 @@ static void monitor_qmp_setup_handlers_bh(void *opaque)
     Monitor *mon = opaque;
     GMainContext *context;
 
-    if (mon->use_io_thread) {
-        /* Use @mon_iothread context */
-        context = monitor_get_io_context();
-        assert(context);
-    } else {
-        /* Use default main loop context */
-        context = NULL;
-    }
-
+    assert(mon->use_io_thread);
+    /* Use @mon_iothread context */
+    context = monitor_get_io_context();
+    assert(context);
     qemu_chr_fe_set_handlers(&mon->chr, monitor_can_read, monitor_qmp_read,
                              monitor_qmp_event, NULL, mon, context, true);
     monitor_list_append(mon);
-- 
2.17.1


Re: [Qemu-devel] [PATCH 1/9] monitor: simplify monitor_qmp_setup_handlers_bh
Posted by Markus Armbruster 7 years, 4 months ago
Peter Xu <peterx@redhat.com> writes:

> When we reach monitor_qmp_setup_handlers_bh() we must be using the
> IOThread then, so no need to check against it any more.  Instead, we
> assert.
>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>  monitor.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/monitor.c b/monitor.c
> index 14af7b7ea6..0e3ac52d87 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -4583,15 +4583,10 @@ static void monitor_qmp_setup_handlers_bh(void *opaque)
>      Monitor *mon = opaque;
>      GMainContext *context;
>  
> -    if (mon->use_io_thread) {
> -        /* Use @mon_iothread context */
> -        context = monitor_get_io_context();
> -        assert(context);
> -    } else {
> -        /* Use default main loop context */
> -        context = NULL;
> -    }
> -
> +    assert(mon->use_io_thread);
> +    /* Use @mon_iothread context */
> +    context = monitor_get_io_context();
> +    assert(context);
>      qemu_chr_fe_set_handlers(&mon->chr, monitor_can_read, monitor_qmp_read,
>                               monitor_qmp_event, NULL, mon, context, true);
>      monitor_list_append(mon);

Reviewed-by: Markus Armbruster <armbru@redhat.com>