Skip to contentSkip to conversation

spice: Disallow use of gl + TCP port

PATCH In review Christophe Fergeau 4 participants 12 messages Mar 14, 2016 – Mar 18, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spice: Disallow use of gl + TCP port

Currently, virgl support has to go through a local unix socket, trying to connect to a VM using -spice gl through spice://localhost:5900 will only result in a black screen.
This commit errors out when the user tries to start a VM with both GL support and a port/tls-port set.
This would fit better in spice-server, but currently QEMU does not call into spice-server when parsing 'gl' on its command line, so we have to do this check in QEMU instead.

---
 ui/spice-core.c | 4 ++++
 1 file changed, 4 insertions(+)
ui/spice-core.c +4 -0
index 7987a4e..94f3236 100644
@@ -844,6 +844,10 @@ void qemu_spice_init(void)
 
 #ifdef HAVE_SPICE_GL
     if (qemu_opt_get_bool(opts, "gl", 0)) {
+        if ((port != 0) || (tls_port != 0)) {
+            error_report("SPICE GL support is local-only for now and incompatible with -spice port/tls-port");
+            exit(1);
+        }
         if (egl_rendernode_init() == 0) {
             display_opengl = 1;
         }
Signature · 1 line
2.5.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Christophe Fergeau

Currently, virgl support has to go through a local unix socket, trying to connect to a VM using -spice gl through spice://localhost:5900 will only result in a black screen.
This commit errors out when the user tries to start a VM with both GL support and a port/tls-port set.
This would fit better in spice-server, but currently QEMU does not call into spice-server when parsing 'gl' on its command line, so we have to do this check in QEMU instead.

Quoted 22 lines
---
 ui/spice-core.c | 4 ++++
 1 file changed, 4 insertions(+)
ui/spice-core.c +4 -1
index 7987a4e..94f3236 100644
@@ -844,6 +844,10 @@ void qemu_spice_init(void)
 
 #ifdef HAVE_SPICE_GL
     if (qemu_opt_get_bool(opts, "gl", 0)) {
+        if ((port != 0) || (tls_port != 0)) {
+            error_report("SPICE GL support is local-only for now and incompatible with -spice port/tls-port");
+            exit(1);
+        }
         if (egl_rendernode_init() == 0) {
             display_opengl = 1;
         }
--

2.5.0

Signature · 1 line
Marc-André Lureau
#2 lore raw
In reply to Christophe Fergeau
Quoted 8 lines · Christophe Fergeau

Currently, virgl support has to go through a local unix socket, trying to connect to a VM using -spice gl through spice://localhost:5900 will only result in a black screen.
This commit errors out when the user tries to start a VM with both GL support and a port/tls-port set.
This would fit better in spice-server, but currently QEMU does not call into spice-server when parsing 'gl' on its command line, so we have to do this check in QEMU instead.

Hmm. It's something which we want support long-term though, by encoding those dma-bufs as video stream and send them off over tcp.

I don't think this is a good idea long-term.

And even as temporary stopgap: Can libvirt + virt-manager handle this?

cheers,
Gerd

#3 lore raw

Hi,

Quoted 10 lines · Gerd Hoffmann
Quoted 8 lines · Christophe Fergeau

Currently, virgl support has to go through a local unix socket, trying to connect to a VM using -spice gl through spice://localhost:5900 will only result in a black screen.
This commit errors out when the user tries to start a VM with both GL support and a port/tls-port set.
This would fit better in spice-server, but currently QEMU does not call into spice-server when parsing 'gl' on its command line, so we have to do this check in QEMU instead.

Quoted 4 lines

Hmm. It's something which we want support long-term though, by encoding those dma-bufs as video stream and send them off over tcp.

I don't think this is a good idea long-term.

Yes, long-term we will want to remove this once spice gets support for this. Currently however, this imo makes it a bit easier to understand how everything is setup.
Otherwise I expect people are going to just take their existing SPICE libvirt configuration listening on the network, add <gl enable="yes"/> to it, try remote-viewer spice://localhost:5900 and wonder why they get a black screen, and not know whether this is because their guest does not support virgl, or their host, or because of some other issue, ...

Having this as a stopgap ensures that they at least be informed this is not a valid usecase.

Quoted 1 line

And even as temporary stopgap: Can libvirt + virt-manager handle this?

libvirt can, I haven't tried virt-manager (I believe all the patches from Marc-André haven't been pushed yet)
<spice autoport="no"/> starts QEMU with -spice port=0

Christophe

#4 lore raw

Hi,

Quoted 2 lines

Yes, long-term we will want to remove this once spice gets support for this.

How can qemu figure whenever spice supports gl+tcp or not?

cheers,
Gerd

#5 lore raw
Quoted 6 lines · Gerd Hoffmann

Hi,

Quoted 2 lines

Yes, long-term we will want to remove this once spice gets support for this.

How can qemu figure whenever spice supports gl+tcp or not?

gl support is already enabled through a spice-server version check

#if defined(CONFIG_OPENGL_DMABUF)

# if SPICE_SERVER_VERSION >= 0x000d01 /* release 0.13.1 */
#  define HAVE_SPICE_GL 1
#  include "ui/egl-helpers.h"
#  include "ui/egl-context.h"
# endif
#endif

We can do something similar once gl+tcp is available.

Christophe

#6 lore raw
Quoted 10 lines · Christophe Fergeau
Quoted 6 lines · Gerd Hoffmann

Hi,

Quoted 2 lines

Yes, long-term we will want to remove this once spice gets support for this.

How can qemu figure whenever spice supports gl+tcp or not?

gl support is already enabled through a spice-server version check

Quoted 7 lines

#if defined(CONFIG_OPENGL_DMABUF)

# if SPICE_SERVER_VERSION >= 0x000d01 /* release 0.13.1 */
#  define HAVE_SPICE_GL 1
#  include "ui/egl-helpers.h"
#  include "ui/egl-context.h"
# endif
#endif

Sure, qemu needed to figure whenever spice-server provides the gl API.

Quoted 1 line

We can do something similar once gl+tcp is available.

I don't expect adding gl+tcp support to spice needs changes in the spice-server API and qemu. So ifdef'ing on the spice-server version is bogous, especially as the version you compiled qemu against can be newer or older as the version used to run qemu.

cheers,
Gerd

#7 lore raw
Quoted 5 lines · Gerd Hoffmann
Quoted 1 line

We can do something similar once gl+tcp is available.

I don't expect adding gl+tcp support to spice needs changes in the spice-server API and qemu. So ifdef'ing on the spice-server version is bogous,

Hmm, I expected some changes, at least wrt options if the user needs to tweak the format of the video stream, hence the suggestion :) Things get trickier then. Adding a runtime spice_get_version() would not be that great either as the check would have to be updated with each spice-server release.

I'd still like to have some failure when people try such configurations, gathering all the pieces is complicated enough, better to let people know when they try doing something that won't work.

Christophe

#8 lore raw
In reply to Christophe Fergeau
Quoted 19 lines · Christophe Fergeau

Currently, virgl support has to go through a local unix socket, trying to connect to a VM using -spice gl through spice://localhost:5900 will only result in a black screen.
This commit errors out when the user tries to start a VM with both GL support and a port/tls-port set.
This would fit better in spice-server, but currently QEMU does not call into spice-server when parsing 'gl' on its command line, so we have to do this check in QEMU instead.

---
 ui/spice-core.c | 4 ++++
 1 file changed, 4 insertions(+)
ui/spice-core.c +0 -0
index 7987a4e..94f3236 100644

ui/spice-core.c void qemu_spice_init(void) · line 847

Quoted 4 lines
ui/spice-core.c +1 -0
@@ -844,6 +844,10 @@ void qemu_spice_init(void)
 
 #ifdef HAVE_SPICE_GL
     if (qemu_opt_get_bool(opts, "gl", 0)) {
+        if ((port != 0) || (tls_port != 0)) {

Overparenthesized; you could write:

if (port || tls_port) {

for the same effect with less typing.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#9 lore raw
Quoted 27 lines · Eric Blake
Quoted 19 lines · Christophe Fergeau

Currently, virgl support has to go through a local unix socket, trying to connect to a VM using -spice gl through spice://localhost:5900 will only result in a black screen.
This commit errors out when the user tries to start a VM with both GL support and a port/tls-port set.
This would fit better in spice-server, but currently QEMU does not call into spice-server when parsing 'gl' on its command line, so we have to do this check in QEMU instead.

---
 ui/spice-core.c | 4 ++++
 1 file changed, 4 insertions(+)
ui/spice-core.c +0 -0
index 7987a4e..94f3236 100644

ui/spice-core.c void qemu_spice_init(void) · line 847

Quoted 4 lines
ui/spice-core.c +1 -0
@@ -844,6 +844,10 @@ void qemu_spice_init(void)
 
 #ifdef HAVE_SPICE_GL
     if (qemu_opt_get_bool(opts, "gl", 0)) {
+        if ((port != 0) || (tls_port != 0)) {

Overparenthesized; you could write:

Quoted 3 lines

if (port || tls_port) {

for the same effect with less typing.

Yeah I know I'm overly verbose with these tests, the parentheses make it explicit that there are no operator priority issues, the != 0 emphasize it's an integer type which is being handled.

I'll change it to your recommendation before sending a v2.

Christophe

#10 lore raw
In reply to Christophe Fergeau
Quoted 10 lines · Christophe Fergeau

Currently, virgl support has to go through a local unix socket, trying to connect to a VM using -spice gl through spice://localhost:5900 will only result in a black screen.
This commit errors out when the user tries to start a VM with both GL support and a port/tls-port set.
This would fit better in spice-server, but currently QEMU does not call into spice-server when parsing 'gl' on its command line, so we have to do this check in QEMU instead.

Picked up for ui patch queue.

thanks,
Gerd

#11 lore raw
Quoted 10 lines · Gerd Hoffmann
Quoted 9 lines · Christophe Fergeau

Currently, virgl support has to go through a local unix socket, trying to connect to a VM using -spice gl through spice://localhost:5900 will only result in a black screen.
This commit errors out when the user tries to start a VM with both GL support and a port/tls-port set.
This would fit better in spice-server, but currently QEMU does not call into spice-server when parsing 'gl' on its command line, so we have to do this check in QEMU instead.

Quoted 3 lines
Quoted 1 line

Picked up for ui patch queue.

Great thanks!

Fwiw, I've changed it locally to address Eric's comments, but did not send it as v2 since a discussion was ongoing, here is what it looks in my local clone now (but I'm fine with either version):

commit c0e10fb17a45a9da14d068a58af3a00e78f82403

Author: Christophe Fergeau <[email protected]>
Date:   Mon Mar 14 12:37:50 2016 +0100

spice: Disallow use of gl + TCP port

Currently, virgl support has to go through a local unix socket, trying to connect to a VM using -spice gl through spice://localhost:5900 will only result in a black screen.
This commit errors out when the user tries to start a VM with both GL support and a port/tls-port set.
This would fit better in spice-server, but currently QEMU does not call into spice-server when parsing 'gl' on its command line, so we have to do this check in QEMU instead.

ui/spice-core.c +4 -0
index 7987a4e..83950fe 100644
@@ -844,6 +844,10 @@ void qemu_spice_init(void)
 
 #ifdef HAVE_SPICE_GL
     if (qemu_opt_get_bool(opts, "gl", 0)) {
+        if (port || tls_port) {
+            error_report("SPICE GL support is local-only for now and incompatible with -spice port/tls-port");
+            exit(1);
+        }
         if (egl_rendernode_init() == 0) {
             display_opengl = 1;
         }

Christophe