All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 00/12] spice: add -display spice-app, setup and launch a Spice client
@ 2018-12-20 14:15 Marc-André Lureau
  2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 01/12] configure: bump spice-server required version to 0.12.5 Marc-André Lureau
                   ` (13 more replies)
  0 siblings, 14 replies; 19+ messages in thread
From: Marc-André Lureau @ 2018-12-20 14:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, kraxel

Hi,

The QEMU GTK UI is quite featurful. Yet, it doesn't provide many of
the functionalities one can expect from a VM desktop application (USB
redirection, shared folders, drag and drop, better multimonitor
support etc.).

Spice is able to export many of the VM controls to a client, including
QMP monitor, serial ports etc... It's thus possible for a Spice client
to provide a similar experience as the QEMU GTK UI (while keeping
similar display performances locally) and more.

This series provides "-display spice-app" to setup a Spice server and
launch a client (associated with the spice+unix:// URI). With
virt-viewer series "Add QEMU-like UI: VT console & basic VM state"
(under review), the resulting user experience is close to what qemu
GTK UI provides.

v2:
- renamed -display app -> -display spice-app
- error if full-screen or window-close is provided (supports can be
  added later)
- use a stable URI when -name is provided
- print the URI at start
- added "qapi: document DisplayType enum"
- added "spice: use a default name for the server"
- commit message tweaks
- include previously reviewed "configure: bump spice-server required
  version to 0.12.5", to avoid conflicts
- rebased

Marc-André Lureau (12):
  configure: bump spice-server required version to 0.12.5
  char/spice: trigger HUP event
  char/spice: discard write() if backend is disconnected
  spice: avoid spice runtime assert
  spice: merge options lists
  spice: do not stop spice if VM is paused
  char: move SpiceChardev and open_spice_port() to spice.h header
  char: register spice ports after spice started
  build-sys: add gio-2.0 check
  qapi: document DisplayType enum
  spice: use a default name for the server
  display: add -display spice-app launching a Spice client

 qapi/ui.json            |  31 ++++++-
 include/chardev/spice.h |  27 ++++++
 include/ui/qemu-spice.h |   6 --
 chardev/spice.c         |  70 +++++++-------
 hw/display/qxl.c        |   2 -
 ui/spice-app.c          | 200 ++++++++++++++++++++++++++++++++++++++++
 ui/spice-core.c         |  21 +++--
 chardev/trace-events    |   1 +
 configure               |  17 +++-
 qemu-options.hx         |   5 +
 ui/Makefile.objs        |   5 +
 11 files changed, 330 insertions(+), 55 deletions(-)
 create mode 100644 include/chardev/spice.h
 create mode 100644 ui/spice-app.c

-- 
2.20.1.2.gb21ebb671b

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

* [Qemu-devel] [PATCH v2 01/12] configure: bump spice-server required version to 0.12.5
  2018-12-20 14:15 [Qemu-devel] [PATCH v2 00/12] spice: add -display spice-app, setup and launch a Spice client Marc-André Lureau
@ 2018-12-20 14:15 ` Marc-André Lureau
  2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 02/12] char/spice: trigger HUP event Marc-André Lureau
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Marc-André Lureau @ 2018-12-20 14:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, kraxel

Looking at chardev/spice.c code, I realize compilation was broken for
a while with spice-server < 0.12.3. Let's bump required version
to 0.12.5, released May 19 2014, instead of adding more #ifdef.

(this patch combines changes from an early version and some of
Frediano "[PATCH 2/2] spice: Bump required spice-server version to
0.12.6")

According to repology, all the distros that are build target platforms
for QEMU include it:

      RHEL-7: 0.14.0
      Debian (Stretch): 0.12.8
      Debian (Jessie): 0.12.5
      FreeBSD (ports): 0.14.0
      OpenSUSE Leap 15: 0.14.0
      Ubuntu (Xenial): 0.12.6

Note that a previous version of this patch was bumping version to
0.12.6. Unfortunately, Debian Jessie (oldstable) is stuck with spice
server 0.12.5, and QEMU should keep building until after 2y of current
stable (Stretch), which will be around June 17th 2019. Qemu 4.1
should thus be free of bumping to spice-server 0.12.6 during 4.1
development cycle.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
---
 include/ui/qemu-spice.h |  6 ------
 chardev/spice.c         | 10 ----------
 hw/display/qxl.c        |  2 --
 ui/spice-core.c         |  8 --------
 configure               |  4 ++--
 5 files changed, 2 insertions(+), 28 deletions(-)

diff --git a/include/ui/qemu-spice.h b/include/ui/qemu-spice.h
index c6d50eb87a..8c23dfe717 100644
--- a/include/ui/qemu-spice.h
+++ b/include/ui/qemu-spice.h
@@ -46,13 +46,7 @@ int qemu_spice_migrate_info(const char *hostname, int port, int tls_port,
 #else
 #define SPICE_NEEDS_SET_MM_TIME 0
 #endif
-
-#if SPICE_SERVER_VERSION >= 0x000c02
 void qemu_spice_register_ports(void);
-#else
-static inline Chardev *qemu_chr_open_spice_port(const char *name)
-{ return NULL; }
-#endif
 
 #else  /* CONFIG_SPICE */
 
diff --git a/chardev/spice.c b/chardev/spice.c
index e66e3ad568..173c257949 100644
--- a/chardev/spice.c
+++ b/chardev/spice.c
@@ -77,7 +77,6 @@ static int vmc_read(SpiceCharDeviceInstance *sin, uint8_t *buf, int len)
     return bytes;
 }
 
-#if SPICE_SERVER_VERSION >= 0x000c02
 static void vmc_event(SpiceCharDeviceInstance *sin, uint8_t event)
 {
     SpiceChardev *scd = container_of(sin, SpiceChardev, sin);
@@ -95,7 +94,6 @@ static void vmc_event(SpiceCharDeviceInstance *sin, uint8_t event)
     trace_spice_vmc_event(chr_event);
     qemu_chr_be_event(chr, chr_event);
 }
-#endif
 
 static void vmc_state(SpiceCharDeviceInstance *sin, int connected)
 {
@@ -119,9 +117,7 @@ static SpiceCharDeviceInterface vmc_interface = {
     .state              = vmc_state,
     .write              = vmc_write,
     .read               = vmc_read,
-#if SPICE_SERVER_VERSION >= 0x000c02
     .event              = vmc_event,
-#endif
 #if SPICE_SERVER_VERSION >= 0x000c06
     .flags              = SPICE_CHAR_DEVICE_NOTIFY_WRITABLE,
 #endif
@@ -223,9 +219,7 @@ static void char_spice_finalize(Object *obj)
     }
 
     g_free((char *)s->sin.subtype);
-#if SPICE_SERVER_VERSION >= 0x000c02
     g_free((char *)s->sin.portname);
-#endif
 }
 
 static void spice_vmc_set_fe_open(struct Chardev *chr, int fe_open)
@@ -240,7 +234,6 @@ static void spice_vmc_set_fe_open(struct Chardev *chr, int fe_open)
 
 static void spice_port_set_fe_open(struct Chardev *chr, int fe_open)
 {
-#if SPICE_SERVER_VERSION >= 0x000c02
     SpiceChardev *s = SPICE_CHARDEV(chr);
 
     if (fe_open) {
@@ -248,7 +241,6 @@ static void spice_port_set_fe_open(struct Chardev *chr, int fe_open)
     } else {
         spice_server_port_event(&s->sin, SPICE_PORT_EVENT_CLOSED);
     }
-#endif
 }
 
 static void spice_chr_accept_input(struct Chardev *chr)
@@ -298,7 +290,6 @@ static void qemu_chr_open_spice_vmc(Chardev *chr,
     chr_open(chr, type);
 }
 
-#if SPICE_SERVER_VERSION >= 0x000c02
 static void qemu_chr_open_spice_port(Chardev *chr,
                                      ChardevBackend *backend,
                                      bool *be_opened,
@@ -331,7 +322,6 @@ void qemu_spice_register_ports(void)
         vmc_register_interface(s);
     }
 }
-#endif
 
 static void qemu_chr_parse_spice_vmc(QemuOpts *opts, ChardevBackend *backend,
                                      Error **errp)
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index 9087db5dee..8e9a65e75b 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -1189,9 +1189,7 @@ static void qxl_enter_vga_mode(PCIQXLDevice *d)
         return;
     }
     trace_qxl_enter_vga_mode(d->id);
-#if SPICE_SERVER_VERSION >= 0x000c03 /* release 0.12.3 */
     spice_qxl_driver_unload(&d->ssd.qxl);
-#endif
     graphic_console_set_hwops(d->ssd.dcl.con, d->vga.hw_ops, &d->vga);
     update_displaychangelistener(&d->ssd.dcl, GUI_REFRESH_INTERVAL_DEFAULT);
     qemu_spice_create_host_primary(&d->ssd);
diff --git a/ui/spice-core.c b/ui/spice-core.c
index ebaae24643..fc850b3f50 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -745,13 +745,7 @@ void qemu_spice_init(void)
     }
 
     if (qemu_opt_get_bool(opts, "disable-agent-file-xfer", 0)) {
-#if SPICE_SERVER_VERSION >= 0x000c04
         spice_server_set_agent_file_xfer(spice_server, false);
-#else
-        error_report("this qemu build does not support the "
-                     "\"disable-agent-file-xfer\" option");
-        exit(1);
-#endif
     }
 
     compression = SPICE_IMAGE_COMPRESS_AUTO_GLZ;
@@ -817,9 +811,7 @@ void qemu_spice_init(void)
     g_free(x509_cert_file);
     g_free(x509_cacert_file);
 
-#if SPICE_SERVER_VERSION >= 0x000c02
     qemu_spice_register_ports();
-#endif
 
 #ifdef HAVE_SPICE_GL
     if (qemu_opt_get_bool(opts, "gl", 0)) {
diff --git a/configure b/configure
index 224d3071ac..b0927b882a 100755
--- a/configure
+++ b/configure
@@ -4599,7 +4599,7 @@ int main(void) { spice_server_new(); return 0; }
 EOF
   spice_cflags=$($pkg_config --cflags spice-protocol spice-server 2>/dev/null)
   spice_libs=$($pkg_config --libs spice-protocol spice-server 2>/dev/null)
-  if $pkg_config --atleast-version=0.12.0 spice-server && \
+  if $pkg_config --atleast-version=0.12.5 spice-server && \
      $pkg_config --atleast-version=0.12.3 spice-protocol && \
      compile_prog "$spice_cflags" "$spice_libs" ; then
     spice="yes"
@@ -4610,7 +4610,7 @@ EOF
   else
     if test "$spice" = "yes" ; then
       feature_not_found "spice" \
-          "Install spice-server(>=0.12.0) and spice-protocol(>=0.12.3) devel"
+          "Install spice-server(>=0.12.5) and spice-protocol(>=0.12.3) devel"
     fi
     spice="no"
   fi
-- 
2.20.1.2.gb21ebb671b

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

* [Qemu-devel] [PATCH v2 02/12] char/spice: trigger HUP event
  2018-12-20 14:15 [Qemu-devel] [PATCH v2 00/12] spice: add -display spice-app, setup and launch a Spice client Marc-André Lureau
  2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 01/12] configure: bump spice-server required version to 0.12.5 Marc-André Lureau
@ 2018-12-20 14:15 ` Marc-André Lureau
  2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 03/12] char/spice: discard write() if backend is disconnected Marc-André Lureau
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Marc-André Lureau @ 2018-12-20 14:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, kraxel

Inform the front-end of disconnected state (spice client
disconnected).

This will wakeup the source handler immediately, so it can detect the
disconnection asap.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 chardev/spice.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/chardev/spice.c b/chardev/spice.c
index 173c257949..c2baeb5461 100644
--- a/chardev/spice.c
+++ b/chardev/spice.c
@@ -148,15 +148,25 @@ static void vmc_unregister_interface(SpiceChardev *scd)
 static gboolean spice_char_source_prepare(GSource *source, gint *timeout)
 {
     SpiceCharSource *src = (SpiceCharSource *)source;
+    Chardev *chr = CHARDEV(src->scd);
 
     *timeout = -1;
 
+    if (!chr->be_open) {
+        return true;
+    }
+
     return !src->scd->blocked;
 }
 
 static gboolean spice_char_source_check(GSource *source)
 {
     SpiceCharSource *src = (SpiceCharSource *)source;
+    Chardev *chr = CHARDEV(src->scd);
+
+    if (!chr->be_open) {
+        return true;
+    }
 
     return !src->scd->blocked;
 }
@@ -164,9 +174,12 @@ static gboolean spice_char_source_check(GSource *source)
 static gboolean spice_char_source_dispatch(GSource *source,
     GSourceFunc callback, gpointer user_data)
 {
+    SpiceCharSource *src = (SpiceCharSource *)source;
+    Chardev *chr = CHARDEV(src->scd);
     GIOFunc func = (GIOFunc)callback;
+    GIOCondition cond = chr->be_open ? G_IO_OUT : G_IO_HUP;
 
-    return func(NULL, G_IO_OUT, user_data);
+    return func(NULL, cond, user_data);
 }
 
 static GSourceFuncs SpiceCharSourceFuncs = {
-- 
2.20.1.2.gb21ebb671b

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

* [Qemu-devel] [PATCH v2 03/12] char/spice: discard write() if backend is disconnected
  2018-12-20 14:15 [Qemu-devel] [PATCH v2 00/12] spice: add -display spice-app, setup and launch a Spice client Marc-André Lureau
  2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 01/12] configure: bump spice-server required version to 0.12.5 Marc-André Lureau
  2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 02/12] char/spice: trigger HUP event Marc-André Lureau
@ 2018-12-20 14:15 ` Marc-André Lureau
  2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 04/12] spice: avoid spice runtime assert Marc-André Lureau
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Marc-André Lureau @ 2018-12-20 14:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, kraxel

Most chardev backend handle write() as discarded data if underlying
system is disconnected. For unknown historical reasons, the Spice
backend has "reliable" write: it will wait until the client end is
reconnected to do further successful write().

To decide whether it make sense to wait until the client is
reconnected (or queue the writes), let's review Spice chardev usage
and handling of a disconnected client:

 * spice vdagent
   The agents reopen the virtio port on disconnect. In qemu side,
   virtio_serial_close() will also discard pending data.

 * usb redirection
   A disconnect creates a device disconnection.

 * smartcard emulation
   Data is discarded in passthru_apdu_from_guest().

   (Spice doesn't explicitly open the smartcard char device until
   upcoming 0.14.2, commit 69a5cfc74131ec0459f2eb5a231139f5a69a8037)

 * spice webdavd
   The daemon will restart the service, and reopen the virtio port.

 * spice ports (serial console, qemu monitor..)
   Depends on the associated device or usage.

   - serial, may be throttled or discarded on write, depending on
     device

   - QMP/HMP monitor have some CLOSED event handling, but want to
     flush the write, which will finish when a new client connects.

On disconnect/reconnect, the client starts with fresh sessions. If it
is a seamless migration, the client disconnects after the source
migrated. The handling of source disconnect in qemu is thus irrelevant
for the Spice session migration.

For all these use cases, it is better to discard writes when the
client is disconnected, and require the vm-side device/agent to behave
correctly on CHR_EVENT_CLOSED, to stop reading and writing from
the spice chardev.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 chardev/spice.c      | 12 ++++++++++++
 chardev/trace-events |  1 +
 2 files changed, 13 insertions(+)

diff --git a/chardev/spice.c b/chardev/spice.c
index c2baeb5461..c68e60115b 100644
--- a/chardev/spice.c
+++ b/chardev/spice.c
@@ -208,6 +208,12 @@ static int spice_chr_write(Chardev *chr, const uint8_t *buf, int len)
     int read_bytes;
 
     assert(s->datalen == 0);
+
+    if (!chr->be_open) {
+        trace_spice_chr_discard_write(len);
+        return len;
+    }
+
     s->datapos = buf;
     s->datalen = len;
     spice_server_char_device_wakeup(&s->sin);
@@ -300,6 +306,12 @@ static void qemu_chr_open_spice_vmc(Chardev *chr,
     }
 
     *be_opened = false;
+#if SPICE_SERVER_VERSION < 0x000e02
+    /* Spice < 0.14.2 doesn't explicitly open smartcard chardev */
+    if (strcmp(type, "smartcard") == 0) {
+        *be_opened = true;
+    }
+#endif
     chr_open(chr, type);
 }
 
diff --git a/chardev/trace-events b/chardev/trace-events
index d0e5f3bbc1..b8a7596344 100644
--- a/chardev/trace-events
+++ b/chardev/trace-events
@@ -10,6 +10,7 @@ wct_cmd_other(const char *cmd) "%s"
 wct_speed(int speed) "%d"
 
 # chardev/spice.c
+spice_chr_discard_write(int len) "spice chr write discarded %d"
 spice_vmc_write(ssize_t out, int len) "spice wrote %zd of requested %d"
 spice_vmc_read(int bytes, int len) "spice read %d of requested %d"
 spice_vmc_register_interface(void *scd) "spice vmc registered interface %p"
-- 
2.20.1.2.gb21ebb671b

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

* [Qemu-devel] [PATCH v2 04/12] spice: avoid spice runtime assert
  2018-12-20 14:15 [Qemu-devel] [PATCH v2 00/12] spice: add -display spice-app, setup and launch a Spice client Marc-André Lureau
                   ` (2 preceding siblings ...)
  2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 03/12] char/spice: discard write() if backend is disconnected Marc-André Lureau
@ 2018-12-20 14:15 ` Marc-André Lureau
  2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 05/12] spice: merge options lists Marc-André Lureau
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Marc-André Lureau @ 2018-12-20 14:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, kraxel

The Spice server doesn't like to be started or stopped twice . It
aborts with:

(process:6191): Spice-ERROR **: 19:29:35.912: red-worker.c:623:handle_dev_start: assertion `!worker->running' failed

It's easy to avoid that situation since qemu spice_display_is_running
tracks the server state.

After the commit "spice: do not stop spice if VM is paused", it will
be possible to pause and resume the VM, and this will call
qemu_spice_display_start() twice. The easiest is to add a check for
spice_display_is_running with this patch to avoid the assert.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 ui/spice-core.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/ui/spice-core.c b/ui/spice-core.c
index fc850b3f50..1f1501de78 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -922,12 +922,20 @@ int qemu_spice_display_add_client(int csock, int skipauth, int tls)
 
 void qemu_spice_display_start(void)
 {
+    if (spice_display_is_running) {
+        return;
+    }
+
     spice_display_is_running = true;
     spice_server_vm_start(spice_server);
 }
 
 void qemu_spice_display_stop(void)
 {
+    if (!spice_display_is_running) {
+        return;
+    }
+
     spice_server_vm_stop(spice_server);
     spice_display_is_running = false;
 }
-- 
2.20.1.2.gb21ebb671b

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

* [Qemu-devel] [PATCH v2 05/12] spice: merge options lists
  2018-12-20 14:15 [Qemu-devel] [PATCH v2 00/12] spice: add -display spice-app, setup and launch a Spice client Marc-André Lureau
                   ` (3 preceding siblings ...)
  2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 04/12] spice: avoid spice runtime assert Marc-André Lureau
@ 2018-12-20 14:15 ` Marc-André Lureau
  2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 06/12] spice: do not stop spice if VM is paused Marc-André Lureau
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Marc-André Lureau @ 2018-12-20 14:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, kraxel

Passing several -spice options to qemu command line, or calling
several time qemu_opts_set() will ignore all but the first option
list. Since the spice server is a singleton, it makes sense to merge
all the options, the last value being the one taken into account.

This changes the behaviour from, for ex:
$ qemu... -spice port=5900 -spice port=5901 -> port: 5900
to:
$ qemu... -spice port=5900 -spice port=5901 -> port: 5901

(if necessary we could instead produce an error when an option is
given twice, although this makes handling default values and such more
complicated)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 ui/spice-core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ui/spice-core.c b/ui/spice-core.c
index 1f1501de78..6fefd95cea 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -398,6 +398,7 @@ static SpiceChannelList *qmp_query_spice_channels(void)
 static QemuOptsList qemu_spice_opts = {
     .name = "spice",
     .head = QTAILQ_HEAD_INITIALIZER(qemu_spice_opts.head),
+    .merge_lists = true,
     .desc = {
         {
             .name = "port",
-- 
2.20.1.2.gb21ebb671b

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

* [Qemu-devel] [PATCH v2 06/12] spice: do not stop spice if VM is paused
  2018-12-20 14:15 [Qemu-devel] [PATCH v2 00/12] spice: add -display spice-app, setup and launch a Spice client Marc-André Lureau
                   ` (4 preceding siblings ...)
  2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 05/12] spice: merge options lists Marc-André Lureau
@ 2018-12-20 14:15 ` Marc-André Lureau
  2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 07/12] char: move SpiceChardev and open_spice_port() to spice.h header Marc-André Lureau
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Marc-André Lureau @ 2018-12-20 14:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, kraxel

spice_server_vm_start/stop() was added to help migration state (commit
f5bb039c6d97ef3e664094eab3c9a4dc1824ed73).

However, a paused VM could keep running the spice server. This will
allow a Spice client to keep sending commands to a spice chardev. This
allows to stop/cont a VM from a Spice monitor port. Character
devices (vdagent/usb/smartcard/..) should not read from Spice when the
VM is paused.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 ui/spice-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ui/spice-core.c b/ui/spice-core.c
index 6fefd95cea..9627f07cd8 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -628,7 +628,7 @@ static void vm_change_state_handler(void *opaque, int running,
 {
     if (running) {
         qemu_spice_display_start();
-    } else {
+    } else if (state != RUN_STATE_PAUSED) {
         qemu_spice_display_stop();
     }
 }
-- 
2.20.1.2.gb21ebb671b

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

* [Qemu-devel] [PATCH v2 07/12] char: move SpiceChardev and open_spice_port() to spice.h header
  2018-12-20 14:15 [Qemu-devel] [PATCH v2 00/12] spice: add -display spice-app, setup and launch a Spice client Marc-André Lureau
                   ` (5 preceding siblings ...)
  2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 06/12] spice: do not stop spice if VM is paused Marc-André Lureau
@ 2018-12-20 14:15 ` Marc-André Lureau
  2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 08/12] char: register spice ports after spice started Marc-André Lureau
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Marc-André Lureau @ 2018-12-20 14:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, kraxel

This will allow easier subclassing of SpiceChardev, in upcoming
"display: add -display app launching external application" patch.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/chardev/spice.h | 27 +++++++++++++++++++++++++++
 chardev/spice.c         | 28 +++++-----------------------
 2 files changed, 32 insertions(+), 23 deletions(-)
 create mode 100644 include/chardev/spice.h

diff --git a/include/chardev/spice.h b/include/chardev/spice.h
new file mode 100644
index 0000000000..6431da3205
--- /dev/null
+++ b/include/chardev/spice.h
@@ -0,0 +1,27 @@
+#ifndef CHARDEV_SPICE_H_
+#define CHARDEV_SPICE_H_
+
+#include <spice.h>
+#include "chardev/char-fe.h"
+
+typedef struct SpiceChardev {
+    Chardev               parent;
+
+    SpiceCharDeviceInstance sin;
+    bool                  active;
+    bool                  blocked;
+    const uint8_t         *datapos;
+    int                   datalen;
+    QLIST_ENTRY(SpiceChardev) next;
+} SpiceChardev;
+
+#define TYPE_CHARDEV_SPICE "chardev-spice"
+#define TYPE_CHARDEV_SPICEVMC "chardev-spicevmc"
+#define TYPE_CHARDEV_SPICEPORT "chardev-spiceport"
+
+#define SPICE_CHARDEV(obj) OBJECT_CHECK(SpiceChardev, (obj), TYPE_CHARDEV_SPICE)
+
+void qemu_chr_open_spice_port(Chardev *chr, ChardevBackend *backend,
+                              bool *be_opened, Error **errp);
+
+#endif
diff --git a/chardev/spice.c b/chardev/spice.c
index c68e60115b..2202d50eee 100644
--- a/chardev/spice.c
+++ b/chardev/spice.c
@@ -2,30 +2,12 @@
 #include "trace.h"
 #include "ui/qemu-spice.h"
 #include "chardev/char.h"
+#include "chardev/spice.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "qemu/option.h"
-#include <spice.h>
 #include <spice/protocol.h>
 
-
-typedef struct SpiceChardev {
-    Chardev               parent;
-
-    SpiceCharDeviceInstance sin;
-    bool                  active;
-    bool                  blocked;
-    const uint8_t         *datapos;
-    int                   datalen;
-    QLIST_ENTRY(SpiceChardev) next;
-} SpiceChardev;
-
-#define TYPE_CHARDEV_SPICE "chardev-spice"
-#define TYPE_CHARDEV_SPICEVMC "chardev-spicevmc"
-#define TYPE_CHARDEV_SPICEPORT "chardev-spiceport"
-
-#define SPICE_CHARDEV(obj) OBJECT_CHECK(SpiceChardev, (obj), TYPE_CHARDEV_SPICE)
-
 typedef struct SpiceCharSource {
     GSource               source;
     SpiceChardev       *scd;
@@ -315,10 +297,10 @@ static void qemu_chr_open_spice_vmc(Chardev *chr,
     chr_open(chr, type);
 }
 
-static void qemu_chr_open_spice_port(Chardev *chr,
-                                     ChardevBackend *backend,
-                                     bool *be_opened,
-                                     Error **errp)
+void qemu_chr_open_spice_port(Chardev *chr,
+                              ChardevBackend *backend,
+                              bool *be_opened,
+                              Error **errp)
 {
     ChardevSpicePort *spiceport = backend->u.spiceport.data;
     const char *name = spiceport->fqdn;
-- 
2.20.1.2.gb21ebb671b

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

* [Qemu-devel] [PATCH v2 08/12] char: register spice ports after spice started
  2018-12-20 14:15 [Qemu-devel] [PATCH v2 00/12] spice: add -display spice-app, setup and launch a Spice client Marc-André Lureau
                   ` (6 preceding siblings ...)
  2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 07/12] char: move SpiceChardev and open_spice_port() to spice.h header Marc-André Lureau
@ 2018-12-20 14:15 ` Marc-André Lureau
  2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 09/12] build-sys: add gio-2.0 check Marc-André Lureau
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Marc-André Lureau @ 2018-12-20 14:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, kraxel

Spice port registration is delayed until the server is started. But
ports created after are not being registered. If the server is already
started, do vmc_register_interface() to register it from
qemu_chr_open_spice_port().

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 chardev/spice.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/chardev/spice.c b/chardev/spice.c
index 2202d50eee..22c30ae833 100644
--- a/chardev/spice.c
+++ b/chardev/spice.c
@@ -316,6 +316,11 @@ void qemu_chr_open_spice_port(Chardev *chr,
     *be_opened = false;
     s = SPICE_CHARDEV(chr);
     s->sin.portname = g_strdup(name);
+
+    if (using_spice) {
+        /* spice server already created */
+        vmc_register_interface(s);
+    }
 }
 
 void qemu_spice_register_ports(void)
-- 
2.20.1.2.gb21ebb671b

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

* [Qemu-devel] [PATCH v2 09/12] build-sys: add gio-2.0 check
  2018-12-20 14:15 [Qemu-devel] [PATCH v2 00/12] spice: add -display spice-app, setup and launch a Spice client Marc-André Lureau
                   ` (7 preceding siblings ...)
  2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 08/12] char: register spice ports after spice started Marc-André Lureau
@ 2018-12-20 14:15 ` Marc-André Lureau
  2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 10/12] qapi: document DisplayType enum Marc-André Lureau
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Marc-André Lureau @ 2018-12-20 14:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, kraxel

GIO is required for the -display app backend.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 configure | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/configure b/configure
index b0927b882a..dd0bcc2a10 100755
--- a/configure
+++ b/configure
@@ -3518,6 +3518,14 @@ for i in $glib_modules; do
     fi
 done
 
+if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
+    gio=yes
+    gio_cflags=$($pkg_config --cflags gio-2.0)
+    gio_libs=$($pkg_config --libs gio-2.0)
+else
+    gio=no
+fi
+
 # Sanity check that the current size_t matches the
 # size that glib thinks it should be. This catches
 # problems on multi-arch where people try to build
@@ -6472,6 +6480,11 @@ if test "$gtk" = "yes" ; then
     echo "CONFIG_GTK_GL=y" >> $config_host_mak
   fi
 fi
+if test "$gio" = "yes" ; then
+    echo "CONFIG_GIO=y" >> $config_host_mak
+    echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
+    echo "GIO_LIBS=$gio_libs" >> $config_host_mak
+fi
 echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
 if test "$gnutls" = "yes" ; then
   echo "CONFIG_GNUTLS=y" >> $config_host_mak
-- 
2.20.1.2.gb21ebb671b

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

* [Qemu-devel] [PATCH v2 10/12] qapi: document DisplayType enum
  2018-12-20 14:15 [Qemu-devel] [PATCH v2 00/12] spice: add -display spice-app, setup and launch a Spice client Marc-André Lureau
                   ` (8 preceding siblings ...)
  2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 09/12] build-sys: add gio-2.0 check Marc-André Lureau
@ 2018-12-20 14:15 ` Marc-André Lureau
  2018-12-20 14:46   ` Eric Blake
  2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 11/12] spice: use a default name for the server Marc-André Lureau
                   ` (3 subsequent siblings)
  13 siblings, 1 reply; 19+ messages in thread
From: Marc-André Lureau @ 2018-12-20 14:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, kraxel

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 qapi/ui.json | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/qapi/ui.json b/qapi/ui.json
index 5ad13248d5..3f2f662dca 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -1075,6 +1075,30 @@
 #
 # Display (user interface) type.
 #
+# @default: The default user interface.
+#
+# @none: No user interface or video output display. The guest will
+#        still see an emulated graphics card, but its output will not
+#        be displayed to the QEMU user.
+#
+# @gtk: The GTK user interface.
+#
+# @sdl: The SDL user interface.
+#
+# @egl-headless: No user interface, offload GL operations to a local
+#                DRI device. Graphical display need to be paired with
+#                VNC or Spice. (Since 3.1)
+#
+# @curses: Display video output via curses.  For graphics device
+#          models which support a text mode, QEMU can display this
+#          output using a curses/ncurses interface. Nothing is
+#          displayed when the graphics device is in graphical mode or
+#          if the graphics device does not support a text
+#          mode. Generally only the VGA device models support text
+#          mode.
+#
+# @cocoa: The Cocoa user interface.
+#
 # Since: 2.12
 #
 ##
-- 
2.20.1.2.gb21ebb671b

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

* [Qemu-devel] [PATCH v2 11/12] spice: use a default name for the server
  2018-12-20 14:15 [Qemu-devel] [PATCH v2 00/12] spice: add -display spice-app, setup and launch a Spice client Marc-André Lureau
                   ` (9 preceding siblings ...)
  2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 10/12] qapi: document DisplayType enum Marc-André Lureau
@ 2018-12-20 14:15 ` Marc-André Lureau
  2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 12/12] display: add -display spice-app launching a Spice client Marc-André Lureau
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Marc-André Lureau @ 2018-12-20 14:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, kraxel

If no -name is given, let's use a friendly "QEMU version" server
name. This is sometime exposed on spice client side, for example on
remote-viewer title.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 ui/spice-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ui/spice-core.c b/ui/spice-core.c
index 9627f07cd8..71ff34c927 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -785,7 +785,7 @@ void qemu_spice_init(void)
 
     qemu_opt_foreach(opts, add_channel, &tls_port, &error_fatal);
 
-    spice_server_set_name(spice_server, qemu_name);
+    spice_server_set_name(spice_server, qemu_name ?: "QEMU " QEMU_VERSION);
     spice_server_set_uuid(spice_server, (unsigned char *)&qemu_uuid);
 
     seamless_migration = qemu_opt_get_bool(opts, "seamless-migration", 0);
-- 
2.20.1.2.gb21ebb671b

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

* [Qemu-devel] [PATCH v2 12/12] display: add -display spice-app launching a Spice client
  2018-12-20 14:15 [Qemu-devel] [PATCH v2 00/12] spice: add -display spice-app, setup and launch a Spice client Marc-André Lureau
                   ` (10 preceding siblings ...)
  2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 11/12] spice: use a default name for the server Marc-André Lureau
@ 2018-12-20 14:15 ` Marc-André Lureau
  2018-12-21 14:12 ` [Qemu-devel] [PATCH v2 00/12] spice: add -display spice-app, setup and launch " Victor Toso
  2019-02-09 13:19 ` Marc-André Lureau
  13 siblings, 0 replies; 19+ messages in thread
From: Marc-André Lureau @ 2018-12-20 14:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, kraxel

Add a new display backend that will configure Spice to allow a remote
client to control QEMU in a similar fashion as other QEMU display
backend/UI like GTK.

For this to work, it will set up Spice server with a unix socket, and
register a VC chardev that will be exposed as Spice ports. A QMP
monitor is also exposed as a Spice port, this allows the remote client
fuller qemu control and state handling.

- doesn't handle VC set_echo() - this doesn't seem a strong
  requirement, very few front-end use it
- spice options can be tweaked with other -spice arguments
- Windows support shouldn't be hard to do, but will probably use a TCP
  port instead
- we may want to watch the child process to quit automatically if it
  crashed

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 qapi/ui.json     |   7 +-
 ui/spice-app.c   | 200 +++++++++++++++++++++++++++++++++++++++++++++++
 qemu-options.hx  |   5 ++
 ui/Makefile.objs |   5 ++
 4 files changed, 216 insertions(+), 1 deletion(-)
 create mode 100644 ui/spice-app.c

diff --git a/qapi/ui.json b/qapi/ui.json
index 3f2f662dca..56092706dd 100644
--- a/qapi/ui.json
+++ b/qapi/ui.json
@@ -1099,12 +1099,17 @@
 #
 # @cocoa: The Cocoa user interface.
 #
+# @spice-app: Set up a Spice server and run the default associated
+#             application to connect to it. The server will redirect
+#             the serial console and QEMU monitors. (Since 4.0)
+#
 # Since: 2.12
 #
 ##
 { 'enum'    : 'DisplayType',
   'data'    : [ 'default', 'none', 'gtk', 'sdl',
-                'egl-headless', 'curses', 'cocoa' ] }
+                'egl-headless', 'curses', 'cocoa',
+                'spice-app'] }
 
 ##
 # @DisplayOptions:
diff --git a/ui/spice-app.c b/ui/spice-app.c
new file mode 100644
index 0000000000..1d283d7ba3
--- /dev/null
+++ b/ui/spice-app.c
@@ -0,0 +1,200 @@
+/*
+ * QEMU external Spice client display driver
+ *
+ * Copyright (c) 2018 Marc-André Lureau <marcandre.lureau@redhat.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include "qemu/osdep.h"
+
+#include <gio/gio.h>
+
+#include "qemu-common.h"
+#include "ui/console.h"
+#include "qemu/config-file.h"
+#include "qemu/option.h"
+#include "qemu/cutils.h"
+#include "qapi/error.h"
+#include "io/channel-command.h"
+#include "chardev/spice.h"
+#include "sysemu/sysemu.h"
+
+static const char *tmp_dir;
+static char *app_dir;
+static char *sock_path;
+
+typedef struct VCChardev {
+    SpiceChardev parent;
+} VCChardev;
+
+#define TYPE_CHARDEV_VC "chardev-vc"
+#define VC_CHARDEV(obj) OBJECT_CHECK(VCChardev, (obj), TYPE_CHARDEV_VC)
+
+static ChardevBackend *
+chr_spice_backend_new(void)
+{
+    ChardevBackend *be = g_new0(ChardevBackend, 1);
+
+    be->type = CHARDEV_BACKEND_KIND_SPICEPORT;
+    be->u.spiceport.data = g_new0(ChardevSpicePort, 1);
+
+    return be;
+}
+
+static void vc_chr_open(Chardev *chr,
+                        ChardevBackend *backend,
+                        bool *be_opened,
+                        Error **errp)
+{
+    ChardevBackend *be;
+    const char *fqdn = NULL;
+
+    if (strstart(chr->label, "serial", NULL)) {
+        fqdn = "org.qemu.console.serial.0";
+    } else if (strstart(chr->label, "parallel", NULL)) {
+        fqdn = "org.qemu.console.parallel.0";
+    } else if (strstart(chr->label, "compat_monitor", NULL)) {
+        fqdn = "org.qemu.monitor.hmp.0";
+    }
+
+    be = chr_spice_backend_new();
+    be->u.spiceport.data->fqdn = fqdn ?
+        g_strdup(fqdn) : g_strdup_printf("org.qemu.console.%s", chr->label);
+    qemu_chr_open_spice_port(chr, be, be_opened, errp);
+    qapi_free_ChardevBackend(be);
+}
+
+static void vc_chr_set_echo(Chardev *chr, bool echo)
+{
+    /* TODO: set echo for frontends QMP and qtest */
+}
+
+static void char_vc_class_init(ObjectClass *oc, void *data)
+{
+    ChardevClass *cc = CHARDEV_CLASS(oc);
+
+    cc->parse = qemu_chr_parse_vc;
+    cc->open = vc_chr_open;
+    cc->chr_set_echo = vc_chr_set_echo;
+}
+
+static const TypeInfo char_vc_type_info = {
+    .name = TYPE_CHARDEV_VC,
+    .parent = TYPE_CHARDEV_SPICEPORT,
+    .instance_size = sizeof(VCChardev),
+    .class_init = char_vc_class_init,
+};
+
+static void spice_app_atexit(void)
+{
+    if (sock_path) {
+        unlink(sock_path);
+    }
+    if (tmp_dir) {
+        rmdir(tmp_dir);
+    }
+    g_free(sock_path);
+    g_free(app_dir);
+}
+
+static void spice_app_display_early_init(DisplayOptions *opts)
+{
+    QemuOpts *qopts;
+    ChardevBackend *be = chr_spice_backend_new();
+    GError *err = NULL;
+
+    if (opts->has_full_screen) {
+        error_report("spice-app full-screen isn't supported yet.");
+        exit(1);
+    }
+    if (opts->has_window_close) {
+        error_report("spice-app window-close isn't supported yet.");
+        exit(1);
+    }
+
+    atexit(spice_app_atexit);
+
+    if (qemu_name) {
+        app_dir = g_build_filename(g_get_user_runtime_dir(),
+                                   "qemu", qemu_name, NULL);
+        if (g_mkdir_with_parents(app_dir, S_IRWXU) < -1) {
+            error_report("Failed to create directory %s: %s",
+                         app_dir, strerror(errno));
+            exit(1);
+        }
+    } else {
+        app_dir = g_dir_make_tmp(NULL, &err);
+        tmp_dir = app_dir;
+        if (err) {
+            error_report("Failed to create temporary directory: %s",
+                         err->message);
+            exit(1);
+        }
+    }
+
+    type_register(&char_vc_type_info);
+
+    sock_path = g_strjoin("", app_dir, "/", "spice.sock", NULL);
+    qopts = qemu_opts_create(qemu_find_opts("spice"), NULL, 0, &error_abort);
+    qemu_opt_set(qopts, "disable-ticketing", "on", &error_abort);
+    qemu_opt_set(qopts, "unix", "on", &error_abort);
+    qemu_opt_set(qopts, "addr", sock_path, &error_abort);
+    qemu_opt_set(qopts, "image-compression", "off", &error_abort);
+    qemu_opt_set(qopts, "streaming-video", "off", &error_abort);
+    qemu_opt_set(qopts, "gl", opts->has_gl ? "on" : "off", &error_abort);
+    display_opengl = opts->has_gl;
+
+    be->u.spiceport.data->fqdn = g_strdup("org.qemu.monitor.qmp.0");
+    qemu_chardev_new("org.qemu.monitor.qmp", TYPE_CHARDEV_SPICEPORT,
+                     be, &error_abort);
+    qopts = qemu_opts_create(qemu_find_opts("mon"),
+                             NULL, 0, &error_fatal);
+    qemu_opt_set(qopts, "chardev", "org.qemu.monitor.qmp", &error_abort);
+    qemu_opt_set(qopts, "mode", "control", &error_abort);
+
+    qapi_free_ChardevBackend(be);
+}
+
+static void spice_app_display_init(DisplayState *ds, DisplayOptions *opts)
+{
+    GError *err = NULL;
+    gchar *uri;
+
+    uri = g_strjoin("", "spice+unix://", app_dir, "/", "spice.sock", NULL);
+    info_report("Launching display with URI: %s", uri);
+    g_app_info_launch_default_for_uri(uri, NULL, &err);
+    if (err) {
+        error_report("Failed to launch %s URI: %s", uri, err->message);
+        exit(1);
+    }
+    g_free(uri);
+}
+
+static QemuDisplay qemu_display_spice_app = {
+    .type       = DISPLAY_TYPE_SPICE_APP,
+    .early_init = spice_app_display_early_init,
+    .init       = spice_app_display_init,
+};
+
+static void register_spice_app(void)
+{
+    qemu_display_register(&qemu_display_spice_app);
+}
+
+type_init(register_spice_app);
diff --git a/qemu-options.hx b/qemu-options.hx
index df42116ecc..e13425fbc2 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1211,6 +1211,7 @@ STEXI
 ETEXI
 
 DEF("display", HAS_ARG, QEMU_OPTION_display,
+    "-display spice-app[,gl=on|off]\n"
     "-display sdl[,frame=on|off][,alt_grab=on|off][,ctrl_grab=on|off]\n"
     "            [,window_close=on|off][,gl=on|core|es|off]\n"
     "-display gtk[,grab_on_hover=on|off][,gl=on|off]|\n"
@@ -1262,6 +1263,10 @@ Start a VNC server on display <arg>
 @item egl-headless
 Offload all OpenGL operations to a local DRI device. For any graphical display,
 this display needs to be paired with either VNC or SPICE displays.
+@item spice-app
+Start QEMU as a Spice server and launch the default Spice client
+application. The Spice server will redirect the serial consoles and
+QEMU monitors. (Since 4.0)
 @end table
 ETEXI
 
diff --git a/ui/Makefile.objs b/ui/Makefile.objs
index 00f6976c30..5b155d2292 100644
--- a/ui/Makefile.objs
+++ b/ui/Makefile.objs
@@ -54,6 +54,11 @@ curses.mo-objs := curses.o
 curses.mo-cflags := $(CURSES_CFLAGS)
 curses.mo-libs := $(CURSES_LIBS)
 
+common-obj-$(call land,$(CONFIG_SPICE),$(CONFIG_GIO)) += spice-app.mo
+spice-app.mo-objs := spice-app.o
+spice-app.mo-cflags := $(GIO_CFLAGS)
+spice-app.mo-libs := $(GIO_LIBS)
+
 common-obj-$(CONFIG_OPENGL) += shader.o
 common-obj-$(CONFIG_OPENGL) += console-gl.o
 common-obj-$(CONFIG_OPENGL) += egl-helpers.o
-- 
2.20.1.2.gb21ebb671b

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

* Re: [Qemu-devel] [PATCH v2 10/12] qapi: document DisplayType enum
  2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 10/12] qapi: document DisplayType enum Marc-André Lureau
@ 2018-12-20 14:46   ` Eric Blake
  2019-01-07  9:45     ` Gerd Hoffmann
  0 siblings, 1 reply; 19+ messages in thread
From: Eric Blake @ 2018-12-20 14:46 UTC (permalink / raw)
  To: Marc-André Lureau, qemu-devel; +Cc: kraxel

On 12/20/18 8:15 AM, Marc-André Lureau wrote:
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>   qapi/ui.json | 24 ++++++++++++++++++++++++
>   1 file changed, 24 insertions(+)
> 
> diff --git a/qapi/ui.json b/qapi/ui.json
> index 5ad13248d5..3f2f662dca 100644
> --- a/qapi/ui.json
> +++ b/qapi/ui.json
> @@ -1075,6 +1075,30 @@
>   #
>   # Display (user interface) type.
>   #
> +# @default: The default user interface.

Any more hints on how this default is determined?  Is it a compile-time 
decision, based on what libraries were linked in?  Does the work on 
adding #if support to qapi make it introspectible what the default is?

> +#
> +# @none: No user interface or video output display. The guest will
> +#        still see an emulated graphics card, but its output will not
> +#        be displayed to the QEMU user.
> +#
> +# @gtk: The GTK user interface.
> +#
> +# @sdl: The SDL user interface.
> +#
> +# @egl-headless: No user interface, offload GL operations to a local
> +#                DRI device. Graphical display need to be paired with
> +#                VNC or Spice. (Since 3.1)

s/need/needs/

> +#
> +# @curses: Display video output via curses.  For graphics device
> +#          models which support a text mode, QEMU can display this
> +#          output using a curses/ncurses interface. Nothing is
> +#          displayed when the graphics device is in graphical mode or
> +#          if the graphics device does not support a text
> +#          mode. Generally only the VGA device models support text
> +#          mode.
> +#
> +# @cocoa: The Cocoa user interface.
> +#
>   # Since: 2.12
>   #
>   ##
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

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

* Re: [Qemu-devel] [PATCH v2 00/12] spice: add -display spice-app, setup and launch a Spice client
  2018-12-20 14:15 [Qemu-devel] [PATCH v2 00/12] spice: add -display spice-app, setup and launch a Spice client Marc-André Lureau
                   ` (11 preceding siblings ...)
  2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 12/12] display: add -display spice-app launching a Spice client Marc-André Lureau
@ 2018-12-21 14:12 ` Victor Toso
  2019-02-09 13:19 ` Marc-André Lureau
  13 siblings, 0 replies; 19+ messages in thread
From: Victor Toso @ 2018-12-21 14:12 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: qemu-devel, kraxel

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

Hi,

On Thu, Dec 20, 2018 at 06:15:41PM +0400, Marc-André Lureau wrote:
> Hi,
> 
> The QEMU GTK UI is quite featurful. Yet, it doesn't provide many of
> the functionalities one can expect from a VM desktop application (USB
> redirection, shared folders, drag and drop, better multimonitor
> support etc.).
> 
> Spice is able to export many of the VM controls to a client, including
> QMP monitor, serial ports etc... It's thus possible for a Spice client
> to provide a similar experience as the QEMU GTK UI (while keeping
> similar display performances locally) and more.
> 
> This series provides "-display spice-app" to setup a Spice server and
> launch a client (associated with the spice+unix:// URI). With
> virt-viewer series "Add QEMU-like UI: VT console & basic VM state"
> (under review), the resulting user experience is close to what qemu
> GTK UI provides.

Not much knowledge on the qemu codebase but I tested this and v1
with spice-gtk + virt-viewer patches and it works well so,

Tested-by: Victor Toso <victortoso@redhat.com>

> v2:
> - renamed -display app -> -display spice-app
> - error if full-screen or window-close is provided (supports can be
>   added later)
> - use a stable URI when -name is provided
> - print the URI at start
> - added "qapi: document DisplayType enum"
> - added "spice: use a default name for the server"
> - commit message tweaks
> - include previously reviewed "configure: bump spice-server required
>   version to 0.12.5", to avoid conflicts
> - rebased
> 
> Marc-André Lureau (12):
>   configure: bump spice-server required version to 0.12.5
>   char/spice: trigger HUP event
>   char/spice: discard write() if backend is disconnected
>   spice: avoid spice runtime assert
>   spice: merge options lists
>   spice: do not stop spice if VM is paused
>   char: move SpiceChardev and open_spice_port() to spice.h header
>   char: register spice ports after spice started
>   build-sys: add gio-2.0 check
>   qapi: document DisplayType enum
>   spice: use a default name for the server
>   display: add -display spice-app launching a Spice client
> 
>  qapi/ui.json            |  31 ++++++-
>  include/chardev/spice.h |  27 ++++++
>  include/ui/qemu-spice.h |   6 --
>  chardev/spice.c         |  70 +++++++-------
>  hw/display/qxl.c        |   2 -
>  ui/spice-app.c          | 200 ++++++++++++++++++++++++++++++++++++++++
>  ui/spice-core.c         |  21 +++--
>  chardev/trace-events    |   1 +
>  configure               |  17 +++-
>  qemu-options.hx         |   5 +
>  ui/Makefile.objs        |   5 +
>  11 files changed, 330 insertions(+), 55 deletions(-)
>  create mode 100644 include/chardev/spice.h
>  create mode 100644 ui/spice-app.c
> 
> -- 
> 2.20.1.2.gb21ebb671b
> 
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [Qemu-devel] [PATCH v2 10/12] qapi: document DisplayType enum
  2018-12-20 14:46   ` Eric Blake
@ 2019-01-07  9:45     ` Gerd Hoffmann
  2019-02-09 13:15       ` Marc-André Lureau
  0 siblings, 1 reply; 19+ messages in thread
From: Gerd Hoffmann @ 2019-01-07  9:45 UTC (permalink / raw)
  To: Eric Blake; +Cc: Marc-André Lureau, qemu-devel

On Thu, Dec 20, 2018 at 08:46:13AM -0600, Eric Blake wrote:
> On 12/20/18 8:15 AM, Marc-André Lureau wrote:
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> >   qapi/ui.json | 24 ++++++++++++++++++++++++
> >   1 file changed, 24 insertions(+)
> > 
> > diff --git a/qapi/ui.json b/qapi/ui.json
> > index 5ad13248d5..3f2f662dca 100644
> > --- a/qapi/ui.json
> > +++ b/qapi/ui.json
> > @@ -1075,6 +1075,30 @@
> >   #
> >   # Display (user interface) type.
> >   #
> > +# @default: The default user interface.
> 
> Any more hints on how this default is determined?  Is it a compile-time
> decision, based on what libraries were linked in?

Basically yes.  A bit more complicated due to modules.  gtk, sdl and
cocoa are checked, in that order.  And if none of them is available the
vnc server is enabled.

> Does the work on adding
> #if support to qapi make it introspectible what the default is?

Due to modules it isn't a compile time constant.  With a modular build
and gtk being packaged as separate sub-rpm the default depends on
whenever the sub-rpm is installed or not.

So I guess the answer is "no".

cheers,
  Gerd

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

* Re: [Qemu-devel] [PATCH v2 10/12] qapi: document DisplayType enum
  2019-01-07  9:45     ` Gerd Hoffmann
@ 2019-02-09 13:15       ` Marc-André Lureau
  2019-02-11 18:28         ` Eric Blake
  0 siblings, 1 reply; 19+ messages in thread
From: Marc-André Lureau @ 2019-02-09 13:15 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: Eric Blake, QEMU

Hi

On Mon, Jan 7, 2019 at 10:46 AM Gerd Hoffmann <kraxel@redhat.com> wrote:
>
> On Thu, Dec 20, 2018 at 08:46:13AM -0600, Eric Blake wrote:
> > On 12/20/18 8:15 AM, Marc-André Lureau wrote:
> > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > > ---
> > >   qapi/ui.json | 24 ++++++++++++++++++++++++
> > >   1 file changed, 24 insertions(+)
> > >
> > > diff --git a/qapi/ui.json b/qapi/ui.json
> > > index 5ad13248d5..3f2f662dca 100644
> > > --- a/qapi/ui.json
> > > +++ b/qapi/ui.json
> > > @@ -1075,6 +1075,30 @@
> > >   #
> > >   # Display (user interface) type.
> > >   #
> > > +# @default: The default user interface.
> >
> > Any more hints on how this default is determined?  Is it a compile-time
> > decision, based on what libraries were linked in?
>
> Basically yes.  A bit more complicated due to modules.  gtk, sdl and
> cocoa are checked, in that order.  And if none of them is available the
> vnc server is enabled.


Eric, should I cram this comment there?: "(gtk, sdl and
cocoa are checked, in that order.  And if none of them is available the
vnc server is enabled)"

thanks

>
> > Does the work on adding
> > #if support to qapi make it introspectible what the default is?
>
> Due to modules it isn't a compile time constant.  With a modular build
> and gtk being packaged as separate sub-rpm the default depends on
> whenever the sub-rpm is installed or not.
>
> So I guess the answer is "no".
>
> cheers,
>   Gerd
>



-- 
Marc-André Lureau

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

* Re: [Qemu-devel] [PATCH v2 00/12] spice: add -display spice-app, setup and launch a Spice client
  2018-12-20 14:15 [Qemu-devel] [PATCH v2 00/12] spice: add -display spice-app, setup and launch a Spice client Marc-André Lureau
                   ` (12 preceding siblings ...)
  2018-12-21 14:12 ` [Qemu-devel] [PATCH v2 00/12] spice: add -display spice-app, setup and launch " Victor Toso
@ 2019-02-09 13:19 ` Marc-André Lureau
  13 siblings, 0 replies; 19+ messages in thread
From: Marc-André Lureau @ 2019-02-09 13:19 UTC (permalink / raw)
  To: QEMU; +Cc: Gerd Hoffmann

Hi

On Thu, Dec 20, 2018 at 3:44 PM Marc-André Lureau
<marcandre.lureau@redhat.com> wrote:
>
> Hi,
>
> The QEMU GTK UI is quite featurful. Yet, it doesn't provide many of
> the functionalities one can expect from a VM desktop application (USB
> redirection, shared folders, drag and drop, better multimonitor
> support etc.).
>
> Spice is able to export many of the VM controls to a client, including
> QMP monitor, serial ports etc... It's thus possible for a Spice client
> to provide a similar experience as the QEMU GTK UI (while keeping
> similar display performances locally) and more.
>
> This series provides "-display spice-app" to setup a Spice server and
> launch a client (associated with the spice+unix:// URI). With
> virt-viewer series "Add QEMU-like UI: VT console & basic VM state"
> (under review), the resulting user experience is close to what qemu
> GTK UI provides.
>
> v2:
> - renamed -display app -> -display spice-app
> - error if full-screen or window-close is provided (supports can be
>   added later)
> - use a stable URI when -name is provided
> - print the URI at start
> - added "qapi: document DisplayType enum"
> - added "spice: use a default name for the server"
> - commit message tweaks
> - include previously reviewed "configure: bump spice-server required
>   version to 0.12.5", to avoid conflicts
> - rebased
>

ping for reviews

(rebased version pushed on github https://github.com/elmarco/qemu/commits/spice)

thanks

> Marc-André Lureau (12):
>   configure: bump spice-server required version to 0.12.5
>   char/spice: trigger HUP event
>   char/spice: discard write() if backend is disconnected
>   spice: avoid spice runtime assert
>   spice: merge options lists
>   spice: do not stop spice if VM is paused
>   char: move SpiceChardev and open_spice_port() to spice.h header
>   char: register spice ports after spice started
>   build-sys: add gio-2.0 check
>   qapi: document DisplayType enum
>   spice: use a default name for the server
>   display: add -display spice-app launching a Spice client
>
>  qapi/ui.json            |  31 ++++++-
>  include/chardev/spice.h |  27 ++++++
>  include/ui/qemu-spice.h |   6 --
>  chardev/spice.c         |  70 +++++++-------
>  hw/display/qxl.c        |   2 -
>  ui/spice-app.c          | 200 ++++++++++++++++++++++++++++++++++++++++
>  ui/spice-core.c         |  21 +++--
>  chardev/trace-events    |   1 +
>  configure               |  17 +++-
>  qemu-options.hx         |   5 +
>  ui/Makefile.objs        |   5 +
>  11 files changed, 330 insertions(+), 55 deletions(-)
>  create mode 100644 include/chardev/spice.h
>  create mode 100644 ui/spice-app.c
>
> --
> 2.20.1.2.gb21ebb671b
>
>


-- 
Marc-André Lureau

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

* Re: [Qemu-devel] [PATCH v2 10/12] qapi: document DisplayType enum
  2019-02-09 13:15       ` Marc-André Lureau
@ 2019-02-11 18:28         ` Eric Blake
  0 siblings, 0 replies; 19+ messages in thread
From: Eric Blake @ 2019-02-11 18:28 UTC (permalink / raw)
  To: Marc-André Lureau, Gerd Hoffmann; +Cc: QEMU

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

On 2/9/19 7:15 AM, Marc-André Lureau wrote:

>>>>   # Display (user interface) type.
>>>>   #
>>>> +# @default: The default user interface.
>>>
>>> Any more hints on how this default is determined?  Is it a compile-time
>>> decision, based on what libraries were linked in?
>>
>> Basically yes.  A bit more complicated due to modules.  gtk, sdl and
>> cocoa are checked, in that order.  And if none of them is available the
>> vnc server is enabled.
> 
> 
> Eric, should I cram this comment there?: "(gtk, sdl and
> cocoa are checked, in that order.  And if none of them is available the
> vnc server is enabled)"

If you think the end user will benefit from reading that, then it is
worth adding.  Wordsmithing a bit:

@default: The default user interface, selecting from the first available
of gtk, sdl, cocoa, and vnc.


-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


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

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

end of thread, other threads:[~2019-02-11 18:28 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-20 14:15 [Qemu-devel] [PATCH v2 00/12] spice: add -display spice-app, setup and launch a Spice client Marc-André Lureau
2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 01/12] configure: bump spice-server required version to 0.12.5 Marc-André Lureau
2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 02/12] char/spice: trigger HUP event Marc-André Lureau
2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 03/12] char/spice: discard write() if backend is disconnected Marc-André Lureau
2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 04/12] spice: avoid spice runtime assert Marc-André Lureau
2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 05/12] spice: merge options lists Marc-André Lureau
2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 06/12] spice: do not stop spice if VM is paused Marc-André Lureau
2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 07/12] char: move SpiceChardev and open_spice_port() to spice.h header Marc-André Lureau
2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 08/12] char: register spice ports after spice started Marc-André Lureau
2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 09/12] build-sys: add gio-2.0 check Marc-André Lureau
2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 10/12] qapi: document DisplayType enum Marc-André Lureau
2018-12-20 14:46   ` Eric Blake
2019-01-07  9:45     ` Gerd Hoffmann
2019-02-09 13:15       ` Marc-André Lureau
2019-02-11 18:28         ` Eric Blake
2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 11/12] spice: use a default name for the server Marc-André Lureau
2018-12-20 14:15 ` [Qemu-devel] [PATCH v2 12/12] display: add -display spice-app launching a Spice client Marc-André Lureau
2018-12-21 14:12 ` [Qemu-devel] [PATCH v2 00/12] spice: add -display spice-app, setup and launch " Victor Toso
2019-02-09 13:19 ` Marc-André Lureau

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.