[Spice-devel] Enable the use of SpiceExitOnDisconnect so that Xspice can be configured to allow exactly one server per client session.

Submitted by Jeremy White on Sept. 6, 2012, 9:04 p.m.

Details

Message ID 50490FDD.8010102@codeweavers.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Jeremy White Sept. 6, 2012, 9:04 p.m.
---
 src/qxl.h                   |    1 +
 src/qxl_driver.c            |    2 ++
 src/spiceqxl_spice_server.c |   12 ++++++++++++
 3 files changed, 15 insertions(+)

Patch hide | download patch | download mbox

diff --git a/src/qxl.h b/src/qxl.h
index 8494550..03d08a1 100644
--- a/src/qxl.h
+++ b/src/qxl.h
@@ -125,6 +125,7 @@  enum {
     OPTION_SPICE_TLS_CIPHERS,
     OPTION_SPICE_CACERT_FILE,
     OPTION_SPICE_DH_FILE,
+    OPTION_SPICE_EXIT_ON_DISCONNECT,
 #endif
     OPTION_COUNT,
 };
diff --git a/src/qxl_driver.c b/src/qxl_driver.c
index c7b8486..ef099c1 100644
--- a/src/qxl_driver.c
+++ b/src/qxl_driver.c
@@ -123,6 +123,8 @@  const OptionInfoRec DefaultOptions[] =
       "SpiceCacertFile",          OPTV_STRING,    {0}, FALSE},
     { OPTION_SPICE_DH_FILE,
       "SpiceDhFile",              OPTV_STRING,    {0}, FALSE},
+    { OPTION_SPICE_EXIT_ON_DISCONNECT,
+      "SpiceExitOnDisconnect",    OPTV_BOOLEAN,   {0}, FALSE},
 #endif
     
     { -1, NULL, OPTV_NONE, {0}, FALSE }
diff --git a/src/spiceqxl_spice_server.c b/src/spiceqxl_spice_server.c
index 84fad06..0432d21 100644
--- a/src/spiceqxl_spice_server.c
+++ b/src/spiceqxl_spice_server.c
@@ -158,6 +158,9 @@  void xspice_set_spice_server_options(OptionInfoPtr options)
     int disable_copy_paste =
         get_bool_option(options, OPTION_SPICE_DISABLE_COPY_PASTE,
                         "XSPICE_DISABLE_COPY_PASTE");
+    int exit_on_disconnect =
+        get_bool_option(options, OPTION_SPICE_EXIT_ON_DISCONNECT,
+                        "XSPICE_EXIT_ON_DISCONNECT");
     const char *image_compression =
         get_str_option(options, OPTION_SPICE_IMAGE_COMPRESSION,
                        "XSPICE_IMAGE_COMPRESSION");
@@ -263,6 +266,15 @@  void xspice_set_spice_server_options(OptionInfoPtr options)
     }
 #endif
 
+    if (exit_on_disconnect) {
+#if SPICE_SERVER_VERSION >= 0x000b04 /* 0.11.4 */
+        spice_server_set_exit_on_disconnect(spice_server, exit_on_disconnect);
+#else
+        fprintf(stderr, "spice: cannot set exit_on_disconnect (spice >= 0.11.4 required)\n");
+        exit(1);
+#endif
+    }
+
     compression = SPICE_IMAGE_COMPRESS_AUTO_GLZ;
     if (image_compression) {
         compression = parse_compression(image_compression);

Comments

Ack.

> ---
>  src/qxl.h                   |    1 +
>  src/qxl_driver.c            |    2 ++
>  src/spiceqxl_spice_server.c |   12 ++++++++++++
>  3 files changed, 15 insertions(+)
> 
> diff --git a/src/qxl.h b/src/qxl.h
> index 8494550..03d08a1 100644
> --- a/src/qxl.h
> +++ b/src/qxl.h
> @@ -125,6 +125,7 @@ enum {
>      OPTION_SPICE_TLS_CIPHERS,
>      OPTION_SPICE_CACERT_FILE,
>      OPTION_SPICE_DH_FILE,
> +    OPTION_SPICE_EXIT_ON_DISCONNECT,
>  #endif
>      OPTION_COUNT,
>  };
> diff --git a/src/qxl_driver.c b/src/qxl_driver.c
> index c7b8486..ef099c1 100644
> --- a/src/qxl_driver.c
> +++ b/src/qxl_driver.c
> @@ -123,6 +123,8 @@ const OptionInfoRec DefaultOptions[] =
>        "SpiceCacertFile",          OPTV_STRING,    {0}, FALSE},
>      { OPTION_SPICE_DH_FILE,
>        "SpiceDhFile",              OPTV_STRING,    {0}, FALSE},
> +    { OPTION_SPICE_EXIT_ON_DISCONNECT,
> +      "SpiceExitOnDisconnect",    OPTV_BOOLEAN,   {0}, FALSE},
>  #endif
>      
>      { -1, NULL, OPTV_NONE, {0}, FALSE }
> diff --git a/src/spiceqxl_spice_server.c
> b/src/spiceqxl_spice_server.c
> index 84fad06..0432d21 100644
> --- a/src/spiceqxl_spice_server.c
> +++ b/src/spiceqxl_spice_server.c
> @@ -158,6 +158,9 @@ void
> xspice_set_spice_server_options(OptionInfoPtr options)
>      int disable_copy_paste =
>          get_bool_option(options, OPTION_SPICE_DISABLE_COPY_PASTE,
>                          "XSPICE_DISABLE_COPY_PASTE");
> +    int exit_on_disconnect =
> +        get_bool_option(options, OPTION_SPICE_EXIT_ON_DISCONNECT,
> +                        "XSPICE_EXIT_ON_DISCONNECT");
>      const char *image_compression =
>          get_str_option(options, OPTION_SPICE_IMAGE_COMPRESSION,
>                         "XSPICE_IMAGE_COMPRESSION");
> @@ -263,6 +266,15 @@ void
> xspice_set_spice_server_options(OptionInfoPtr options)
>      }
>  #endif
>  
> +    if (exit_on_disconnect) {
> +#if SPICE_SERVER_VERSION >= 0x000b04 /* 0.11.4 */
> +        spice_server_set_exit_on_disconnect(spice_server,
> exit_on_disconnect);
> +#else
> +        fprintf(stderr, "spice: cannot set exit_on_disconnect (spice
> >= 0.11.4 required)\n");
> +        exit(1);
> +#endif
> +    }
> +
>      compression = SPICE_IMAGE_COMPRESS_AUTO_GLZ;
>      if (image_compression) {
>          compression = parse_compression(image_compression);
> --
> 1.7.10.4
> 
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
>