hmp: info spice: Show string channel name
PATCH 1/1 hmp: info spice: Show string channel name
Useful for debugging.
https://bugzilla.redhat.com/show_bug.cgi?id=822418
--- hmp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
hmp.c +13 -0
@@ -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); } }
Signature · 1 line
2.1.0
Quoted 13 lines · Cole Robinson
Useful for debugging.
https://bugzilla.redhat.com/show_bug.cgi?id=822418
Signed-off-by Cole Robinson <[email protected]>--- hmp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)hmp.c +0
-0
hmp.c void hmp_info_spice(Monitor *mon, const QDict *qdict) · line 553
Quoted 9 lines
hmp.c +5
-0@@ -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,
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 18 lines · Eric Blake
Quoted 17 lines · Cole Robinson
Useful for debugging.
https://bugzilla.redhat.com/show_bug.cgi?id=822418
Signed-off-by Cole Robinson <[email protected]>--- hmp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)hmp.c +1
-0@@ -545,6 +545,11 @@ void hmp_info_spice(Monitor *mon, const QDict *qdict) {SpiceChannelList *chan;SpiceInfo *info; +const char *channel_name;
Quoted 8 lines
hmp.c void hmp_info_spice(Monitor *mon, const QDict *qdict) · line 553
Quoted 5 lines
hmp.c +4
-0+/* 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
Quoted 33 lines · Gerd Hoffmann
Quoted 18 lines · Eric Blake
Quoted 17 lines · Cole Robinson
Useful for debugging.
https://bugzilla.redhat.com/show_bug.cgi?id=822418
Signed-off-by Cole Robinson <[email protected]>--- hmp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)hmp.c +1
-0@@ -545,6 +545,11 @@ void hmp_info_spice(Monitor *mon, const QDict *qdict) {SpiceChannelList *chan;SpiceInfo *info; +const char *channel_name;Quoted 8 lines
hmp.c void hmp_info_spice(Monitor *mon, const QDict *qdict) · line 553
Quoted 5 lines
hmp.c +4
-0+/* 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 ...
Quoted 10 lines
[ 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