[Spice-devel] [PATCH v2 1/4] channel: add a new internal SpiceCoreInterface

Frediano Ziglio fziglio at redhat.com
Thu Jan 7 09:32:14 PST 2016


Define an internal structure that much 100% the ABI of the public one.
The structure will be changed by following patches.
See comments in "channel: add interface parameters to
SpiceCoreInterfaceInternal" patch.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/main-dispatcher.c     |  4 ++--
 server/main-dispatcher.h     |  2 +-
 server/red-channel.c         |  6 +++---
 server/red-channel.h         |  6 +++---
 server/red-common.h          | 17 +++++++++++++++++
 server/red-worker.c          |  2 +-
 server/reds-stream.c         |  2 +-
 server/reds.c                |  5 +++--
 server/reds.h                |  2 +-
 server/tests/test_playback.c |  1 -
 10 files changed, 32 insertions(+), 15 deletions(-)

diff --git a/server/main-dispatcher.c b/server/main-dispatcher.c
index 78b2fed..77f2071 100644
--- a/server/main-dispatcher.c
+++ b/server/main-dispatcher.c
@@ -49,7 +49,7 @@
 
 typedef struct {
     Dispatcher base;
-    SpiceCoreInterface *core;
+    SpiceCoreInterfaceInternal *core;
 } MainDispatcher;
 
 MainDispatcher main_dispatcher;
@@ -195,7 +195,7 @@ static void dispatcher_handle_read(int fd, int event, void *opaque)
  * Reds routines shouldn't be exposed. Instead reds.c should register the callbacks,
  * and the corresponding operations should be made only via main_dispatcher.
  */
-void main_dispatcher_init(SpiceCoreInterface *core)
+void main_dispatcher_init(SpiceCoreInterfaceInternal *core)
 {
     memset(&main_dispatcher, 0, sizeof(main_dispatcher));
     main_dispatcher.core = core;
diff --git a/server/main-dispatcher.h b/server/main-dispatcher.h
index a1a2e77..1a06229 100644
--- a/server/main-dispatcher.h
+++ b/server/main-dispatcher.h
@@ -31,6 +31,6 @@ void main_dispatcher_set_mm_time_latency(RedClient *client, uint32_t latency);
  */
 void main_dispatcher_client_disconnect(RedClient *client);
 
-void main_dispatcher_init(SpiceCoreInterface *core);
+void main_dispatcher_init(SpiceCoreInterfaceInternal *core);
 
 #endif //MAIN_DISPATCHER_H
diff --git a/server/red-channel.c b/server/red-channel.c
index 1cc6534..f79605a 100644
--- a/server/red-channel.c
+++ b/server/red-channel.c
@@ -1008,7 +1008,7 @@ void red_channel_client_default_migrate(RedChannelClient *rcc)
 }
 
 RedChannel *red_channel_create(int size,
-                               const SpiceCoreInterface *core,
+                               const SpiceCoreInterfaceInternal *core,
                                uint32_t type, uint32_t id,
                                int handle_acks,
                                channel_handle_message_proc handle_message,
@@ -1080,7 +1080,7 @@ static void dummy_watch_remove(SpiceWatch *watch)
 }
 
 // TODO: actually, since I also use channel_client_dummy, no need for core. Can be NULL
-SpiceCoreInterface dummy_core = {
+SpiceCoreInterfaceInternal dummy_core = {
     .watch_update_mask = dummy_watch_update_mask,
     .watch_add = dummy_watch_add,
     .watch_remove = dummy_watch_remove,
@@ -1123,7 +1123,7 @@ static int do_nothing_handle_message(RedChannelClient *rcc,
 }
 
 RedChannel *red_channel_create_parser(int size,
-                               const SpiceCoreInterface *core,
+                               const SpiceCoreInterfaceInternal *core,
                                uint32_t type, uint32_t id,
                                int handle_acks,
                                spice_parse_channel_func_t parser,
diff --git a/server/red-channel.h b/server/red-channel.h
index c5784e6..791bc5b 100644
--- a/server/red-channel.h
+++ b/server/red-channel.h
@@ -311,7 +311,7 @@ struct RedChannel {
 
     RingItem link; // channels link for reds
 
-    const SpiceCoreInterface *core;
+    const SpiceCoreInterfaceInternal *core;
     int handle_acks;
 
     // RedChannel will hold only connected channel clients (logic - when pushing pipe item to all channel clients, there
@@ -359,7 +359,7 @@ struct RedChannel {
 /* if one of the callbacks should cause disconnect, use red_channel_shutdown and don't
  * explicitly destroy the channel */
 RedChannel *red_channel_create(int size,
-                               const SpiceCoreInterface *core,
+                               const SpiceCoreInterfaceInternal *core,
                                uint32_t type, uint32_t id,
                                int handle_acks,
                                channel_handle_message_proc handle_message,
@@ -369,7 +369,7 @@ RedChannel *red_channel_create(int size,
 /* alternative constructor, meant for marshaller based (inputs,main) channels,
  * will become default eventually */
 RedChannel *red_channel_create_parser(int size,
-                               const SpiceCoreInterface *core,
+                               const SpiceCoreInterfaceInternal *core,
                                uint32_t type, uint32_t id,
                                int handle_acks,
                                spice_parse_channel_func_t parser,
diff --git a/server/red-common.h b/server/red-common.h
index f6098f6..40da0b1 100644
--- a/server/red-common.h
+++ b/server/red-common.h
@@ -39,4 +39,21 @@
 #include "spice.h"
 #include "utils.h"
 
+typedef struct SpiceCoreInterfaceInternal SpiceCoreInterfaceInternal;
+
+struct SpiceCoreInterfaceInternal {
+    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
diff --git a/server/red-worker.c b/server/red-worker.c
index dfaf4ba..ce9cc56 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -580,7 +580,7 @@ static void worker_watch_remove(SpiceWatch *watch)
     memset(watch, 0, sizeof(SpiceWatch));
 }
 
-SpiceCoreInterface worker_core = {
+SpiceCoreInterfaceInternal worker_core = {
     .timer_add = spice_timer_queue_add,
     .timer_start = spice_timer_set,
     .timer_cancel = spice_timer_cancel,
diff --git a/server/reds-stream.c b/server/reds-stream.c
index d87cb23..d8e4fe4 100644
--- a/server/reds-stream.c
+++ b/server/reds-stream.c
@@ -43,7 +43,7 @@ struct AsyncRead {
 };
 typedef struct AsyncRead AsyncRead;
 
-extern SpiceCoreInterface *core;
+extern SpiceCoreInterfaceInternal *core;
 
 #if HAVE_SASL
 #include <sasl/sasl.h>
diff --git a/server/reds.c b/server/reds.c
index e8cf168..54a398e 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -72,7 +72,8 @@
 
 #include "reds-private.h"
 
-SpiceCoreInterface *core = NULL;
+SpiceCoreInterfaceInternal *core = NULL;
+
 static SpiceCharDeviceInstance *vdagent = NULL;
 static SpiceMigrateInstance *migration_interface = NULL;
 
@@ -3274,7 +3275,7 @@ static int do_spice_init(SpiceCoreInterface *core_interface)
         spice_warning("bad core interface version");
         goto err;
     }
-    core = core_interface;
+    core = (SpiceCoreInterfaceInternal *) core_interface;
     reds->listen_socket = -1;
     reds->secure_listen_socket = -1;
     init_vd_agent_resources();
diff --git a/server/reds.h b/server/reds.h
index 4d1b631..f3a9ce4 100644
--- a/server/reds.h
+++ b/server/reds.h
@@ -69,7 +69,7 @@ enum {
 extern uint32_t renderers[RED_RENDERER_LAST];
 extern uint32_t num_renderers;
 
-extern struct SpiceCoreInterface *core;
+extern struct SpiceCoreInterfaceInternal *core;
 extern uint32_t streaming_video;
 extern SpiceImageCompression image_compression;
 extern spice_wan_compression_t jpeg_state;
diff --git a/server/tests/test_playback.c b/server/tests/test_playback.c
index cf31155..1283427 100644
--- a/server/tests/test_playback.c
+++ b/server/tests/test_playback.c
@@ -22,7 +22,6 @@
 #include <math.h>
 
 #include <spice.h>
-#include "reds.h"
 #include "basic_event_loop.h"
 
 /* test the audio playback interface. Really basic no frils test - create
-- 
2.4.3



More information about the Spice-devel mailing list