[libvirt] [PATCH] qemu: event: Fix retrieval of the "service" field from graphics events

qemu's event has following format: { "timestamp": { "seconds": 1435580974, "microseconds": 82226 }, "event": "SPICE_INITIALIZED", "data": { "server": { "auth": "none", "port": "5900", "family": "ipv4", "host": "127.0.0.1" }, "client": { "port": "53224", "family": "ipv4", "channel-type": 3, "connection-id": 1113096064, "host": "127.0.0.1", "channel-id": 0, "tls": false } } } Our code tried to extract the "service" field but qemu reports it as "port". --- src/qemu/qemu_monitor_json.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index d3e98d4..bd73b05 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -652,7 +652,7 @@ static void qemuMonitorJSONHandleGraphics(qemuMonitorPtr mon, virJSONValuePtr da VIR_WARN("missing local hostname in graphics event"); return; } - localService = virJSONValueObjectGetString(server, "service"); + localService = virJSONValueObjectGetString(server, "port"); if (!localService) localService = ""; /* Spice has multiple ports, so this isn't provided */ @@ -666,7 +666,7 @@ static void qemuMonitorJSONHandleGraphics(qemuMonitorPtr mon, virJSONValuePtr da VIR_WARN("missing remote hostname in graphics event"); return; } - remoteService = virJSONValueObjectGetString(client, "service"); + remoteService = virJSONValueObjectGetString(client, "port"); if (!remoteService) remoteService = ""; /* Spice has multiple ports, so this isn't provided */ -- 2.4.1

On Mon, Jun 29, 2015 at 14:42:50 +0200, Peter Krempa wrote:
qemu's event has following format:
{ "timestamp": { "seconds": 1435580974, "microseconds": 82226 }, "event": "SPICE_INITIALIZED", "data": { "server": { "auth": "none", "port": "5900", "family": "ipv4", "host": "127.0.0.1" }, "client": { "port": "53224", "family": "ipv4", "channel-type": 3, "connection-id": 1113096064, "host": "127.0.0.1", "channel-id": 0, "tls": false } } }
Our code tried to extract the "service" field but qemu reports it as "port". --- src/qemu/qemu_monitor_json.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
ACK Jirka

On Mon, Jun 29, 2015 at 02:42:50PM +0200, Peter Krempa wrote:
qemu's event has following format:
{ "timestamp": { "seconds": 1435580974, "microseconds": 82226 }, "event": "SPICE_INITIALIZED", "data": { "server": { "auth": "none", "port": "5900", "family": "ipv4", "host": "127.0.0.1" }, "client": { "port": "53224", "family": "ipv4", "channel-type": 3, "connection-id": 1113096064, "host": "127.0.0.1", "channel-id": 0, "tls": false } } }
Our code tried to extract the "service" field but qemu reports it as "port".
Hmm, that's somewhat odd - did you check back historical versions of QEMU where this event was first introduced to see if it has always had this name ? It smells like the kind of thing that could have been a regression at some point Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On Mon, Jun 29, 2015 at 13:47:50 +0100, Daniel Berrange wrote:
On Mon, Jun 29, 2015 at 02:42:50PM +0200, Peter Krempa wrote:
qemu's event has following format:
{ "timestamp": { "seconds": 1435580974, "microseconds": 82226 }, "event": "SPICE_INITIALIZED", "data": { "server": { "auth": "none", "port": "5900", "family": "ipv4", "host": "127.0.0.1" }, "client": { "port": "53224", "family": "ipv4", "channel-type": 3, "connection-id": 1113096064, "host": "127.0.0.1", "channel-id": 0, "tls": false } } }
Our code tried to extract the "service" field but qemu reports it as "port".
Hmm, that's somewhat odd - did you check back historical versions of QEMU where this event was first introduced to see if it has always had this name ? It smells like the kind of thing that could have been a regression at some point
Actually the regression would be on the VNC side, since VNC uses "service" and the function that I've modified handles both. I failed to notice that fact at first. I'll post a V2 with dual handling. Peter

On Mon, Jun 29, 2015 at 03:17:50PM +0200, Peter Krempa wrote:
On Mon, Jun 29, 2015 at 13:47:50 +0100, Daniel Berrange wrote:
On Mon, Jun 29, 2015 at 02:42:50PM +0200, Peter Krempa wrote:
qemu's event has following format:
{ "timestamp": { "seconds": 1435580974, "microseconds": 82226 }, "event": "SPICE_INITIALIZED", "data": { "server": { "auth": "none", "port": "5900", "family": "ipv4", "host": "127.0.0.1" }, "client": { "port": "53224", "family": "ipv4", "channel-type": 3, "connection-id": 1113096064, "host": "127.0.0.1", "channel-id": 0, "tls": false } } }
Our code tried to extract the "service" field but qemu reports it as "port".
Hmm, that's somewhat odd - did you check back historical versions of QEMU where this event was first introduced to see if it has always had this name ? It smells like the kind of thing that could have been a regression at some point
Actually the regression would be on the VNC side, since VNC uses "service" and the function that I've modified handles both. I failed to notice that fact at first.
I'll post a V2 with dual handling.
Hmm, are you saying QEMU uses a different field name when it has VNC vs SPICE ? If so that's a bug in QEMU that needs adressing (though of course we'd have to workaround it in libvirt too now). Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On Mon, Jun 29, 2015 at 14:22:47 +0100, Daniel Berrange wrote:
On Mon, Jun 29, 2015 at 03:17:50PM +0200, Peter Krempa wrote:
On Mon, Jun 29, 2015 at 13:47:50 +0100, Daniel Berrange wrote:
On Mon, Jun 29, 2015 at 02:42:50PM +0200, Peter Krempa wrote:
qemu's event has following format:
{ "timestamp": { "seconds": 1435580974, "microseconds": 82226 }, "event": "SPICE_INITIALIZED", "data": { "server": { "auth": "none", "port": "5900", "family": "ipv4", "host": "127.0.0.1" }, "client": { "port": "53224", "family": "ipv4", "channel-type": 3, "connection-id": 1113096064, "host": "127.0.0.1", "channel-id": 0, "tls": false } } }
Our code tried to extract the "service" field but qemu reports it as "port".
Hmm, that's somewhat odd - did you check back historical versions of QEMU where this event was first introduced to see if it has always had this name ? It smells like the kind of thing that could have been a regression at some point
Actually the regression would be on the VNC side, since VNC uses "service" and the function that I've modified handles both. I failed to notice that fact at first.
I'll post a V2 with dual handling.
Hmm, are you saying QEMU uses a different field name when it has VNC vs SPICE ? If so that's a bug in QEMU that needs adressing (though of course we'd have to workaround it in libvirt too now).
Well, qemu uses different fields but they also use them in different events (VNC_CONNECTED vs SPICE_CONNECTED) with different return structures since spice provides a lot more data. The issue is that libvirt tries to use the same handler for parsing the data. I'm now conflicted whether to duplicate it or do a dual handler for both. If we will ever want to parse more data from that we will need a new function for that. Peter

On Mon, Jun 29, 2015 at 15:17:50 +0200, Peter Krempa wrote:
On Mon, Jun 29, 2015 at 13:47:50 +0100, Daniel Berrange wrote:
On Mon, Jun 29, 2015 at 02:42:50PM +0200, Peter Krempa wrote:
qemu's event has following format:
{ "timestamp": { "seconds": 1435580974, "microseconds": 82226 }, "event": "SPICE_INITIALIZED", "data": { "server": { "auth": "none", "port": "5900", "family": "ipv4", "host": "127.0.0.1" }, "client": { "port": "53224", "family": "ipv4", "channel-type": 3, "connection-id": 1113096064, "host": "127.0.0.1", "channel-id": 0, "tls": false } } }
Our code tried to extract the "service" field but qemu reports it as "port".
Hmm, that's somewhat odd - did you check back historical versions of QEMU where this event was first introduced to see if it has always had this name ? It smells like the kind of thing that could have been a regression at some point
Actually the regression would be on the VNC side, since VNC uses "service" and the function that I've modified handles both. I failed to notice that fact at first.
Heh, I was thinking "service" was an old downstream-only spelling of "port" and checked it wasn't the case. But I failed to notice the same handler is used for VNC too... Jirka

On Mon, Jun 29, 2015 at 03:35:05PM +0200, Jiri Denemark wrote:
On Mon, Jun 29, 2015 at 15:17:50 +0200, Peter Krempa wrote:
On Mon, Jun 29, 2015 at 13:47:50 +0100, Daniel Berrange wrote:
On Mon, Jun 29, 2015 at 02:42:50PM +0200, Peter Krempa wrote:
qemu's event has following format:
{ "timestamp": { "seconds": 1435580974, "microseconds": 82226 }, "event": "SPICE_INITIALIZED", "data": { "server": { "auth": "none", "port": "5900", "family": "ipv4", "host": "127.0.0.1" }, "client": { "port": "53224", "family": "ipv4", "channel-type": 3, "connection-id": 1113096064, "host": "127.0.0.1", "channel-id": 0, "tls": false } } }
Our code tried to extract the "service" field but qemu reports it as "port".
Hmm, that's somewhat odd - did you check back historical versions of QEMU where this event was first introduced to see if it has always had this name ? It smells like the kind of thing that could have been a regression at some point
Actually the regression would be on the VNC side, since VNC uses "service" and the function that I've modified handles both. I failed to notice that fact at first.
Heh, I was thinking "service" was an old downstream-only spelling of "port" and checked it wasn't the case. But I failed to notice the same handler is used for VNC too...
I've confirmed all the way back to 0.14.0 QEMU VNC and SPICE have used different names service vs port respectively. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
participants (3)
-
Daniel P. Berrange
-
Jiri Denemark
-
Peter Krempa