[Spice-commits] 2 commits - configure.ac server/red_parse_qxl.c server/reds.c server/spice.h server/spice-server.syms

Alon Levy alon at kemper.freedesktop.org
Wed Sep 5 09:18:44 PDT 2012


 configure.ac             |    6 +++---
 server/red_parse_qxl.c   |   31 ++++++++++++++++++++++++++-----
 server/reds.c            |   14 ++++++++++++++
 server/spice-server.syms |    4 ++++
 server/spice.h           |    1 +
 5 files changed, 48 insertions(+), 8 deletions(-)

New commits:
commit 5819976c7ed6669f4334bb5ec8b25cd213dd7e8a
Author: Jeremy White <jwhite at codeweavers.com>
Date:   Wed Sep 5 09:59:33 2012 -0500

    Implement spice_server_set_exit_on_disconnect to enable an option whereby the spice server shuts down on client disconnect.

diff --git a/configure.ac b/configure.ac
index cb7bed1..3882fb6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -12,10 +12,10 @@ AC_PREREQ([2.57])
 
 m4_define([SPICE_MAJOR], 0)
 m4_define([SPICE_MINOR], 11)
-m4_define([SPICE_MICRO], 3)
-m4_define([SPICE_CURRENT], [4])
+m4_define([SPICE_MICRO], 4)
+m4_define([SPICE_CURRENT], [5])
 m4_define([SPICE_REVISION], [0])
-m4_define([SPICE_AGE], [3])
+m4_define([SPICE_AGE], [4])
 
 # Note on the library name on linux (SONAME) produced by libtool (for reference, gleaned
 # from looking at libtool 2.4.2)
diff --git a/server/reds.c b/server/reds.c
index 8ad8425..98b316d 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -119,6 +119,7 @@ void *red_tunnel = NULL;
 #endif
 int agent_mouse = TRUE;
 int agent_copypaste = TRUE;
+static bool exit_on_disconnect = FALSE;
 
 #define MIGRATE_TIMEOUT (1000 * 10) /* 10sec */
 #define MM_TIMER_GRANULARITY_MS (1000 / 30)
@@ -673,6 +674,12 @@ void reds_client_disconnect(RedClient *client)
 {
     RedsMigTargetClient *mig_client;
 
+    if (exit_on_disconnect)
+    {
+        spice_info("Exiting server because of client disconnect.\n");
+        exit(0);
+    }
+
     if (!client || client->disconnecting) {
         return;
     }
@@ -4061,6 +4068,13 @@ SPICE_GNUC_VISIBLE int spice_server_set_listen_socket_fd(SpiceServer *s, int lis
     return 0;
 }
 
+SPICE_GNUC_VISIBLE int spice_server_set_exit_on_disconnect(SpiceServer *s, int flag)
+{
+    spice_assert(reds == s);
+    exit_on_disconnect = !!flag;
+    return 0;
+}
+
 SPICE_GNUC_VISIBLE int spice_server_set_noauth(SpiceServer *s)
 {
     spice_assert(reds == s);
diff --git a/server/spice-server.syms b/server/spice-server.syms
index 359791c..fd2a423 100644
--- a/server/spice-server.syms
+++ b/server/spice-server.syms
@@ -123,3 +123,7 @@ global:
     spice_server_vm_stop;
     spice_server_set_seamless_migration;
 } SPICE_SERVER_0.10.4;
+
+SPICE_SERVER_0.11.4 {
+    spice_server_set_exit_on_disconnect;
+} SPICE_SERVER_0.11.2;
diff --git a/server/spice.h b/server/spice.h
index 0dc9d05..fdcfbb7 100644
--- a/server/spice.h
+++ b/server/spice.h
@@ -427,6 +427,7 @@ int spice_server_set_compat_version(SpiceServer *s,
 int spice_server_set_port(SpiceServer *s, int port);
 void spice_server_set_addr(SpiceServer *s, const char *addr, int flags);
 int spice_server_set_listen_socket_fd(SpiceServer *s, int listen_fd);
+int spice_server_set_exit_on_disconnect(SpiceServer *s, int flag);
 int spice_server_set_noauth(SpiceServer *s);
 int spice_server_set_sasl(SpiceServer *s, int enabled);
 int spice_server_set_sasl_appname(SpiceServer *s, const char *appname);
commit bf29ff4296ad6462d2382f9166e79c043cc7e08c
Author: Alon Levy <alevy at redhat.com>
Date:   Tue Sep 4 19:23:44 2012 +0300

    server/red_parse_qxl: fix wrong bitmap_consistent
    
    The bit calculation was wrong for all the paletted types by a factor of
    between 8 and 1 (SPICE_BITMAP_FMT_{1,4,8}BIT_PLT_{LE,BE})

diff --git a/server/red_parse_qxl.c b/server/red_parse_qxl.c
index b893add..175f873 100644
--- a/server/red_parse_qxl.c
+++ b/server/red_parse_qxl.c
@@ -328,14 +328,35 @@ static SpiceChunks *red_get_image_data_chunked(RedMemSlotInfo *slots, int group_
     return data;
 }
 
+static const char *bitmap_format_to_string(int format)
+{
+    switch (format) {
+    case SPICE_BITMAP_FMT_INVALID: return "SPICE_BITMAP_FMT_INVALID";
+    case SPICE_BITMAP_FMT_1BIT_LE: return "SPICE_BITMAP_FMT_1BIT_LE";
+    case SPICE_BITMAP_FMT_1BIT_BE: return "SPICE_BITMAP_FMT_1BIT_BE";
+    case SPICE_BITMAP_FMT_4BIT_LE: return "SPICE_BITMAP_FMT_4BIT_LE";
+    case SPICE_BITMAP_FMT_4BIT_BE: return "SPICE_BITMAP_FMT_4BIT_BE";
+    case SPICE_BITMAP_FMT_8BIT: return "SPICE_BITMAP_FMT_8BIT";
+    case SPICE_BITMAP_FMT_16BIT: return "SPICE_BITMAP_FMT_16BIT";
+    case SPICE_BITMAP_FMT_24BIT: return "SPICE_BITMAP_FMT_24BIT";
+    case SPICE_BITMAP_FMT_32BIT: return "SPICE_BITMAP_FMT_32BIT";
+    case SPICE_BITMAP_FMT_RGBA: return "SPICE_BITMAP_FMT_RGBA";
+    case SPICE_BITMAP_FMT_8BIT_A: return "SPICE_BITMAP_FMT_8BIT_A";
+    }
+    return "unknown";
+}
+
+static const int MAP_BITMAP_FMT_TO_BITS_PER_PIXEL[] = {0, 1, 1, 4, 4, 8, 16, 24, 32, 32, 8};
+
 static int bitmap_consistent(SpiceBitmap *bitmap)
 {
-    int type = MAP_BITMAP_FMT_TO_LZ_IMAGE_TYPE[bitmap->format];
-    int bpp = RGB_BYTES_PER_PIXEL[type];
+    int bpp = MAP_BITMAP_FMT_TO_BITS_PER_PIXEL[bitmap->format];
 
-    if (bitmap->stride < bitmap->x * bpp) {
-        spice_error("image stride too small for width: %d < %d * %d\n",
-                    bitmap->stride, bitmap->x, bpp);
+    if (bitmap->stride < bitmap->x * ((bpp + 7) / 8)) {
+        spice_error("image stride too small for width: %d < %d * (%d + 7) / 8 (%s=%d)\n",
+                    bitmap->stride, bitmap->x, bpp,
+                    bitmap_format_to_string(bitmap->format),
+                    bitmap->format);
         return FALSE;
     }
     return TRUE;


More information about the Spice-commits mailing list