All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] hmp: info spice: Show string channel name
@ 2015-02-26 19:02 Cole Robinson
  2015-02-26 20:48 ` Eric Blake
  0 siblings, 1 reply; 4+ messages in thread
From: Cole Robinson @ 2015-02-26 19:02 UTC (permalink / raw)
  To: qemu-devel
  Cc: Cole Robinson, Gerd Hoffmann, Markus Armbruster, Luiz Capitulino

Useful for debugging.

https://bugzilla.redhat.com/show_bug.cgi?id=822418
Signed-off-by: Cole Robinson <crobinso@redhat.com>
---
 hmp.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/hmp.c b/hmp.c
index 735097c..93fd5cd 100644
--- a/hmp.c
+++ b/hmp.c
@@ -545,6 +545,11 @@ void hmp_info_spice(Monitor *mon, const QDict *qdict)
 {
     SpiceChannelList *chan;
     SpiceInfo *info;
+    const char *channel_name;
+    /* String representations of SPICE_CHANNEL_* enum */
+    const char * const channel_names[] = {"main", "display", "input", "cursor",
+        "playback", "record", "tunnel", "smartcard", "usbredir", "port",
+        "webdav"};
 
     info = qmp_query_spice(NULL);
 
@@ -581,6 +586,14 @@ void hmp_info_spice(Monitor *mon, const QDict *qdict)
                            chan->value->connection_id);
             monitor_printf(mon, "     channel: %" PRId64 ":%" PRId64 "\n",
                            chan->value->channel_type, chan->value->channel_id);
+
+            channel_name = "unknown";
+            if (chan->value->channel_type > 0 &&
+                chan->value->channel_type <= sizeof(channel_names)) {
+                channel_name = channel_names[chan->value->channel_type - 1];
+            }
+
+            monitor_printf(mon, "     channel name: %s\n", channel_name);
         }
     }
 
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] hmp: info spice: Show string channel name
  2015-02-26 19:02 [Qemu-devel] [PATCH] hmp: info spice: Show string channel name Cole Robinson
@ 2015-02-26 20:48 ` Eric Blake
  2015-02-27  7:35   ` Gerd Hoffmann
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Blake @ 2015-02-26 20:48 UTC (permalink / raw)
  To: Cole Robinson, qemu-devel
  Cc: Luiz Capitulino, Gerd Hoffmann, Markus Armbruster

[-- Attachment #1: Type: text/plain, Size: 1072 bytes --]

On 02/26/2015 12:02 PM, Cole Robinson wrote:
> Useful for debugging.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=822418
> Signed-off-by: Cole Robinson <crobinso@redhat.com>
> ---
>  hmp.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/hmp.c b/hmp.c
> index 735097c..93fd5cd 100644
> --- a/hmp.c
> +++ b/hmp.c
> @@ -545,6 +545,11 @@ void hmp_info_spice(Monitor *mon, const QDict *qdict)
>  {
>      SpiceChannelList *chan;
>      SpiceInfo *info;
> +    const char *channel_name;
> +    /* String representations of SPICE_CHANNEL_* enum */
> +    const char * const channel_names[] = {"main", "display", "input", "cursor",
> +        "playback", "record", "tunnel", "smartcard", "usbredir", "port",
> +        "webdav"};
>  

Hmm. I wonder if we should have a QAPI enum for this, instead of
open-coding it here.  But as this is already a strict improvement,

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] hmp: info spice: Show string channel name
  2015-02-26 20:48 ` Eric Blake
@ 2015-02-27  7:35   ` Gerd Hoffmann
  2015-02-27 14:56     ` Cole Robinson
  0 siblings, 1 reply; 4+ messages in thread
From: Gerd Hoffmann @ 2015-02-27  7:35 UTC (permalink / raw)
  To: Eric Blake; +Cc: Markus Armbruster, Luiz Capitulino, qemu-devel, Cole Robinson

On Do, 2015-02-26 at 13:48 -0700, Eric Blake wrote:
> On 02/26/2015 12:02 PM, Cole Robinson wrote:
> > Useful for debugging.
> > 
> > https://bugzilla.redhat.com/show_bug.cgi?id=822418
> > Signed-off-by: Cole Robinson <crobinso@redhat.com>
> > ---
> >  hmp.c | 13 +++++++++++++
> >  1 file changed, 13 insertions(+)
> > 
> > diff --git a/hmp.c b/hmp.c
> > index 735097c..93fd5cd 100644
> > --- a/hmp.c
> > +++ b/hmp.c
> > @@ -545,6 +545,11 @@ void hmp_info_spice(Monitor *mon, const QDict *qdict)
> >  {
> >      SpiceChannelList *chan;
> >      SpiceInfo *info;
> > +    const char *channel_name;
> > +    /* String representations of SPICE_CHANNEL_* enum */
> > +    const char * const channel_names[] = {"main", "display", "input", "cursor",
> > +        "playback", "record", "tunnel", "smartcard", "usbredir", "port",
> > +        "webdav"};
> >  
> 
> Hmm. I wonder if we should have a QAPI enum for this, instead of
> open-coding it here.  But as this is already a strict improvement,

These numbers are defined by spice not qemu, so a qapi enum isn't going
to fly here.

Nevertheless it would be great to declare the array using c99 syntax ...

    [ SPICE_CHANNEL_foo ] = "foo",

... to make clear how we are mapping spice enums (or #defines?) to
strings here.

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] hmp: info spice: Show string channel name
  2015-02-27  7:35   ` Gerd Hoffmann
@ 2015-02-27 14:56     ` Cole Robinson
  0 siblings, 0 replies; 4+ messages in thread
From: Cole Robinson @ 2015-02-27 14:56 UTC (permalink / raw)
  To: Gerd Hoffmann, Eric Blake; +Cc: qemu-devel, Markus Armbruster, Luiz Capitulino

On 02/27/2015 02:35 AM, Gerd Hoffmann wrote:
> On Do, 2015-02-26 at 13:48 -0700, Eric Blake wrote:
>> On 02/26/2015 12:02 PM, Cole Robinson wrote:
>>> Useful for debugging.
>>>
>>> https://bugzilla.redhat.com/show_bug.cgi?id=822418
>>> Signed-off-by: Cole Robinson <crobinso@redhat.com>
>>> ---
>>>  hmp.c | 13 +++++++++++++
>>>  1 file changed, 13 insertions(+)
>>>
>>> diff --git a/hmp.c b/hmp.c
>>> index 735097c..93fd5cd 100644
>>> --- a/hmp.c
>>> +++ b/hmp.c
>>> @@ -545,6 +545,11 @@ void hmp_info_spice(Monitor *mon, const QDict *qdict)
>>>  {
>>>      SpiceChannelList *chan;
>>>      SpiceInfo *info;
>>> +    const char *channel_name;
>>> +    /* String representations of SPICE_CHANNEL_* enum */
>>> +    const char * const channel_names[] = {"main", "display", "input", "cursor",
>>> +        "playback", "record", "tunnel", "smartcard", "usbredir", "port",
>>> +        "webdav"};
>>>  
>>
>> Hmm. I wonder if we should have a QAPI enum for this, instead of
>> open-coding it here.  But as this is already a strict improvement,
> 
> These numbers are defined by spice not qemu, so a qapi enum isn't going
> to fly here.
> 
> Nevertheless it would be great to declare the array using c99 syntax ...
> 
>     [ SPICE_CHANNEL_foo ] = "foo",
> 
> ... to make clear how we are mapping spice enums (or #defines?) to
> strings here.
> 
> cheers,
>   Gerd
> 
> 
> 

Good idea, I'll send a v2

Thanks,
Cole

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-02-27 14:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-26 19:02 [Qemu-devel] [PATCH] hmp: info spice: Show string channel name Cole Robinson
2015-02-26 20:48 ` Eric Blake
2015-02-27  7:35   ` Gerd Hoffmann
2015-02-27 14:56     ` Cole Robinson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.