[Spice-commits] 7 commits - configure.ac server/char_device.c server/Makefile.am server/red_dispatcher.c server/reds.c server/reds.h server/reds-private.h server/red_worker.c server/snd_worker.c server/spice-audio.h server/spice-char.h server/spice-core.h server/spice.h server/spice-input.h server/spice-migration.h server/spice-qxl.h server/spice-server.h server/spice-version.h.in

Marc-André Lureau elmarco at kemper.freedesktop.org
Thu Nov 27 05:36:10 PST 2014


 configure.ac              |   11 
 server/Makefile.am        |   23 +
 server/char_device.c      |   36 ++
 server/red_dispatcher.c   |    9 
 server/red_worker.c       |   24 +
 server/reds-private.h     |    4 
 server/reds.c             |   25 -
 server/reds.h             |    4 
 server/snd_worker.c       |    9 
 server/spice-audio.h      |   96 +++++++
 server/spice-char.h       |   61 ++++
 server/spice-core.h       |  106 ++++++++
 server/spice-input.h      |   91 +++++++
 server/spice-migration.h  |   64 ++++
 server/spice-qxl.h        |  189 ++++++++++++++
 server/spice-server.h     |  124 +++++++++
 server/spice-version.h.in |   27 ++
 server/spice.h            |  598 ++--------------------------------------------
 18 files changed, 870 insertions(+), 631 deletions(-)

New commits:
commit ea4e9f28bf779771a7f361229d4320fd6e771cb7
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Thu Nov 27 14:30:58 2014 +0100

    Rename mm_timer/mm_time
    
    As suggested by Christophe on the mailing list.

diff --git a/server/reds-private.h b/server/reds-private.h
index 0bfbf3b..2f9af44 100644
--- a/server/reds-private.h
+++ b/server/reds-private.h
@@ -175,7 +175,7 @@ typedef struct RedsState {
     int allow_multiple_clients;
 
     RedsClientMonitorsConfig client_monitors_config;
-    int mm_timer_enabled;
+    int mm_time_enabled;
     uint32_t mm_time_latency;
 } RedsState;
 
diff --git a/server/reds.c b/server/reds.c
index f868cd8..e34433b 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -1280,7 +1280,7 @@ int reds_handle_migrate_data(MainChannelClient *mcc, SpiceMigrateDataMain *mig_d
      * controls the mm-time, we update the client's mm-time.
      * (MSG_MAIN_INIT is not sent for a migrating connection)
      */
-    if (reds->mm_timer_enabled) {
+    if (reds->mm_time_enabled) {
         reds_send_mm_time();
     }
     if (mig_data->agent_base.connected) {
@@ -2423,7 +2423,7 @@ static void reds_send_mm_time(void)
 void reds_set_client_mm_time_latency(RedClient *client, uint32_t latency)
 {
     // TODO: multi-client support for mm_time
-    if (reds->mm_timer_enabled) {
+    if (reds->mm_time_enabled) {
         // TODO: consider network latency
         if (latency > reds->mm_time_latency) {
             reds->mm_time_latency = latency;
@@ -2828,16 +2828,16 @@ uint32_t reds_get_mm_time(void)
     return time_space.tv_sec * 1000 + time_space.tv_nsec / 1000 / 1000;
 }
 
-void reds_enable_mm_timer(void)
+void reds_enable_mm_time(void)
 {
-    reds->mm_timer_enabled = TRUE;
+    reds->mm_time_enabled = TRUE;
     reds->mm_time_latency = MM_TIME_DELTA;
     reds_send_mm_time();
 }
 
-void reds_disable_mm_timer(void)
+void reds_disable_mm_time(void)
 {
-    reds->mm_timer_enabled = FALSE;
+    reds->mm_time_enabled = FALSE;
 }
 
 static SpiceCharDeviceState *attach_to_red_agent(SpiceCharDeviceInstance *sin)
diff --git a/server/reds.h b/server/reds.h
index 371ba96..0483c71 100644
--- a/server/reds.h
+++ b/server/reds.h
@@ -54,8 +54,8 @@ typedef struct RedsMigSpice {
 /* main thread only */
 void reds_handle_channel_event(int event, SpiceChannelEventInfo *info);
 
-void reds_disable_mm_timer(void);
-void reds_enable_mm_timer(void);
+void reds_disable_mm_time(void);
+void reds_enable_mm_time(void);
 uint32_t reds_get_mm_time(void);
 void reds_set_client_mouse_allowed(int is_client_mouse_allowed,
                                    int x_res, int y_res);
diff --git a/server/snd_worker.c b/server/snd_worker.c
index 77bb3ca..a1223b4 100644
--- a/server/snd_worker.c
+++ b/server/snd_worker.c
@@ -1041,7 +1041,7 @@ SPICE_GNUC_VISIBLE void spice_server_playback_start(SpicePlaybackInstance *sin)
     if (!channel)
         return;
     spice_assert(!playback_channel->base.active);
-    reds_disable_mm_timer();
+    reds_disable_mm_time();
     playback_channel->base.active = TRUE;
     if (!playback_channel->base.client_active) {
         snd_set_command(&playback_channel->base, SND_PLAYBACK_CTRL_MASK);
@@ -1060,7 +1060,7 @@ SPICE_GNUC_VISIBLE void spice_server_playback_stop(SpicePlaybackInstance *sin)
     if (!channel)
         return;
     spice_assert(playback_channel->base.active);
-    reds_enable_mm_timer();
+    reds_enable_mm_time();
     playback_channel->base.active = FALSE;
     if (playback_channel->base.client_active) {
         snd_set_command(&playback_channel->base, SND_PLAYBACK_CTRL_MASK);
@@ -1174,7 +1174,7 @@ static void on_new_playback_channel(SndWorker *worker)
         snd_set_command((SndChannel *)playback_channel, SND_PLAYBACK_VOLUME_MASK);
     }
     if (playback_channel->base.active) {
-        reds_disable_mm_timer();
+        reds_disable_mm_time();
     }
 }
 
@@ -1183,7 +1183,7 @@ static void snd_playback_cleanup(SndChannel *channel)
     PlaybackChannel *playback_channel = SPICE_CONTAINEROF(channel, PlaybackChannel, base);
 
     if (playback_channel->base.active) {
-        reds_enable_mm_timer();
+        reds_enable_mm_time();
     }
 
     snd_codec_destroy(&playback_channel->codec);
commit c541d7e29dc0053e6434d053a50454bb8a7121e9
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Sun Nov 2 22:11:58 2014 +0100

    Remove guest side video time-stamping
    
    The multimedia time is defined by the server side monotonic time [1],
    but the drawing time-stamp is done in guest side, so it requires
    synchronization between host and guest. This is expensive, when no audio
    is playing, there is a ~30x/sec wakeup to update the qxl device mmtime,
    and it requires marking dirty the rom region.
    
    Instead, the video timestamping can be done more efficiently on server
    side, without visible drawbacks.
    
    [1] a better timestamp could be the audio time, since audio players are
        usually sync with audio time)
    
    Related to:
    https://bugzilla.redhat.com/show_bug.cgi?id=912763

diff --git a/server/red_dispatcher.c b/server/red_dispatcher.c
index a6ffe7b..d8389bc 100644
--- a/server/red_dispatcher.c
+++ b/server/red_dispatcher.c
@@ -751,15 +751,6 @@ static void qxl_worker_loadvm_commands(QXLWorker *qxl_worker,
     red_dispatcher_loadvm_commands((RedDispatcher*)qxl_worker, ext, count);
 }
 
-void red_dispatcher_set_mm_time(uint32_t mm_time)
-{
-    RedDispatcher *now = dispatchers;
-    while (now) {
-        now->qxl->st->qif->set_mm_time(now->qxl, mm_time);
-        now = now->next;
-    }
-}
-
 static inline int calc_compression_level(void)
 {
     spice_assert(streaming_video != STREAM_VIDEO_INVALID);
diff --git a/server/red_worker.c b/server/red_worker.c
index 9f18495..cbb78a2 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -4195,6 +4195,7 @@ static inline void red_process_drawable(RedWorker *worker, RedDrawable *red_draw
         return;
     }
 
+    red_drawable->mm_time = reds_get_mm_time();
     surface_id = drawable->surface_id;
 
     worker->surfaces[surface_id].refs++;
diff --git a/server/reds-private.h b/server/reds-private.h
index ee09e7c..0bfbf3b 100644
--- a/server/reds-private.h
+++ b/server/reds-private.h
@@ -6,7 +6,6 @@
 #include <spice/protocol.h>
 
 #define MIGRATE_TIMEOUT (1000 * 10) /* 10sec */
-#define MM_TIMER_GRANULARITY_MS (1000 / 30)
 #define MM_TIME_DELTA 400 /*ms*/
 
 typedef struct TicketAuthentication {
@@ -159,7 +158,6 @@ typedef struct RedsState {
     int dispatcher_allows_client_mouse;
     MonitorMode monitor_mode;
     SpiceTimer *mig_timer;
-    SpiceTimer *mm_timer;
 
     int vm_running;
     Ring char_devs_states; /* list of SpiceCharDeviceStateItem */
diff --git a/server/reds.c b/server/reds.c
index 7ecea13..f868cd8 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -2830,7 +2830,6 @@ uint32_t reds_get_mm_time(void)
 
 void reds_enable_mm_timer(void)
 {
-    core->timer_start(reds->mm_timer, MM_TIMER_GRANULARITY_MS);
     reds->mm_timer_enabled = TRUE;
     reds->mm_time_latency = MM_TIME_DELTA;
     reds_send_mm_time();
@@ -2838,16 +2837,9 @@ void reds_enable_mm_timer(void)
 
 void reds_disable_mm_timer(void)
 {
-    core->timer_cancel(reds->mm_timer);
     reds->mm_timer_enabled = FALSE;
 }
 
-static void mm_timer_proc(void *opaque)
-{
-    red_dispatcher_set_mm_time(reds_get_mm_time());
-    core->timer_start(reds->mm_timer, MM_TIMER_GRANULARITY_MS);
-}
-
 static SpiceCharDeviceState *attach_to_red_agent(SpiceCharDeviceInstance *sin)
 {
     VDIPortState *state = &reds->agent_state;
@@ -3271,11 +3263,6 @@ static int do_spice_init(SpiceCoreInterface *core_interface)
     }
 #endif
 
-    if (!(reds->mm_timer = core->timer_add(mm_timer_proc, NULL))) {
-        spice_error("mm timer create failed");
-    }
-    reds_enable_mm_timer();
-
     if (reds_init_net() < 0) {
         goto err;
     }
diff --git a/server/snd_worker.c b/server/snd_worker.c
index 70148b7..77bb3ca 100644
--- a/server/snd_worker.c
+++ b/server/snd_worker.c
@@ -1117,7 +1117,6 @@ SPICE_GNUC_VISIBLE void spice_server_playback_put_samples(SpicePlaybackInstance
         snd_playback_free_frame(playback_channel, playback_channel->pending_frame);
     }
     frame->time = reds_get_mm_time();
-    red_dispatcher_set_mm_time(frame->time);
     playback_channel->pending_frame = frame;
     snd_set_command(&playback_channel->base, SND_PLAYBACK_PCM_MASK);
     snd_playback_send(&playback_channel->base);
diff --git a/server/spice-qxl.h b/server/spice-qxl.h
index ddf599a..31ff742 100644
--- a/server/spice-qxl.h
+++ b/server/spice-qxl.h
@@ -156,7 +156,7 @@ struct QXLInterface {
 
     void (*attache_worker)(QXLInstance *qin, QXLWorker *qxl_worker);
     void (*set_compression_level)(QXLInstance *qin, int level);
-    void (*set_mm_time)(QXLInstance *qin, uint32_t mm_time);
+    void (*set_mm_time)(QXLInstance *qin, uint32_t mm_time) SPICE_GNUC_DEPRECATED;
 
     void (*get_init_info)(QXLInstance *qin, QXLDevInitInfo *info);
     int (*get_command)(QXLInstance *qin, struct QXLCommandExt *cmd);
commit ab12cf414c87e0cc3b43bdc47f57bef837986f3b
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Fri Oct 24 17:46:31 2014 +0200

    build-sys: generate spice-version.h
    
    Editing the hexadecimal value of spice-version and keeping it in sync
    with actual release is a bit tedious. Let's generate it
    automatically (although handling of bumps will need temporarily static
    versions, when 0.12 -> 1.0 for example)

diff --git a/configure.ac b/configure.ac
index 3c81adf..8b731ee 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,6 +18,16 @@ m4_define([SPICE_AGE], [9])
 AC_INIT(spice, [m4_esyscmd(build-aux/git-version-gen .tarball-version)],
         [spice-devel at lists.freedesktop.org], spice)
 
+major=`echo $PACKAGE_VERSION | cut -d. -f1`
+minor=`echo $PACKAGE_VERSION | cut -d. -f2`
+micro=`echo $PACKAGE_VERSION | cut -d. -f3`
+git=`echo $PACKAGE_VERSION | cut -d. -f4`
+if test x"$git" != x ; then
+    micro=$(($micro+1))
+fi
+SPICE_SERVER_VERSION=`printf "0x%02x%02x%02x" $major $minor $micro`
+AC_SUBST(SPICE_SERVER_VERSION)
+
 AC_CONFIG_MACRO_DIR([m4])
 AM_CONFIG_HEADER([config.h])
 AC_CONFIG_AUX_DIR(.)
@@ -510,6 +520,7 @@ AC_OUTPUT([
 Makefile
 spice-server.pc
 server/Makefile
+server/spice-version.h
 server/tests/Makefile
 client/Makefile
 docs/Makefile
diff --git a/server/spice-version.h b/server/spice-version.h
deleted file mode 100644
index b5c8eb0..0000000
--- a/server/spice-version.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- *  Copyright (C) 2009-2014 Red Hat, Inc.
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public
- *  License as published by the Free Software Foundation; either
- *  version 2.1 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef SPICE_VERSION_H_
-#define SPICE_VERSION_H_
-
-#if !defined(SPICE_H_INSIDE) && !defined(SPICE_SERVER_INTERNAL)
-#error "Only spice.h can be included directly."
-#endif
-
-#define SPICE_SERVER_VERSION 0x000c06 /* release 0.12.6 */
-
-#endif /* SPICE_VERSION_H_ */
diff --git a/server/spice-version.h.in b/server/spice-version.h.in
new file mode 100644
index 0000000..69e97e9
--- /dev/null
+++ b/server/spice-version.h.in
@@ -0,0 +1,27 @@
+/*
+ *  Copyright (C) 2009-2014 Red Hat, Inc.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SPICE_VERSION_H_
+#define SPICE_VERSION_H_
+
+#if !defined(SPICE_H_INSIDE) && !defined(SPICE_SERVER_INTERNAL)
+#error "Only spice.h can be included directly."
+#endif
+
+#define SPICE_SERVER_VERSION @SPICE_SERVER_VERSION@
+
+#endif /* SPICE_VERSION_H_ */
commit 6f798ba1f75360e6c66260b0ac2de76efa0a7d1d
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Fri Oct 24 16:59:30 2014 +0200

    Split spice.h
    
    Make it easier to read the Spice server API.

diff --git a/server/Makefile.am b/server/Makefile.am
index 34219c8..f162a18 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -44,7 +44,22 @@ libspice_server_la_LIBADD =						\
 	$(SPICE_NONPKGCONFIG_LIBS)					\
 	$(NULL)
 
+libspice_serverincludedir = $(includedir)/spice-server
+libspice_serverinclude_HEADERS =		\
+	spice-audio.h				\
+	spice-char.h				\
+	spice-core.h				\
+	spice-experimental.h			\
+	spice-input.h				\
+	spice-migration.h			\
+	spice-qxl.h				\
+	spice-server.h				\
+	spice-version.h				\
+	spice.h					\
+	$(NULL)
+
 libspice_server_la_SOURCES =			\
+	$(libspice_serverinclude_HEADERS)	\
 	agent-msg-filter.c			\
 	agent-msg-filter.h			\
 	char_device.c				\
@@ -93,8 +108,6 @@ libspice_server_la_SOURCES =			\
 	reds_sw_canvas.h			\
 	snd_worker.c				\
 	snd_worker.h				\
-	spice-experimental.h			\
-	spice.h					\
 	stat.h					\
 	spicevmc.c				\
 	spice_timer_queue.c			\
@@ -122,12 +135,6 @@ libspice_server_la_SOURCES +=	\
 	$(NULL)
 endif
 
-libspice_serverincludedir = $(includedir)/spice-server
-libspice_serverinclude_HEADERS =		\
-	spice.h					\
-	spice-experimental.h			\
-	$(NULL)
-
 EXTRA_DIST =					\
 	glz_encode_match_tmpl.c			\
 	glz_encode_tmpl.c			\
diff --git a/server/spice-audio.h b/server/spice-audio.h
new file mode 100644
index 0000000..3de4a8d
--- /dev/null
+++ b/server/spice-audio.h
@@ -0,0 +1,96 @@
+/*
+ *  Copyright (C) 2009-2014 Red Hat, Inc.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SPICE_AUDIO_H_
+#define SPICE_AUDIO_H_
+
+#if !defined(SPICE_H_INSIDE) && !defined(SPICE_SERVER_INTERNAL)
+#error "Only spice.h can be included directly."
+#endif
+
+#include "spice-core.h"
+
+/* sound interfaces */
+
+#define SPICE_INTERFACE_PLAYBACK "playback"
+#define SPICE_INTERFACE_PLAYBACK_MAJOR 1
+#define SPICE_INTERFACE_PLAYBACK_MINOR 3
+typedef struct SpicePlaybackInterface SpicePlaybackInterface;
+typedef struct SpicePlaybackInstance SpicePlaybackInstance;
+typedef struct SpicePlaybackState SpicePlaybackState;
+
+enum {
+    SPICE_INTERFACE_AUDIO_FMT_S16 = 1,
+};
+
+#define SPICE_INTERFACE_PLAYBACK_FREQ  44100
+#define SPICE_INTERFACE_PLAYBACK_CHAN  2
+#define SPICE_INTERFACE_PLAYBACK_FMT   SPICE_INTERFACE_AUDIO_FMT_S16
+
+struct SpicePlaybackInterface {
+    SpiceBaseInterface base;
+};
+
+struct SpicePlaybackInstance {
+    SpiceBaseInstance  base;
+    SpicePlaybackState *st;
+};
+
+void spice_server_playback_start(SpicePlaybackInstance *sin);
+void spice_server_playback_stop(SpicePlaybackInstance *sin);
+void spice_server_playback_get_buffer(SpicePlaybackInstance *sin,
+                                      uint32_t **samples, uint32_t *nsamples);
+void spice_server_playback_put_samples(SpicePlaybackInstance *sin,
+                                       uint32_t *samples);
+void spice_server_playback_set_volume(SpicePlaybackInstance *sin,
+                                      uint8_t nchannels, uint16_t *volume);
+void spice_server_playback_set_mute(SpicePlaybackInstance *sin, uint8_t mute);
+
+#define SPICE_INTERFACE_RECORD "record"
+#define SPICE_INTERFACE_RECORD_MAJOR 2
+#define SPICE_INTERFACE_RECORD_MINOR 3
+typedef struct SpiceRecordInterface SpiceRecordInterface;
+typedef struct SpiceRecordInstance SpiceRecordInstance;
+typedef struct SpiceRecordState SpiceRecordState;
+
+#define SPICE_INTERFACE_RECORD_FREQ  44100
+#define SPICE_INTERFACE_RECORD_CHAN  2
+#define SPICE_INTERFACE_RECORD_FMT   SPICE_INTERFACE_AUDIO_FMT_S16
+
+struct SpiceRecordInterface {
+    SpiceBaseInterface base;
+};
+
+struct SpiceRecordInstance {
+    SpiceBaseInstance base;
+    SpiceRecordState  *st;
+};
+
+void spice_server_record_start(SpiceRecordInstance *sin);
+void spice_server_record_stop(SpiceRecordInstance *sin);
+uint32_t spice_server_record_get_samples(SpiceRecordInstance *sin,
+                                         uint32_t *samples, uint32_t bufsize);
+void spice_server_record_set_volume(SpiceRecordInstance *sin,
+                                    uint8_t nchannels, uint16_t *volume);
+void spice_server_record_set_mute(SpiceRecordInstance *sin, uint8_t mute);
+
+uint32_t spice_server_get_best_playback_rate(SpicePlaybackInstance *sin);
+void     spice_server_set_playback_rate(SpicePlaybackInstance *sin, uint32_t frequency);
+uint32_t spice_server_get_best_record_rate(SpiceRecordInstance *sin);
+void     spice_server_set_record_rate(SpiceRecordInstance *sin, uint32_t frequency);
+
+#endif /* SPICE_AUDIO_H_ */
diff --git a/server/spice-char.h b/server/spice-char.h
new file mode 100644
index 0000000..efd685d
--- /dev/null
+++ b/server/spice-char.h
@@ -0,0 +1,61 @@
+/*
+ *  Copyright (C) 2009-2014 Red Hat, Inc.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SPICE_CHAR_H_
+#define SPICE_CHAR_H_
+
+#if !defined(SPICE_H_INSIDE) && !defined(SPICE_SERVER_INTERNAL)
+#error "Only spice.h can be included directly."
+#endif
+
+#include "spice-core.h"
+
+/* char device interfaces */
+
+#define SPICE_INTERFACE_CHAR_DEVICE "char_device"
+#define SPICE_INTERFACE_CHAR_DEVICE_MAJOR 1
+#define SPICE_INTERFACE_CHAR_DEVICE_MINOR 3
+typedef struct SpiceCharDeviceInterface SpiceCharDeviceInterface;
+typedef struct SpiceCharDeviceInstance SpiceCharDeviceInstance;
+typedef struct SpiceCharDeviceState SpiceCharDeviceState;
+
+typedef enum {
+    SPICE_CHAR_DEVICE_NOTIFY_WRITABLE = 1 << 0,
+} spice_char_device_flags;
+
+struct SpiceCharDeviceInterface {
+    SpiceBaseInterface base;
+
+    void (*state)(SpiceCharDeviceInstance *sin, int connected);
+    int (*write)(SpiceCharDeviceInstance *sin, const uint8_t *buf, int len);
+    int (*read)(SpiceCharDeviceInstance *sin, uint8_t *buf, int len);
+    void (*event)(SpiceCharDeviceInstance *sin, uint8_t event);
+    spice_char_device_flags flags;
+};
+
+struct SpiceCharDeviceInstance {
+    SpiceBaseInstance base;
+    const char* subtype;
+    SpiceCharDeviceState *st;
+    const char* portname;
+};
+
+void spice_server_char_device_wakeup(SpiceCharDeviceInstance *sin);
+void spice_server_port_event(SpiceCharDeviceInstance *char_device, uint8_t event);
+const char** spice_server_char_device_recognized_subtypes(void);
+
+#endif /* SPICE_CHAR_H_ */
diff --git a/server/spice-core.h b/server/spice-core.h
new file mode 100644
index 0000000..4d8f2ed
--- /dev/null
+++ b/server/spice-core.h
@@ -0,0 +1,106 @@
+/*
+ *  Copyright (C) 2009-2014 Red Hat, Inc.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SPICE_CORE_H_
+#define SPICE_CORE_H_
+
+#if !defined(SPICE_H_INSIDE) && !defined(SPICE_SERVER_INTERNAL)
+#error "Only spice.h can be included directly."
+#endif
+
+#include <stdint.h>
+#include <sys/socket.h>
+#include <spice/qxl_dev.h>
+#include <spice/vd_agent.h>
+#include <spice/macros.h>
+
+#ifdef SPICE_SERVER_INTERNAL
+#undef SPICE_GNUC_DEPRECATED
+#define SPICE_GNUC_DEPRECATED
+#endif
+
+/* interface base type */
+
+typedef struct SpiceBaseInterface SpiceBaseInterface;
+typedef struct SpiceBaseInstance SpiceBaseInstance;
+
+struct SpiceBaseInterface {
+    const char *type;
+    const char *description;
+    uint32_t major_version;
+    uint32_t minor_version;
+};
+struct SpiceBaseInstance {
+    const SpiceBaseInterface *sif;
+};
+
+/* core interface */
+
+#define SPICE_INTERFACE_CORE "core"
+#define SPICE_INTERFACE_CORE_MAJOR 1
+#define SPICE_INTERFACE_CORE_MINOR 3
+typedef struct SpiceCoreInterface SpiceCoreInterface;
+
+#define SPICE_WATCH_EVENT_READ  (1 << 0)
+#define SPICE_WATCH_EVENT_WRITE (1 << 1)
+
+#define SPICE_CHANNEL_EVENT_CONNECTED     1
+#define SPICE_CHANNEL_EVENT_INITIALIZED   2
+#define SPICE_CHANNEL_EVENT_DISCONNECTED  3
+
+#define SPICE_CHANNEL_EVENT_FLAG_TLS      (1 << 0)
+#define SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT (1 << 1)
+
+typedef struct SpiceWatch SpiceWatch;
+typedef void (*SpiceWatchFunc)(int fd, int event, void *opaque);
+
+typedef struct SpiceTimer SpiceTimer;
+typedef void (*SpiceTimerFunc)(void *opaque);
+
+typedef struct SpiceChannelEventInfo {
+    int connection_id;
+    int type;
+    int id;
+    int flags;
+    /* deprecated, can't hold ipv6 addresses, kept for backward compatibility */
+    struct sockaddr laddr SPICE_GNUC_DEPRECATED;
+    struct sockaddr paddr SPICE_GNUC_DEPRECATED;
+    socklen_t llen SPICE_GNUC_DEPRECATED;
+    socklen_t plen SPICE_GNUC_DEPRECATED;
+    /* should be used if (flags & SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT) */
+    struct sockaddr_storage laddr_ext;
+    struct sockaddr_storage paddr_ext;
+    socklen_t llen_ext, plen_ext;
+} SpiceChannelEventInfo;
+
+struct SpiceCoreInterface {
+    SpiceBaseInterface base;
+
+    SpiceTimer *(*timer_add)(SpiceTimerFunc func, void *opaque);
+    void (*timer_start)(SpiceTimer *timer, uint32_t ms);
+    void (*timer_cancel)(SpiceTimer *timer);
+    void (*timer_remove)(SpiceTimer *timer);
+
+    SpiceWatch *(*watch_add)(int fd, int event_mask, SpiceWatchFunc func, void *opaque);
+    void (*watch_update_mask)(SpiceWatch *watch, int event_mask);
+    void (*watch_remove)(SpiceWatch *watch);
+
+    void (*channel_event)(int event, SpiceChannelEventInfo *info);
+};
+
+
+#endif /* SPICE_CORE_H_ */
diff --git a/server/spice-input.h b/server/spice-input.h
new file mode 100644
index 0000000..dc07c4f
--- /dev/null
+++ b/server/spice-input.h
@@ -0,0 +1,91 @@
+/*
+ *  Copyright (C) 2009-2014 Red Hat, Inc.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SPICE_INPUT_H_
+#define SPICE_INPUT_H_
+
+#if !defined(SPICE_H_INSIDE) && !defined(SPICE_SERVER_INTERNAL)
+#error "Only spice.h can be included directly."
+#endif
+
+#include "spice-core.h"
+
+/* input interfaces */
+
+#define SPICE_INTERFACE_KEYBOARD "keyboard"
+#define SPICE_INTERFACE_KEYBOARD_MAJOR 1
+#define SPICE_INTERFACE_KEYBOARD_MINOR 1
+typedef struct SpiceKbdInterface SpiceKbdInterface;
+typedef struct SpiceKbdInstance SpiceKbdInstance;
+typedef struct SpiceKbdState SpiceKbdState;
+
+struct SpiceKbdInterface {
+    SpiceBaseInterface base;
+
+    void (*push_scan_freg)(SpiceKbdInstance *sin, uint8_t frag);
+    uint8_t (*get_leds)(SpiceKbdInstance *sin);
+};
+
+struct SpiceKbdInstance {
+    SpiceBaseInstance base;
+    SpiceKbdState     *st;
+};
+
+int spice_server_kbd_leds(SpiceKbdInstance *sin, int leds);
+
+#define SPICE_INTERFACE_MOUSE "mouse"
+#define SPICE_INTERFACE_MOUSE_MAJOR 1
+#define SPICE_INTERFACE_MOUSE_MINOR 1
+typedef struct SpiceMouseInterface SpiceMouseInterface;
+typedef struct SpiceMouseInstance SpiceMouseInstance;
+typedef struct SpiceMouseState SpiceMouseState;
+
+struct SpiceMouseInterface {
+    SpiceBaseInterface base;
+
+    void (*motion)(SpiceMouseInstance *sin, int dx, int dy, int dz,
+                   uint32_t buttons_state);
+    void (*buttons)(SpiceMouseInstance *sin, uint32_t buttons_state);
+};
+
+struct SpiceMouseInstance {
+    SpiceBaseInstance base;
+    SpiceMouseState   *st;
+};
+
+#define SPICE_INTERFACE_TABLET "tablet"
+#define SPICE_INTERFACE_TABLET_MAJOR 1
+#define SPICE_INTERFACE_TABLET_MINOR 1
+typedef struct SpiceTabletInterface SpiceTabletInterface;
+typedef struct SpiceTabletInstance SpiceTabletInstance;
+typedef struct SpiceTabletState SpiceTabletState;
+
+struct SpiceTabletInterface {
+    SpiceBaseInterface base;
+
+    void (*set_logical_size)(SpiceTabletInstance* tablet, int width, int height);
+    void (*position)(SpiceTabletInstance* tablet, int x, int y, uint32_t buttons_state);
+    void (*wheel)(SpiceTabletInstance* tablet, int wheel_moution, uint32_t buttons_state);
+    void (*buttons)(SpiceTabletInstance* tablet, uint32_t buttons_state);
+};
+
+struct SpiceTabletInstance {
+    SpiceBaseInstance base;
+    SpiceTabletState  *st;
+};
+
+#endif /* SPICE_INPUT_H_ */
diff --git a/server/spice-migration.h b/server/spice-migration.h
new file mode 100644
index 0000000..e2fc92e
--- /dev/null
+++ b/server/spice-migration.h
@@ -0,0 +1,64 @@
+/*
+ *  Copyright (C) 2009-2014 Red Hat, Inc.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SPICE_MIGRATION_H_
+#define SPICE_MIGRATION_H_
+
+#if !defined(SPICE_H_INSIDE) && !defined(SPICE_SERVER_INTERNAL)
+#error "Only spice.h can be included directly."
+#endif
+
+#include "spice-core.h"
+
+/* migration interface */
+#define SPICE_INTERFACE_MIGRATION "migration"
+#define SPICE_INTERFACE_MIGRATION_MAJOR 1
+#define SPICE_INTERFACE_MIGRATION_MINOR 1
+typedef struct SpiceMigrateInterface SpiceMigrateInterface;
+typedef struct SpiceMigrateInstance SpiceMigrateInstance;
+typedef struct SpiceMigrateState SpiceMigrateState;
+
+struct SpiceMigrateInterface {
+    SpiceBaseInterface base;
+    void (*migrate_connect_complete)(SpiceMigrateInstance *sin);
+    void (*migrate_end_complete)(SpiceMigrateInstance *sin);
+};
+
+struct SpiceMigrateInstance {
+    SpiceBaseInstance base;
+    SpiceMigrateState *st;
+};
+
+/* spice switch-host client migration */
+int spice_server_migrate_info(SpiceServer *s, const char* dest,
+                              int port, int secure_port,
+                              const char* cert_subject);
+int spice_server_migrate_switch(SpiceServer *s);
+
+/* server status */
+int spice_server_get_num_clients(SpiceServer *s);
+
+/* spice (semi-)seamless client migration */
+int spice_server_migrate_connect(SpiceServer *s, const char* dest,
+                                 int port, int secure_port,
+                                 const char* cert_subject);
+int spice_server_migrate_start(SpiceServer *s);
+int spice_server_migrate_end(SpiceServer *s, int completed);
+
+void spice_server_set_seamless_migration(SpiceServer *s, int enable);
+
+#endif /* SPICE_MIGRATION_H_ */
diff --git a/server/spice-qxl.h b/server/spice-qxl.h
new file mode 100644
index 0000000..ddf599a
--- /dev/null
+++ b/server/spice-qxl.h
@@ -0,0 +1,189 @@
+/*
+ *  Copyright (C) 2014 Red Hat, Inc.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SPICE_QXL_H_
+#define SPICE_QXL_H_
+
+#if !defined(SPICE_H_INSIDE) && !defined(SPICE_SERVER_INTERNAL)
+#error "Only spice.h can be included directly."
+#endif
+
+#include "spice-core.h"
+
+/* qxl interface */
+
+#define SPICE_INTERFACE_QXL "qxl"
+#define SPICE_INTERFACE_QXL_MAJOR 3
+#define SPICE_INTERFACE_QXL_MINOR 3
+
+typedef struct QXLInterface QXLInterface;
+typedef struct QXLInstance QXLInstance;
+typedef struct QXLState QXLState;
+typedef struct QXLWorker QXLWorker;
+typedef struct QXLDevMemSlot QXLDevMemSlot;
+typedef struct QXLDevSurfaceCreate QXLDevSurfaceCreate;
+
+struct QXLWorker {
+    uint32_t minor_version;
+    uint32_t major_version;
+    /* These calls are deprecated. Please use the spice_qxl_* calls instead */
+    void (*wakeup)(QXLWorker *worker) SPICE_GNUC_DEPRECATED;
+    void (*oom)(QXLWorker *worker) SPICE_GNUC_DEPRECATED;
+    void (*start)(QXLWorker *worker) SPICE_GNUC_DEPRECATED;
+    void (*stop)(QXLWorker *worker) SPICE_GNUC_DEPRECATED;
+    void (*update_area)(QXLWorker *qxl_worker, uint32_t surface_id,
+                       struct QXLRect *area, struct QXLRect *dirty_rects,
+                       uint32_t num_dirty_rects, uint32_t clear_dirty_region) SPICE_GNUC_DEPRECATED;
+    void (*add_memslot)(QXLWorker *worker, QXLDevMemSlot *slot) SPICE_GNUC_DEPRECATED;
+    void (*del_memslot)(QXLWorker *worker, uint32_t slot_group_id, uint32_t slot_id) SPICE_GNUC_DEPRECATED;
+    void (*reset_memslots)(QXLWorker *worker) SPICE_GNUC_DEPRECATED;
+    void (*destroy_surfaces)(QXLWorker *worker) SPICE_GNUC_DEPRECATED;
+    void (*destroy_primary_surface)(QXLWorker *worker, uint32_t surface_id) SPICE_GNUC_DEPRECATED;
+    void (*create_primary_surface)(QXLWorker *worker, uint32_t surface_id,
+                                   QXLDevSurfaceCreate *surface) SPICE_GNUC_DEPRECATED;
+    void (*reset_image_cache)(QXLWorker *worker) SPICE_GNUC_DEPRECATED;
+    void (*reset_cursor)(QXLWorker *worker) SPICE_GNUC_DEPRECATED;
+    void (*destroy_surface_wait)(QXLWorker *worker, uint32_t surface_id) SPICE_GNUC_DEPRECATED;
+    void (*loadvm_commands)(QXLWorker *worker, struct QXLCommandExt *ext, uint32_t count) SPICE_GNUC_DEPRECATED;
+};
+
+void spice_qxl_wakeup(QXLInstance *instance);
+void spice_qxl_oom(QXLInstance *instance);
+/* deprecated since 0.11.2, spice_server_vm_start replaces it */
+void spice_qxl_start(QXLInstance *instance) SPICE_GNUC_DEPRECATED;
+/* deprecated since 0.11.2 spice_server_vm_stop replaces it */
+void spice_qxl_stop(QXLInstance *instance) SPICE_GNUC_DEPRECATED;
+void spice_qxl_update_area(QXLInstance *instance, uint32_t surface_id,
+                   struct QXLRect *area, struct QXLRect *dirty_rects,
+                   uint32_t num_dirty_rects, uint32_t clear_dirty_region);
+void spice_qxl_add_memslot(QXLInstance *instance, QXLDevMemSlot *slot);
+void spice_qxl_del_memslot(QXLInstance *instance, uint32_t slot_group_id, uint32_t slot_id);
+void spice_qxl_reset_memslots(QXLInstance *instance);
+void spice_qxl_destroy_surfaces(QXLInstance *instance);
+void spice_qxl_destroy_primary_surface(QXLInstance *instance, uint32_t surface_id);
+void spice_qxl_create_primary_surface(QXLInstance *instance, uint32_t surface_id,
+                               QXLDevSurfaceCreate *surface);
+void spice_qxl_reset_image_cache(QXLInstance *instance);
+void spice_qxl_reset_cursor(QXLInstance *instance);
+void spice_qxl_destroy_surface_wait(QXLInstance *instance, uint32_t surface_id);
+void spice_qxl_loadvm_commands(QXLInstance *instance, struct QXLCommandExt *ext, uint32_t count);
+/* async versions of commands. when complete spice calls async_complete */
+void spice_qxl_update_area_async(QXLInstance *instance, uint32_t surface_id, QXLRect *qxl_area,
+                                 uint32_t clear_dirty_region, uint64_t cookie);
+void spice_qxl_add_memslot_async(QXLInstance *instance, QXLDevMemSlot *slot, uint64_t cookie);
+void spice_qxl_destroy_surfaces_async(QXLInstance *instance, uint64_t cookie);
+void spice_qxl_destroy_primary_surface_async(QXLInstance *instance, uint32_t surface_id, uint64_t cookie);
+void spice_qxl_create_primary_surface_async(QXLInstance *instance, uint32_t surface_id,
+                                QXLDevSurfaceCreate *surface, uint64_t cookie);
+void spice_qxl_destroy_surface_async(QXLInstance *instance, uint32_t surface_id, uint64_t cookie);
+/* suspend and resolution change on windows drivers */
+void spice_qxl_flush_surfaces_async(QXLInstance *instance, uint64_t cookie);
+/* since spice 0.12.0 */
+void spice_qxl_monitors_config_async(QXLInstance *instance, QXLPHYSICAL monitors_config,
+                                     int group_id, uint64_t cookie);
+/* since spice 0.12.3 */
+void spice_qxl_driver_unload(QXLInstance *instance);
+
+typedef struct QXLDrawArea {
+    uint8_t *buf;
+    uint32_t size;
+    uint8_t *line_0;
+    uint32_t width;
+    uint32_t heigth;
+    int stride;
+} QXLDrawArea;
+
+typedef struct QXLDevInfo {
+    uint32_t x_res;
+    uint32_t y_res;
+    uint32_t bits;
+    uint32_t use_hardware_cursor;
+
+    QXLDrawArea draw_area;
+
+    uint32_t ram_size;
+} QXLDevInfo;
+
+typedef struct QXLDevInitInfo {
+    uint32_t num_memslots_groups;
+    uint32_t num_memslots;
+    uint8_t memslot_gen_bits;
+    uint8_t memslot_id_bits;
+    uint32_t qxl_ram_size;
+    uint8_t internal_groupslot_id;
+    uint32_t n_surfaces;
+} QXLDevInitInfo;
+
+struct QXLDevMemSlot {
+    uint32_t slot_group_id;
+    uint32_t slot_id;
+    uint32_t generation;
+    unsigned long virt_start;
+    unsigned long virt_end;
+    uint64_t addr_delta;
+    uint32_t qxl_ram_size;
+};
+
+struct QXLDevSurfaceCreate {
+    uint32_t width;
+    uint32_t height;
+    int32_t stride;
+    uint32_t format;
+    uint32_t position;
+    uint32_t mouse_mode;
+    uint32_t flags;
+    uint32_t type;
+    uint64_t mem;
+    uint32_t group_id;
+};
+
+struct QXLInterface {
+    SpiceBaseInterface base;
+
+    void (*attache_worker)(QXLInstance *qin, QXLWorker *qxl_worker);
+    void (*set_compression_level)(QXLInstance *qin, int level);
+    void (*set_mm_time)(QXLInstance *qin, uint32_t mm_time);
+
+    void (*get_init_info)(QXLInstance *qin, QXLDevInitInfo *info);
+    int (*get_command)(QXLInstance *qin, struct QXLCommandExt *cmd);
+    int (*req_cmd_notification)(QXLInstance *qin);
+    void (*release_resource)(QXLInstance *qin, struct QXLReleaseInfoExt release_info);
+    int (*get_cursor_command)(QXLInstance *qin, struct QXLCommandExt *cmd);
+    int (*req_cursor_notification)(QXLInstance *qin);
+    void (*notify_update)(QXLInstance *qin, uint32_t update_id);
+    int (*flush_resources)(QXLInstance *qin);
+    void (*async_complete)(QXLInstance *qin, uint64_t cookie);
+    void (*update_area_complete)(QXLInstance *qin, uint32_t surface_id,
+                                 struct QXLRect *updated_rects,
+                                 uint32_t num_updated_rects);
+    void (*set_client_capabilities)(QXLInstance *qin,
+                                    uint8_t client_present,
+                                    uint8_t caps[58]);
+    /* returns 1 if the interface is supported, 0 otherwise.
+     * if monitors_config is NULL nothing is done except reporting the
+     * return code. */
+    int (*client_monitors_config)(QXLInstance *qin,
+                                  VDAgentMonitorsConfig *monitors_config);
+};
+
+struct QXLInstance {
+    SpiceBaseInstance  base;
+    int                id;
+    QXLState           *st;
+};
+
+#endif /* SPICE_QXL_H_ */
diff --git a/server/spice-server.h b/server/spice-server.h
new file mode 100644
index 0000000..ac63a94
--- /dev/null
+++ b/server/spice-server.h
@@ -0,0 +1,124 @@
+/*
+ *  Copyright (C) 2009-2014 Red Hat, Inc.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SPICE_SERVER_H_
+#define SPICE_SERVER_H_
+
+#if !defined(SPICE_H_INSIDE) && !defined(SPICE_SERVER_INTERNAL)
+#error "Only spice.h can be included directly."
+#endif
+
+/* spice server setup */
+
+/* Don't use features incompatible with a specific spice
+   version, so that migration to/from that version works. */
+typedef enum {
+    SPICE_COMPAT_VERSION_0_4 = 0,
+    SPICE_COMPAT_VERSION_0_6 = 1,
+} spice_compat_version_t;
+
+#define SPICE_COMPAT_VERSION_CURRENT SPICE_COMPAT_VERSION_0_6
+
+spice_compat_version_t spice_get_current_compat_version(void);
+
+typedef struct RedsState SpiceServer;
+SpiceServer *spice_server_new(void);
+int spice_server_init(SpiceServer *s, SpiceCoreInterface *core);
+void spice_server_destroy(SpiceServer *s);
+
+#define SPICE_ADDR_FLAG_IPV4_ONLY (1 << 0)
+#define SPICE_ADDR_FLAG_IPV6_ONLY (1 << 1)
+
+int spice_server_set_compat_version(SpiceServer *s,
+                                    spice_compat_version_t version);
+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);
+int spice_server_set_ticket(SpiceServer *s, const char *passwd, int lifetime,
+                            int fail_if_connected, int disconnect_if_connected);
+int spice_server_set_tls(SpiceServer *s, int port,
+                         const char *ca_cert_file, const char *certs_file,
+                         const char *private_key_file, const char *key_passwd,
+                         const char *dh_key_file, const char *ciphersuite);
+
+int spice_server_add_client(SpiceServer *s, int socket, int skip_auth);
+int spice_server_add_ssl_client(SpiceServer *s, int socket, int skip_auth);
+
+int spice_server_add_interface(SpiceServer *s,
+                               SpiceBaseInstance *sin);
+int spice_server_remove_interface(SpiceBaseInstance *sin);
+
+typedef enum {
+    SPICE_IMAGE_COMPRESS_INVALID  = 0,
+    SPICE_IMAGE_COMPRESS_OFF      = 1,
+    SPICE_IMAGE_COMPRESS_AUTO_GLZ = 2,
+    SPICE_IMAGE_COMPRESS_AUTO_LZ  = 3,
+    SPICE_IMAGE_COMPRESS_QUIC     = 4,
+    SPICE_IMAGE_COMPRESS_GLZ      = 5,
+    SPICE_IMAGE_COMPRESS_LZ       = 6,
+} spice_image_compression_t;
+
+int spice_server_set_image_compression(SpiceServer *s,
+                                       spice_image_compression_t comp);
+spice_image_compression_t spice_server_get_image_compression(SpiceServer *s);
+
+typedef enum {
+    SPICE_WAN_COMPRESSION_INVALID,
+    SPICE_WAN_COMPRESSION_AUTO,
+    SPICE_WAN_COMPRESSION_ALWAYS,
+    SPICE_WAN_COMPRESSION_NEVER,
+} spice_wan_compression_t;
+
+int spice_server_set_jpeg_compression(SpiceServer *s, spice_wan_compression_t comp);
+int spice_server_set_zlib_glz_compression(SpiceServer *s, spice_wan_compression_t comp);
+
+#define SPICE_CHANNEL_SECURITY_NONE (1 << 0)
+#define SPICE_CHANNEL_SECURITY_SSL (1 << 1)
+
+int spice_server_set_channel_security(SpiceServer *s, const char *channel, int security);
+
+int spice_server_add_renderer(SpiceServer *s, const char *name);
+
+enum {
+    SPICE_STREAM_VIDEO_INVALID,
+    SPICE_STREAM_VIDEO_OFF,
+    SPICE_STREAM_VIDEO_ALL,
+    SPICE_STREAM_VIDEO_FILTER
+};
+
+int spice_server_set_streaming_video(SpiceServer *s, int value);
+int spice_server_set_playback_compression(SpiceServer *s, int enable);
+int spice_server_set_agent_mouse(SpiceServer *s, int enable);
+int spice_server_set_agent_copypaste(SpiceServer *s, int enable);
+int spice_server_set_agent_file_xfer(SpiceServer *s, int enable);
+
+int spice_server_get_sock_info(SpiceServer *s, struct sockaddr *sa, socklen_t *salen);
+int spice_server_get_peer_info(SpiceServer *s, struct sockaddr *sa, socklen_t *salen);
+
+int spice_server_is_server_mouse(SpiceServer *s);
+
+void spice_server_set_name(SpiceServer *s, const char *name);
+void spice_server_set_uuid(SpiceServer *s, const uint8_t uuid[16]);
+
+void spice_server_vm_start(SpiceServer *s);
+void spice_server_vm_stop(SpiceServer *s);
+
+#endif /* SPICE_SERVER_H_ */
diff --git a/server/spice-version.h b/server/spice-version.h
new file mode 100644
index 0000000..b5c8eb0
--- /dev/null
+++ b/server/spice-version.h
@@ -0,0 +1,27 @@
+/*
+ *  Copyright (C) 2009-2014 Red Hat, Inc.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SPICE_VERSION_H_
+#define SPICE_VERSION_H_
+
+#if !defined(SPICE_H_INSIDE) && !defined(SPICE_SERVER_INTERNAL)
+#error "Only spice.h can be included directly."
+#endif
+
+#define SPICE_SERVER_VERSION 0x000c06 /* release 0.12.6 */
+
+#endif /* SPICE_VERSION_H_ */
diff --git a/server/spice.h b/server/spice.h
index ca167ea..bd533b3 100644
--- a/server/spice.h
+++ b/server/spice.h
@@ -1,567 +1,34 @@
 /*
-   Copyright (C) 2009 Red Hat, Inc.
-
-   This library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   This library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with this library; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef _H_SPICE
-#define _H_SPICE
-
-#include <stdint.h>
-#include <sys/socket.h>
-#include <spice/qxl_dev.h>
-#include <spice/vd_agent.h>
-#include <spice/macros.h>
-
-#define SPICE_SERVER_VERSION 0x000c06 /* release 0.12.6 */
-
-#ifdef SPICE_SERVER_INTERNAL
-#undef SPICE_GNUC_DEPRECATED
-#define SPICE_GNUC_DEPRECATED
-#endif
-
-/* interface base type */
-
-typedef struct SpiceBaseInterface SpiceBaseInterface;
-typedef struct SpiceBaseInstance SpiceBaseInstance;
-
-struct SpiceBaseInterface {
-    const char *type;
-    const char *description;
-    uint32_t major_version;
-    uint32_t minor_version;
-};
-struct SpiceBaseInstance {
-    const SpiceBaseInterface *sif;
-};
-
-/* core interface */
-
-#define SPICE_INTERFACE_CORE "core"
-#define SPICE_INTERFACE_CORE_MAJOR 1
-#define SPICE_INTERFACE_CORE_MINOR 3
-typedef struct SpiceCoreInterface SpiceCoreInterface;
-
-#define SPICE_WATCH_EVENT_READ  (1 << 0)
-#define SPICE_WATCH_EVENT_WRITE (1 << 1)
-
-#define SPICE_CHANNEL_EVENT_CONNECTED     1
-#define SPICE_CHANNEL_EVENT_INITIALIZED   2
-#define SPICE_CHANNEL_EVENT_DISCONNECTED  3
-
-#define SPICE_CHANNEL_EVENT_FLAG_TLS      (1 << 0)
-#define SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT (1 << 1)
-
-typedef struct SpiceWatch SpiceWatch;
-typedef void (*SpiceWatchFunc)(int fd, int event, void *opaque);
-
-typedef struct SpiceTimer SpiceTimer;
-typedef void (*SpiceTimerFunc)(void *opaque);
-
-typedef struct SpiceChannelEventInfo {
-    int connection_id;
-    int type;
-    int id;
-    int flags;
-    /* deprecated, can't hold ipv6 addresses, kept for backward compatibility */
-    struct sockaddr laddr SPICE_GNUC_DEPRECATED;
-    struct sockaddr paddr SPICE_GNUC_DEPRECATED;
-    socklen_t llen SPICE_GNUC_DEPRECATED;
-    socklen_t plen SPICE_GNUC_DEPRECATED;
-    /* should be used if (flags & SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT) */
-    struct sockaddr_storage laddr_ext;
-    struct sockaddr_storage paddr_ext;
-    socklen_t llen_ext, plen_ext;
-} SpiceChannelEventInfo;
-
-struct SpiceCoreInterface {
-    SpiceBaseInterface base;
-
-    SpiceTimer *(*timer_add)(SpiceTimerFunc func, void *opaque);
-    void (*timer_start)(SpiceTimer *timer, uint32_t ms);
-    void (*timer_cancel)(SpiceTimer *timer);
-    void (*timer_remove)(SpiceTimer *timer);
-
-    SpiceWatch *(*watch_add)(int fd, int event_mask, SpiceWatchFunc func, void *opaque);
-    void (*watch_update_mask)(SpiceWatch *watch, int event_mask);
-    void (*watch_remove)(SpiceWatch *watch);
-
-    void (*channel_event)(int event, SpiceChannelEventInfo *info);
-};
-
-/* qxl interface */
-
-#define SPICE_INTERFACE_QXL "qxl"
-#define SPICE_INTERFACE_QXL_MAJOR 3
-#define SPICE_INTERFACE_QXL_MINOR 3
-typedef struct QXLInterface QXLInterface;
-typedef struct QXLInstance QXLInstance;
-typedef struct QXLState QXLState;
-typedef struct QXLWorker QXLWorker;
-typedef struct QXLDevMemSlot QXLDevMemSlot;
-typedef struct QXLDevSurfaceCreate QXLDevSurfaceCreate;
-
-struct QXLWorker {
-    uint32_t minor_version;
-    uint32_t major_version;
-    /* These calls are deprecated. Please use the spice_qxl_* calls instead */
-    void (*wakeup)(QXLWorker *worker) SPICE_GNUC_DEPRECATED;
-    void (*oom)(QXLWorker *worker) SPICE_GNUC_DEPRECATED;
-    void (*start)(QXLWorker *worker) SPICE_GNUC_DEPRECATED;
-    void (*stop)(QXLWorker *worker) SPICE_GNUC_DEPRECATED;
-    void (*update_area)(QXLWorker *qxl_worker, uint32_t surface_id,
-                       struct QXLRect *area, struct QXLRect *dirty_rects,
-                       uint32_t num_dirty_rects, uint32_t clear_dirty_region) SPICE_GNUC_DEPRECATED;
-    void (*add_memslot)(QXLWorker *worker, QXLDevMemSlot *slot) SPICE_GNUC_DEPRECATED;
-    void (*del_memslot)(QXLWorker *worker, uint32_t slot_group_id, uint32_t slot_id) SPICE_GNUC_DEPRECATED;
-    void (*reset_memslots)(QXLWorker *worker) SPICE_GNUC_DEPRECATED;
-    void (*destroy_surfaces)(QXLWorker *worker) SPICE_GNUC_DEPRECATED;
-    void (*destroy_primary_surface)(QXLWorker *worker, uint32_t surface_id) SPICE_GNUC_DEPRECATED;
-    void (*create_primary_surface)(QXLWorker *worker, uint32_t surface_id,
-                                   QXLDevSurfaceCreate *surface) SPICE_GNUC_DEPRECATED;
-    void (*reset_image_cache)(QXLWorker *worker) SPICE_GNUC_DEPRECATED;
-    void (*reset_cursor)(QXLWorker *worker) SPICE_GNUC_DEPRECATED;
-    void (*destroy_surface_wait)(QXLWorker *worker, uint32_t surface_id) SPICE_GNUC_DEPRECATED;
-    void (*loadvm_commands)(QXLWorker *worker, struct QXLCommandExt *ext, uint32_t count) SPICE_GNUC_DEPRECATED;
-};
-
-void spice_qxl_wakeup(QXLInstance *instance);
-void spice_qxl_oom(QXLInstance *instance);
-/* deprecated since 0.11.2, spice_server_vm_start replaces it */
-void spice_qxl_start(QXLInstance *instance) SPICE_GNUC_DEPRECATED;
-/* deprecated since 0.11.2 spice_server_vm_stop replaces it */
-void spice_qxl_stop(QXLInstance *instance) SPICE_GNUC_DEPRECATED;
-void spice_qxl_update_area(QXLInstance *instance, uint32_t surface_id,
-                   struct QXLRect *area, struct QXLRect *dirty_rects,
-                   uint32_t num_dirty_rects, uint32_t clear_dirty_region);
-void spice_qxl_add_memslot(QXLInstance *instance, QXLDevMemSlot *slot);
-void spice_qxl_del_memslot(QXLInstance *instance, uint32_t slot_group_id, uint32_t slot_id);
-void spice_qxl_reset_memslots(QXLInstance *instance);
-void spice_qxl_destroy_surfaces(QXLInstance *instance);
-void spice_qxl_destroy_primary_surface(QXLInstance *instance, uint32_t surface_id);
-void spice_qxl_create_primary_surface(QXLInstance *instance, uint32_t surface_id,
-                               QXLDevSurfaceCreate *surface);
-void spice_qxl_reset_image_cache(QXLInstance *instance);
-void spice_qxl_reset_cursor(QXLInstance *instance);
-void spice_qxl_destroy_surface_wait(QXLInstance *instance, uint32_t surface_id);
-void spice_qxl_loadvm_commands(QXLInstance *instance, struct QXLCommandExt *ext, uint32_t count);
-/* async versions of commands. when complete spice calls async_complete */
-void spice_qxl_update_area_async(QXLInstance *instance, uint32_t surface_id, QXLRect *qxl_area,
-                                 uint32_t clear_dirty_region, uint64_t cookie);
-void spice_qxl_add_memslot_async(QXLInstance *instance, QXLDevMemSlot *slot, uint64_t cookie);
-void spice_qxl_destroy_surfaces_async(QXLInstance *instance, uint64_t cookie);
-void spice_qxl_destroy_primary_surface_async(QXLInstance *instance, uint32_t surface_id, uint64_t cookie);
-void spice_qxl_create_primary_surface_async(QXLInstance *instance, uint32_t surface_id,
-                                QXLDevSurfaceCreate *surface, uint64_t cookie);
-void spice_qxl_destroy_surface_async(QXLInstance *instance, uint32_t surface_id, uint64_t cookie);
-/* suspend and resolution change on windows drivers */
-void spice_qxl_flush_surfaces_async(QXLInstance *instance, uint64_t cookie);
-/* since spice 0.12.0 */
-void spice_qxl_monitors_config_async(QXLInstance *instance, QXLPHYSICAL monitors_config,
-                                     int group_id, uint64_t cookie);
-/* since spice 0.12.3 */
-void spice_qxl_driver_unload(QXLInstance *instance);
-
-typedef struct QXLDrawArea {
-    uint8_t *buf;
-    uint32_t size;
-    uint8_t *line_0;
-    uint32_t width;
-    uint32_t heigth;
-    int stride;
-} QXLDrawArea;
-
-typedef struct QXLDevInfo {
-    uint32_t x_res;
-    uint32_t y_res;
-    uint32_t bits;
-    uint32_t use_hardware_cursor;
-
-    QXLDrawArea draw_area;
-
-    uint32_t ram_size;
-} QXLDevInfo;
-
-typedef struct QXLDevInitInfo {
-    uint32_t num_memslots_groups;
-    uint32_t num_memslots;
-    uint8_t memslot_gen_bits;
-    uint8_t memslot_id_bits;
-    uint32_t qxl_ram_size;
-    uint8_t internal_groupslot_id;
-    uint32_t n_surfaces;
-} QXLDevInitInfo;
-
-struct QXLDevMemSlot {
-    uint32_t slot_group_id;
-    uint32_t slot_id;
-    uint32_t generation;
-    unsigned long virt_start;
-    unsigned long virt_end;
-    uint64_t addr_delta;
-    uint32_t qxl_ram_size;
-};
-
-struct QXLDevSurfaceCreate {
-    uint32_t width;
-    uint32_t height;
-    int32_t stride;
-    uint32_t format;
-    uint32_t position;
-    uint32_t mouse_mode;
-    uint32_t flags;
-    uint32_t type;
-    uint64_t mem;
-    uint32_t group_id;
-};
-
-struct QXLInterface {
-    SpiceBaseInterface base;
-
-    void (*attache_worker)(QXLInstance *qin, QXLWorker *qxl_worker);
-    void (*set_compression_level)(QXLInstance *qin, int level);
-    void (*set_mm_time)(QXLInstance *qin, uint32_t mm_time);
-
-    void (*get_init_info)(QXLInstance *qin, QXLDevInitInfo *info);
-    int (*get_command)(QXLInstance *qin, struct QXLCommandExt *cmd);
-    int (*req_cmd_notification)(QXLInstance *qin);
-    void (*release_resource)(QXLInstance *qin, struct QXLReleaseInfoExt release_info);
-    int (*get_cursor_command)(QXLInstance *qin, struct QXLCommandExt *cmd);
-    int (*req_cursor_notification)(QXLInstance *qin);
-    void (*notify_update)(QXLInstance *qin, uint32_t update_id);
-    int (*flush_resources)(QXLInstance *qin);
-    void (*async_complete)(QXLInstance *qin, uint64_t cookie);
-    void (*update_area_complete)(QXLInstance *qin, uint32_t surface_id,
-                                 struct QXLRect *updated_rects,
-                                 uint32_t num_updated_rects);
-    void (*set_client_capabilities)(QXLInstance *qin,
-                                    uint8_t client_present,
-                                    uint8_t caps[58]);
-    /* returns 1 if the interface is supported, 0 otherwise.
-     * if monitors_config is NULL nothing is done except reporting the
-     * return code. */
-    int (*client_monitors_config)(QXLInstance *qin,
-                                  VDAgentMonitorsConfig *monitors_config);
-};
-
-struct QXLInstance {
-    SpiceBaseInstance  base;
-    int                id;
-    QXLState           *st;
-};
-
-/* input interfaces */
-
-#define SPICE_INTERFACE_KEYBOARD "keyboard"
-#define SPICE_INTERFACE_KEYBOARD_MAJOR 1
-#define SPICE_INTERFACE_KEYBOARD_MINOR 1
-typedef struct SpiceKbdInterface SpiceKbdInterface;
-typedef struct SpiceKbdInstance SpiceKbdInstance;
-typedef struct SpiceKbdState SpiceKbdState;
-
-struct SpiceKbdInterface {
-    SpiceBaseInterface base;
-
-    void (*push_scan_freg)(SpiceKbdInstance *sin, uint8_t frag);
-    uint8_t (*get_leds)(SpiceKbdInstance *sin);
-};
-
-struct SpiceKbdInstance {
-    SpiceBaseInstance base;
-    SpiceKbdState     *st;
-};
-
-int spice_server_kbd_leds(SpiceKbdInstance *sin, int leds);
-
-#define SPICE_INTERFACE_MOUSE "mouse"
-#define SPICE_INTERFACE_MOUSE_MAJOR 1
-#define SPICE_INTERFACE_MOUSE_MINOR 1
-typedef struct SpiceMouseInterface SpiceMouseInterface;
-typedef struct SpiceMouseInstance SpiceMouseInstance;
-typedef struct SpiceMouseState SpiceMouseState;
-
-struct SpiceMouseInterface {
-    SpiceBaseInterface base;
-
-    void (*motion)(SpiceMouseInstance *sin, int dx, int dy, int dz,
-                   uint32_t buttons_state);
-    void (*buttons)(SpiceMouseInstance *sin, uint32_t buttons_state);
-};
-
-struct SpiceMouseInstance {
-    SpiceBaseInstance base;
-    SpiceMouseState   *st;
-};
-
-#define SPICE_INTERFACE_TABLET "tablet"
-#define SPICE_INTERFACE_TABLET_MAJOR 1
-#define SPICE_INTERFACE_TABLET_MINOR 1
-typedef struct SpiceTabletInterface SpiceTabletInterface;
-typedef struct SpiceTabletInstance SpiceTabletInstance;
-typedef struct SpiceTabletState SpiceTabletState;
-
-struct SpiceTabletInterface {
-    SpiceBaseInterface base;
-
-    void (*set_logical_size)(SpiceTabletInstance* tablet, int width, int height);
-    void (*position)(SpiceTabletInstance* tablet, int x, int y, uint32_t buttons_state);
-    void (*wheel)(SpiceTabletInstance* tablet, int wheel_moution, uint32_t buttons_state);
-    void (*buttons)(SpiceTabletInstance* tablet, uint32_t buttons_state);
-};
-
-struct SpiceTabletInstance {
-    SpiceBaseInstance base;
-    SpiceTabletState  *st;
-};
-
-/* sound interfaces */
-
-#define SPICE_INTERFACE_PLAYBACK "playback"
-#define SPICE_INTERFACE_PLAYBACK_MAJOR 1
-#define SPICE_INTERFACE_PLAYBACK_MINOR 3
-typedef struct SpicePlaybackInterface SpicePlaybackInterface;
-typedef struct SpicePlaybackInstance SpicePlaybackInstance;
-typedef struct SpicePlaybackState SpicePlaybackState;
-
-enum {
-    SPICE_INTERFACE_AUDIO_FMT_S16 = 1,
-};
-
-#define SPICE_INTERFACE_PLAYBACK_FREQ  44100
-#define SPICE_INTERFACE_PLAYBACK_CHAN  2
-#define SPICE_INTERFACE_PLAYBACK_FMT   SPICE_INTERFACE_AUDIO_FMT_S16
-
-struct SpicePlaybackInterface {
-    SpiceBaseInterface base;
-};
-
-struct SpicePlaybackInstance {
-    SpiceBaseInstance  base;
-    SpicePlaybackState *st;
-};
-
-void spice_server_playback_start(SpicePlaybackInstance *sin);
-void spice_server_playback_stop(SpicePlaybackInstance *sin);
-void spice_server_playback_get_buffer(SpicePlaybackInstance *sin,
-                                      uint32_t **samples, uint32_t *nsamples);
-void spice_server_playback_put_samples(SpicePlaybackInstance *sin,
-                                       uint32_t *samples);
-void spice_server_playback_set_volume(SpicePlaybackInstance *sin,
-                                      uint8_t nchannels, uint16_t *volume);
-void spice_server_playback_set_mute(SpicePlaybackInstance *sin, uint8_t mute);
-
-#define SPICE_INTERFACE_RECORD "record"
-#define SPICE_INTERFACE_RECORD_MAJOR 2
-#define SPICE_INTERFACE_RECORD_MINOR 3
-typedef struct SpiceRecordInterface SpiceRecordInterface;
-typedef struct SpiceRecordInstance SpiceRecordInstance;
-typedef struct SpiceRecordState SpiceRecordState;
-
-#define SPICE_INTERFACE_RECORD_FREQ  44100
-#define SPICE_INTERFACE_RECORD_CHAN  2
-#define SPICE_INTERFACE_RECORD_FMT   SPICE_INTERFACE_AUDIO_FMT_S16
-
-struct SpiceRecordInterface {
-    SpiceBaseInterface base;
-};
-
-struct SpiceRecordInstance {
-    SpiceBaseInstance base;
-    SpiceRecordState  *st;
-};
-
-void spice_server_record_start(SpiceRecordInstance *sin);
-void spice_server_record_stop(SpiceRecordInstance *sin);
-uint32_t spice_server_record_get_samples(SpiceRecordInstance *sin,
-                                         uint32_t *samples, uint32_t bufsize);
-void spice_server_record_set_volume(SpiceRecordInstance *sin,
-                                    uint8_t nchannels, uint16_t *volume);
-void spice_server_record_set_mute(SpiceRecordInstance *sin, uint8_t mute);
-
-uint32_t spice_server_get_best_playback_rate(SpicePlaybackInstance *sin);
-void     spice_server_set_playback_rate(SpicePlaybackInstance *sin, uint32_t frequency);
-uint32_t spice_server_get_best_record_rate(SpiceRecordInstance *sin);
-void     spice_server_set_record_rate(SpiceRecordInstance *sin, uint32_t frequency);
-
-/* char device interfaces */
-
-#define SPICE_INTERFACE_CHAR_DEVICE "char_device"
-#define SPICE_INTERFACE_CHAR_DEVICE_MAJOR 1
-#define SPICE_INTERFACE_CHAR_DEVICE_MINOR 3
-typedef struct SpiceCharDeviceInterface SpiceCharDeviceInterface;
-typedef struct SpiceCharDeviceInstance SpiceCharDeviceInstance;
-typedef struct SpiceCharDeviceState SpiceCharDeviceState;
-
-typedef enum {
-    SPICE_CHAR_DEVICE_NOTIFY_WRITABLE = 1 << 0,
-} spice_char_device_flags;
-
-struct SpiceCharDeviceInterface {
-    SpiceBaseInterface base;
-
-    void (*state)(SpiceCharDeviceInstance *sin, int connected);
-    int (*write)(SpiceCharDeviceInstance *sin, const uint8_t *buf, int len);
-    int (*read)(SpiceCharDeviceInstance *sin, uint8_t *buf, int len);
-    void (*event)(SpiceCharDeviceInstance *sin, uint8_t event);
-    spice_char_device_flags flags;
-};
-
-struct SpiceCharDeviceInstance {
-    SpiceBaseInstance base;
-    const char* subtype;
-    SpiceCharDeviceState *st;
-    const char* portname;
-};
-
-void spice_server_char_device_wakeup(SpiceCharDeviceInstance *sin);
-void spice_server_port_event(SpiceCharDeviceInstance *char_device, uint8_t event);
-const char** spice_server_char_device_recognized_subtypes(void);
-
-/* spice server setup */
-
-/* Don't use features incompatible with a specific spice
-   version, so that migration to/from that version works. */
-typedef enum {
-    SPICE_COMPAT_VERSION_0_4 = 0,
-    SPICE_COMPAT_VERSION_0_6 = 1,
-} spice_compat_version_t;
-
-#define SPICE_COMPAT_VERSION_CURRENT SPICE_COMPAT_VERSION_0_6
-
-spice_compat_version_t spice_get_current_compat_version(void);
-
-typedef struct RedsState SpiceServer;
-SpiceServer *spice_server_new(void);
-int spice_server_init(SpiceServer *s, SpiceCoreInterface *core);
-void spice_server_destroy(SpiceServer *s);
-
-#define SPICE_ADDR_FLAG_IPV4_ONLY (1 << 0)
-#define SPICE_ADDR_FLAG_IPV6_ONLY (1 << 1)
-
-int spice_server_set_compat_version(SpiceServer *s,
-                                    spice_compat_version_t version);
-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);
-int spice_server_set_ticket(SpiceServer *s, const char *passwd, int lifetime,
-                            int fail_if_connected, int disconnect_if_connected);
-int spice_server_set_tls(SpiceServer *s, int port,
-                         const char *ca_cert_file, const char *certs_file,
-                         const char *private_key_file, const char *key_passwd,
-                         const char *dh_key_file, const char *ciphersuite);
-
-int spice_server_add_client(SpiceServer *s, int socket, int skip_auth);
-int spice_server_add_ssl_client(SpiceServer *s, int socket, int skip_auth);
-
-int spice_server_add_interface(SpiceServer *s,
-                               SpiceBaseInstance *sin);
-int spice_server_remove_interface(SpiceBaseInstance *sin);
-
-typedef enum {
-    SPICE_IMAGE_COMPRESS_INVALID  = 0,
-    SPICE_IMAGE_COMPRESS_OFF      = 1,
-    SPICE_IMAGE_COMPRESS_AUTO_GLZ = 2,
-    SPICE_IMAGE_COMPRESS_AUTO_LZ  = 3,
-    SPICE_IMAGE_COMPRESS_QUIC     = 4,
-    SPICE_IMAGE_COMPRESS_GLZ      = 5,
-    SPICE_IMAGE_COMPRESS_LZ       = 6,
-} spice_image_compression_t;
-
-int spice_server_set_image_compression(SpiceServer *s,
-                                       spice_image_compression_t comp);
-spice_image_compression_t spice_server_get_image_compression(SpiceServer *s);
-
-typedef enum {
-    SPICE_WAN_COMPRESSION_INVALID,
-    SPICE_WAN_COMPRESSION_AUTO,
-    SPICE_WAN_COMPRESSION_ALWAYS,
-    SPICE_WAN_COMPRESSION_NEVER,
-} spice_wan_compression_t;
-
-int spice_server_set_jpeg_compression(SpiceServer *s, spice_wan_compression_t comp);
-int spice_server_set_zlib_glz_compression(SpiceServer *s, spice_wan_compression_t comp);
-
-#define SPICE_CHANNEL_SECURITY_NONE (1 << 0)
-#define SPICE_CHANNEL_SECURITY_SSL (1 << 1)
-
-int spice_server_set_channel_security(SpiceServer *s, const char *channel, int security);
-
-int spice_server_add_renderer(SpiceServer *s, const char *name);
-
-enum {
-    SPICE_STREAM_VIDEO_INVALID,
-    SPICE_STREAM_VIDEO_OFF,
-    SPICE_STREAM_VIDEO_ALL,
-    SPICE_STREAM_VIDEO_FILTER
-};
-
-int spice_server_set_streaming_video(SpiceServer *s, int value);
-int spice_server_set_playback_compression(SpiceServer *s, int enable);
-int spice_server_set_agent_mouse(SpiceServer *s, int enable);
-int spice_server_set_agent_copypaste(SpiceServer *s, int enable);
-int spice_server_set_agent_file_xfer(SpiceServer *s, int enable);
-
-int spice_server_get_sock_info(SpiceServer *s, struct sockaddr *sa, socklen_t *salen);
-int spice_server_get_peer_info(SpiceServer *s, struct sockaddr *sa, socklen_t *salen);
-
-int spice_server_is_server_mouse(SpiceServer *s);
-
-/* migration interface */
-#define SPICE_INTERFACE_MIGRATION "migration"
-#define SPICE_INTERFACE_MIGRATION_MAJOR 1
-#define SPICE_INTERFACE_MIGRATION_MINOR 1
-typedef struct SpiceMigrateInterface SpiceMigrateInterface;
-typedef struct SpiceMigrateInstance SpiceMigrateInstance;
-typedef struct SpiceMigrateState SpiceMigrateState;
-
-struct SpiceMigrateInterface {
-    SpiceBaseInterface base;
-    void (*migrate_connect_complete)(SpiceMigrateInstance *sin);
-    void (*migrate_end_complete)(SpiceMigrateInstance *sin);
-};
-
-struct SpiceMigrateInstance {
-    SpiceBaseInstance base;
-    SpiceMigrateState *st;
-};
-
-/* spice switch-host client migration */
-int spice_server_migrate_info(SpiceServer *s, const char* dest,
-                              int port, int secure_port,
-                              const char* cert_subject);
-int spice_server_migrate_switch(SpiceServer *s);
-
-/* server status */
-int spice_server_get_num_clients(SpiceServer *s);
-
-/* spice (semi-)seamless client migration */
-int spice_server_migrate_connect(SpiceServer *s, const char* dest,
-                                 int port, int secure_port,
-                                 const char* cert_subject);
-int spice_server_migrate_start(SpiceServer *s);
-int spice_server_migrate_end(SpiceServer *s, int completed);
-
-void spice_server_set_seamless_migration(SpiceServer *s, int enable);
-
-void spice_server_set_name(SpiceServer *s, const char *name);
-void spice_server_set_uuid(SpiceServer *s, const uint8_t uuid[16]);
-
-void spice_server_vm_start(SpiceServer *s);
-void spice_server_vm_stop(SpiceServer *s);
-
-#endif
+ *  Copyright (C) 2009-2014 Red Hat, Inc.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SPICE_H_
+#define SPICE_H_
+
+#define SPICE_H_INSIDE
+
+#include "spice-version.h"
+#include "spice-core.h"
+#include "spice-server.h"
+#include "spice-qxl.h"
+#include "spice-input.h"
+#include "spice-audio.h"
+#include "spice-char.h"
+#include "spice-migration.h"
+
+#undef SPICE_H_INSIDE
+
+#endif /* SPICE_H_ */
commit d26604ce65ff51e2820a27e16b62a2eb17ab994d
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Fri Oct 24 14:14:49 2014 +0200

    spice.h: remove redundant declarations
    
    Those are already declared in <spice/qxl_dev.h>.

diff --git a/server/spice.h b/server/spice.h
index bd5bba8..ca167ea 100644
--- a/server/spice.h
+++ b/server/spice.h
@@ -111,11 +111,7 @@ typedef struct QXLState QXLState;
 typedef struct QXLWorker QXLWorker;
 typedef struct QXLDevMemSlot QXLDevMemSlot;
 typedef struct QXLDevSurfaceCreate QXLDevSurfaceCreate;
-union QXLReleaseInfo;
-struct QXLReleaseInfoExt;
-struct QXLCommand;
-struct QXLCommandExt;
-struct QXLRect;
+
 struct QXLWorker {
     uint32_t minor_version;
     uint32_t major_version;
commit c9685014e73025df416674b4c039079f4fe73faf
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Fri Oct 24 15:08:35 2014 +0200

    Validate RedDrawable before allocating drawable
    
    Avoid unnecessary allocation (and possibly leaking) if the RedDrawable
    is not valid.
    
    Related to: rhbz#1135372

diff --git a/server/red_worker.c b/server/red_worker.c
index e177b68..9f18495 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -4068,6 +4068,17 @@ static Drawable *get_drawable(RedWorker *worker, uint8_t effect, RedDrawable *re
     struct timespec time;
     int x;
 
+    VALIDATE_SURFACE_RETVAL(worker, red_drawable->surface_id, NULL)
+    if (!validate_drawable_bbox(worker, red_drawable)) {
+        rendering_incorrect(__func__);
+        return NULL;
+    }
+    for (x = 0; x < 3; ++x) {
+        if (red_drawable->surfaces_dest[x] != -1) {
+            VALIDATE_SURFACE_RETVAL(worker, red_drawable->surfaces_dest[x], NULL)
+        }
+    }
+
     while (!(drawable = alloc_drawable(worker))) {
         free_one_drawable(worker, FALSE);
     }
@@ -4093,17 +4104,7 @@ static Drawable *get_drawable(RedWorker *worker, uint8_t effect, RedDrawable *re
     drawable->group_id = group_id;
 
     drawable->surface_id = red_drawable->surface_id;
-    VALIDATE_SURFACE_RETVAL(worker, drawable->surface_id, NULL)
-    for (x = 0; x < 3; ++x) {
-        drawable->surfaces_dest[x] = red_drawable->surfaces_dest[x];
-        if (drawable->surfaces_dest[x] != -1) {
-            VALIDATE_SURFACE_RETVAL(worker, drawable->surfaces_dest[x], NULL)
-        }
-    }
-    if (!validate_drawable_bbox(worker, red_drawable)) {
-        rendering_incorrect(__func__);
-        return NULL;
-    }
+    memcpy(drawable->surfaces_dest, red_drawable->surfaces_dest, sizeof(drawable->surfaces_dest));
     ring_init(&drawable->pipes);
     ring_init(&drawable->glz_ring);
 
commit 697f3214fd16adcd524456003619f7f44ddd031b
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Fri Oct 24 10:51:05 2014 +0200

    chardev: remove write polling
    
    In an effort to reduce the wakeups per second, get rid of the
    "write_to_dev" timer when the implementation supports
    SPICE_CHAR_DEVICE_NOTIFY_WRITABLE.
    
    When this flag is set, the frontend instance is responsible for calling
    spice_char_device_wakeup() when the device is ready to perform IO.
    
    Related to:
    https://bugzilla.redhat.com/show_bug.cgi?id=912763

diff --git a/server/char_device.c b/server/char_device.c
index 6d2339e..c6dc45b 100644
--- a/server/char_device.c
+++ b/server/char_device.c
@@ -438,7 +438,10 @@ static int spice_char_device_write_to_device(SpiceCharDeviceState *dev)
     }
 
     spice_char_device_state_ref(dev);
-    core->timer_cancel(dev->write_to_dev_timer);
+
+    if (dev->write_to_dev_timer) {
+        core->timer_cancel(dev->write_to_dev_timer);
+    }
 
     sif = SPICE_CONTAINEROF(dev->sin->base.sif, SpiceCharDeviceInterface, base);
     while (dev->running) {
@@ -473,8 +476,10 @@ static int spice_char_device_write_to_device(SpiceCharDeviceState *dev)
     /* retry writing as long as the write queue is not empty */
     if (dev->running) {
         if (dev->cur_write_buf) {
-            core->timer_start(dev->write_to_dev_timer,
-                              CHAR_DEVICE_WRITE_TO_TIMEOUT);
+            if (dev->write_to_dev_timer) {
+                core->timer_start(dev->write_to_dev_timer,
+                                  CHAR_DEVICE_WRITE_TO_TIMEOUT);
+            }
         } else {
             spice_assert(ring_is_empty(&dev->write_queue));
         }
@@ -488,7 +493,9 @@ static void spice_char_dev_write_retry(void *opaque)
 {
     SpiceCharDeviceState *dev = opaque;
 
-    core->timer_cancel(dev->write_to_dev_timer);
+    if (dev->write_to_dev_timer) {
+        core->timer_cancel(dev->write_to_dev_timer);
+    }
     spice_char_device_write_to_device(dev);
 }
 
@@ -635,6 +642,7 @@ SpiceCharDeviceState *spice_char_device_state_create(SpiceCharDeviceInstance *si
                                                      void *opaque)
 {
     SpiceCharDeviceState *char_dev;
+    SpiceCharDeviceInterface *sif;
 
     spice_assert(sin);
     spice_assert(cbs->read_one_msg_from_device && cbs->ref_msg_to_client &&
@@ -652,10 +660,15 @@ SpiceCharDeviceState *spice_char_device_state_create(SpiceCharDeviceInstance *si
     ring_init(&char_dev->write_bufs_pool);
     ring_init(&char_dev->clients);
 
-    char_dev->write_to_dev_timer = core->timer_add(spice_char_dev_write_retry, char_dev);
-    if (!char_dev->write_to_dev_timer) {
-        spice_error("failed creating char dev write timer");
+    sif = SPICE_CONTAINEROF(char_dev->sin->base.sif, SpiceCharDeviceInterface, base);
+    if (sif->base.minor_version <= 2 ||
+        !(sif->flags & SPICE_CHAR_DEVICE_NOTIFY_WRITABLE)) {
+        char_dev->write_to_dev_timer = core->timer_add(spice_char_dev_write_retry, char_dev);
+        if (!char_dev->write_to_dev_timer) {
+            spice_error("failed creating char dev write timer");
+        }
     }
+
     char_dev->refs = 1;
     sin->st = char_dev;
     spice_debug("sin %p dev_state %p", sin, char_dev);
@@ -697,7 +710,9 @@ static void spice_char_device_state_unref(SpiceCharDeviceState *char_dev)
 void spice_char_device_state_destroy(SpiceCharDeviceState *char_dev)
 {
     reds_on_char_device_state_destroy(char_dev);
-    core->timer_remove(char_dev->write_to_dev_timer);
+    if (char_dev->write_to_dev_timer) {
+        core->timer_remove(char_dev->write_to_dev_timer);
+    }
     write_buffers_queue_free(&char_dev->write_queue);
     write_buffers_queue_free(&char_dev->write_bufs_pool);
     if (char_dev->cur_write_buf) {
@@ -805,7 +820,9 @@ void spice_char_device_stop(SpiceCharDeviceState *dev)
     spice_debug("dev_state %p", dev);
     dev->running = FALSE;
     dev->active = FALSE;
-    core->timer_cancel(dev->write_to_dev_timer);
+    if (dev->write_to_dev_timer) {
+        core->timer_cancel(dev->write_to_dev_timer);
+    }
 }
 
 void spice_char_device_reset(SpiceCharDeviceState *dev)
@@ -842,6 +859,7 @@ void spice_char_device_reset(SpiceCharDeviceState *dev)
 
 void spice_char_device_wakeup(SpiceCharDeviceState *dev)
 {
+    spice_char_device_write_to_device(dev);
     spice_char_device_read_from_device(dev);
 }
 
diff --git a/server/spice.h b/server/spice.h
index 58700d1..bd5bba8 100644
--- a/server/spice.h
+++ b/server/spice.h
@@ -24,7 +24,7 @@
 #include <spice/vd_agent.h>
 #include <spice/macros.h>
 
-#define SPICE_SERVER_VERSION 0x000c05 /* release 0.12.5 */
+#define SPICE_SERVER_VERSION 0x000c06 /* release 0.12.6 */
 
 #ifdef SPICE_SERVER_INTERNAL
 #undef SPICE_GNUC_DEPRECATED
@@ -402,11 +402,15 @@ void     spice_server_set_record_rate(SpiceRecordInstance *sin, uint32_t frequen
 
 #define SPICE_INTERFACE_CHAR_DEVICE "char_device"
 #define SPICE_INTERFACE_CHAR_DEVICE_MAJOR 1
-#define SPICE_INTERFACE_CHAR_DEVICE_MINOR 2
+#define SPICE_INTERFACE_CHAR_DEVICE_MINOR 3
 typedef struct SpiceCharDeviceInterface SpiceCharDeviceInterface;
 typedef struct SpiceCharDeviceInstance SpiceCharDeviceInstance;
 typedef struct SpiceCharDeviceState SpiceCharDeviceState;
 
+typedef enum {
+    SPICE_CHAR_DEVICE_NOTIFY_WRITABLE = 1 << 0,
+} spice_char_device_flags;
+
 struct SpiceCharDeviceInterface {
     SpiceBaseInterface base;
 
@@ -414,6 +418,7 @@ struct SpiceCharDeviceInterface {
     int (*write)(SpiceCharDeviceInstance *sin, const uint8_t *buf, int len);
     int (*read)(SpiceCharDeviceInstance *sin, uint8_t *buf, int len);
     void (*event)(SpiceCharDeviceInstance *sin, uint8_t event);
+    spice_char_device_flags flags;
 };
 
 struct SpiceCharDeviceInstance {


More information about the Spice-commits mailing list