Patchwork [RFC,35/48] monitor: New in_qmp_mon()

login
register
mail settings
Submitter Markus Armbruster
Date Feb. 24, 2010, 5:55 p.m.
Message ID <1267034160-3517-36-git-send-email-armbru@redhat.com>
Download mbox | patch
Permalink /patch/46165/
State New
Headers show

Comments

Markus Armbruster - Feb. 24, 2010, 5:55 p.m.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 monitor.c |    5 +++++
 monitor.h |    2 ++
 2 files changed, 7 insertions(+), 0 deletions(-)
Luiz Capitulino - Feb. 26, 2010, 7:46 p.m.
On Wed, 24 Feb 2010 18:55:47 +0100
Markus Armbruster <armbru@redhat.com> wrote:

> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  monitor.c |    5 +++++
>  monitor.h |    2 ++
>  2 files changed, 7 insertions(+), 0 deletions(-)
> 
> diff --git a/monitor.c b/monitor.c
> index a4263af..5c87a98 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -194,6 +194,11 @@ static inline int monitor_ctrl_mode(const Monitor *mon)
>      return (mon->flags & MONITOR_USE_CONTROL);
>  }
>  
> +int in_qmp_mon(void)
> +{
> +    return cur_mon && monitor_ctrl_mode(cur_mon);
> +}
> +

 Afaik, all public monitor functions begin with 'monitor_'. While it's
debatable if it's a good name, let's keep the consistency.

 Also, I'm going to rename monitor_ctrl_mode() to something like
monitor_qmp_mode() or monitor_is_qmp(). In this case the difference with
in_qmp_mon() is not clear.
Markus Armbruster - March 1, 2010, 9:19 a.m.
Luiz Capitulino <lcapitulino@redhat.com> writes:

> On Wed, 24 Feb 2010 18:55:47 +0100
> Markus Armbruster <armbru@redhat.com> wrote:
>
>> 
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>>  monitor.c |    5 +++++
>>  monitor.h |    2 ++
>>  2 files changed, 7 insertions(+), 0 deletions(-)
>> 
>> diff --git a/monitor.c b/monitor.c
>> index a4263af..5c87a98 100644
>> --- a/monitor.c
>> +++ b/monitor.c
>> @@ -194,6 +194,11 @@ static inline int monitor_ctrl_mode(const Monitor *mon)
>>      return (mon->flags & MONITOR_USE_CONTROL);
>>  }
>>  
>> +int in_qmp_mon(void)
>> +{
>> +    return cur_mon && monitor_ctrl_mode(cur_mon);
>> +}
>> +
>
>  Afaik, all public monitor functions begin with 'monitor_'. While it's
> debatable if it's a good name, let's keep the consistency.
>
>  Also, I'm going to rename monitor_ctrl_mode() to something like
> monitor_qmp_mode() or monitor_is_qmp(). In this case the difference with
> in_qmp_mon() is not clear.

Care to suggest a name?
Luiz Capitulino - March 1, 2010, 4:18 p.m.
On Mon, 01 Mar 2010 10:19:49 +0100
Markus Armbruster <armbru@redhat.com> wrote:

> Luiz Capitulino <lcapitulino@redhat.com> writes:
> 
> > On Wed, 24 Feb 2010 18:55:47 +0100
> > Markus Armbruster <armbru@redhat.com> wrote:
> >
> >> 
> >> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> >> ---
> >>  monitor.c |    5 +++++
> >>  monitor.h |    2 ++
> >>  2 files changed, 7 insertions(+), 0 deletions(-)
> >> 
> >> diff --git a/monitor.c b/monitor.c
> >> index a4263af..5c87a98 100644
> >> --- a/monitor.c
> >> +++ b/monitor.c
> >> @@ -194,6 +194,11 @@ static inline int monitor_ctrl_mode(const Monitor *mon)
> >>      return (mon->flags & MONITOR_USE_CONTROL);
> >>  }
> >>  
> >> +int in_qmp_mon(void)
> >> +{
> >> +    return cur_mon && monitor_ctrl_mode(cur_mon);
> >> +}
> >> +
> >
> >  Afaik, all public monitor functions begin with 'monitor_'. While it's
> > debatable if it's a good name, let's keep the consistency.
> >
> >  Also, I'm going to rename monitor_ctrl_mode() to something like
> > monitor_qmp_mode() or monitor_is_qmp(). In this case the difference with
> > in_qmp_mon() is not clear.
> 
> Care to suggest a name?

 Maybe, monitor_ctrl_mode() should be monitor_is_qmp() and the new one
monitor_cur_is_qmp()?

 Or should we start exporting monitor names as 'mon_' to make them short?
Markus Armbruster - March 2, 2010, 8:53 a.m.
Luiz Capitulino <lcapitulino@redhat.com> writes:

> On Mon, 01 Mar 2010 10:19:49 +0100
> Markus Armbruster <armbru@redhat.com> wrote:
>
>> Luiz Capitulino <lcapitulino@redhat.com> writes:
>> 
>> > On Wed, 24 Feb 2010 18:55:47 +0100
>> > Markus Armbruster <armbru@redhat.com> wrote:
>> >
>> >> 
>> >> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> >> ---
>> >>  monitor.c |    5 +++++
>> >>  monitor.h |    2 ++
>> >>  2 files changed, 7 insertions(+), 0 deletions(-)
>> >> 
>> >> diff --git a/monitor.c b/monitor.c
>> >> index a4263af..5c87a98 100644
>> >> --- a/monitor.c
>> >> +++ b/monitor.c
>> >> @@ -194,6 +194,11 @@ static inline int monitor_ctrl_mode(const Monitor *mon)
>> >>      return (mon->flags & MONITOR_USE_CONTROL);
>> >>  }
>> >>  
>> >> +int in_qmp_mon(void)
>> >> +{
>> >> +    return cur_mon && monitor_ctrl_mode(cur_mon);
>> >> +}
>> >> +
>> >
>> >  Afaik, all public monitor functions begin with 'monitor_'. While it's
>> > debatable if it's a good name, let's keep the consistency.
>> >
>> >  Also, I'm going to rename monitor_ctrl_mode() to something like
>> > monitor_qmp_mode() or monitor_is_qmp(). In this case the difference with
>> > in_qmp_mon() is not clear.
>> 
>> Care to suggest a name?
>
>  Maybe, monitor_ctrl_mode() should be monitor_is_qmp() and the new one
> monitor_cur_is_qmp()?

Works for me.

>  Or should we start exporting monitor names as 'mon_' to make them short?

Fine with me, but not in my patch series, it's plenty long already :)

Patch

diff --git a/monitor.c b/monitor.c
index a4263af..5c87a98 100644
--- a/monitor.c
+++ b/monitor.c
@@ -194,6 +194,11 @@  static inline int monitor_ctrl_mode(const Monitor *mon)
     return (mon->flags & MONITOR_USE_CONTROL);
 }
 
+int in_qmp_mon(void)
+{
+    return cur_mon && monitor_ctrl_mode(cur_mon);
+}
+
 static void monitor_read_command(Monitor *mon, int show_prompt)
 {
     if (!mon->rs)
diff --git a/monitor.h b/monitor.h
index 1222ff0..9fc9639 100644
--- a/monitor.h
+++ b/monitor.h
@@ -30,6 +30,8 @@  typedef enum MonitorEvent {
     QEVENT_MAX,
 } MonitorEvent;
 
+int in_qmp_mon(void);
+
 void monitor_protocol_event(MonitorEvent event, QObject *data);
 void monitor_init(CharDriverState *chr, int flags);