[Spice-commits] server/char-device.c server/reds.c server/reds.h server/sound.c
Frediano Ziglio
fziglio at kemper.freedesktop.org
Thu Jan 21 06:45:13 PST 2016
server/char-device.c | 2 -
server/reds.c | 57 +++++++++++++++++++++++++--------------------------
server/reds.h | 6 ++---
server/sound.c | 8 +++----
4 files changed, 37 insertions(+), 36 deletions(-)
New commits:
commit e5d3b2bf73b13f0d8c5c4098f16388603d106518
Author: Jonathon Jongsma <jjongsma at redhat.com>
Date: Mon Jan 19 16:03:34 2015 -0600
Change some functions to take RedsState arg
In preparation for getting rid of the global 'reds' variable, we need to
pass the RedsState variable to all functions where it is needed. For now
the callers just pass in the global reds variable.
Functions changed:
- reds_mig_fill_wait_disconnect;
- reds_mig_cleanup_wait_disconnect;
- reds_mig_remove_wait_disconnect_client;
- reds_migrate_channels_seamless;
- reds_mig_finished;
- reds_mig_switch;
- reds_enable_mm_time;
- reds_disable_mm_time;
- attach_to_red_agent;
- reds_char_device_add_state;
- reds_char_device_remove_state;
- reds_on_char_device_state_destroy;
- spice_server_char_device_remove_interface;
- migrate_timeout.
Acked-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/server/char-device.c b/server/char-device.c
index 19e8419..7c209cd 100644
--- a/server/char-device.c
+++ b/server/char-device.c
@@ -740,7 +740,7 @@ 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);
+ reds_on_char_device_state_destroy(reds, char_dev);
if (char_dev->write_to_dev_timer) {
core->timer_remove(char_dev->write_to_dev_timer);
char_dev->write_to_dev_timer = NULL;
diff --git a/server/reds.c b/server/reds.c
index d018b1d..f0087a8 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -206,10 +206,10 @@ struct ChannelSecurityOptions {
static void migrate_timeout(void *opaque);
static RedsMigTargetClient* reds_mig_target_client_find(RedsState *reds, RedClient *client);
static void reds_mig_target_client_free(RedsState *reds, RedsMigTargetClient *mig_client);
-static void reds_mig_cleanup_wait_disconnect(void);
-static void reds_mig_remove_wait_disconnect_client(RedClient *client);
-static void reds_char_device_add_state(SpiceCharDeviceState *st);
-static void reds_char_device_remove_state(SpiceCharDeviceState *st);
+static void reds_mig_cleanup_wait_disconnect(RedsState *reds);
+static void reds_mig_remove_wait_disconnect_client(RedsState *reds, RedClient *client);
+static void reds_char_device_add_state(RedsState *reds, SpiceCharDeviceState *st);
+static void reds_char_device_remove_state(RedsState *reds, SpiceCharDeviceState *st);
static void reds_send_mm_time(RedsState *reds);
static VDIReadBuf *vdi_port_read_buf_get(RedsState *reds);
@@ -426,7 +426,7 @@ static void reds_mig_cleanup(RedsState *reds)
reds->mig_wait_connect = FALSE;
reds->mig_wait_disconnect = FALSE;
core->timer_cancel(reds->mig_timer);
- reds_mig_cleanup_wait_disconnect();
+ reds_mig_cleanup_wait_disconnect(reds);
}
}
@@ -517,7 +517,7 @@ void reds_client_disconnect(RedsState *reds, RedClient *client)
}
if (reds->mig_wait_disconnect) {
- reds_mig_remove_wait_disconnect_client(client);
+ reds_mig_remove_wait_disconnect_client(reds, client);
}
if (reds->agent_state.base) {
@@ -2850,7 +2850,7 @@ static void reds_mig_started(RedsState *reds)
core->timer_start(reds->mig_timer, MIGRATE_TIMEOUT);
}
-static void reds_mig_fill_wait_disconnect(void)
+static void reds_mig_fill_wait_disconnect(RedsState *reds)
{
RingItem *client_item;
@@ -2869,7 +2869,7 @@ static void reds_mig_fill_wait_disconnect(void)
core->timer_start(reds->mig_timer, MIGRATE_TIMEOUT);
}
-static void reds_mig_cleanup_wait_disconnect(void)
+static void reds_mig_cleanup_wait_disconnect(RedsState *reds)
{
RingItem *wait_client_item;
@@ -2883,7 +2883,7 @@ static void reds_mig_cleanup_wait_disconnect(void)
reds->mig_wait_disconnect = FALSE;
}
-static void reds_mig_remove_wait_disconnect_client(RedClient *client)
+static void reds_mig_remove_wait_disconnect_client(RedsState *reds, RedClient *client)
{
RingItem *wait_client_item;
@@ -2903,7 +2903,7 @@ static void reds_mig_remove_wait_disconnect_client(RedClient *client)
spice_warning("client not found %p", client);
}
-static void reds_migrate_channels_seamless(void)
+static void reds_migrate_channels_seamless(RedsState *reds)
{
RedClient *client;
@@ -2912,27 +2912,27 @@ static void reds_migrate_channels_seamless(void)
red_client_migrate(client);
}
-static void reds_mig_finished(int completed)
+static void reds_mig_finished(RedsState *reds, int completed)
{
spice_info(NULL);
reds->mig_inprogress = TRUE;
if (reds->src_do_seamless_migrate && completed) {
- reds_migrate_channels_seamless();
+ reds_migrate_channels_seamless(reds);
} else {
main_channel_migrate_src_complete(reds->main_channel, completed);
}
if (completed) {
- reds_mig_fill_wait_disconnect();
+ reds_mig_fill_wait_disconnect(reds);
} else {
reds_mig_cleanup(reds);
}
reds_mig_release(reds);
}
-static void reds_mig_switch(void)
+static void reds_mig_switch(RedsState *reds)
{
if (!reds->mig_spice) {
spice_warning("reds_mig_switch called without migrate_info set");
@@ -2944,6 +2944,7 @@ static void reds_mig_switch(void)
static void migrate_timeout(void *opaque)
{
+ RedsState *reds = opaque;
spice_info(NULL);
spice_assert(reds->mig_wait_connect || reds->mig_wait_disconnect);
if (reds->mig_wait_connect) {
@@ -2962,19 +2963,19 @@ uint32_t reds_get_mm_time(void)
return spice_get_monotonic_time_ms();
}
-void reds_enable_mm_time(void)
+void reds_enable_mm_time(RedsState *reds)
{
reds->mm_time_enabled = TRUE;
reds->mm_time_latency = MM_TIME_DELTA;
reds_send_mm_time(reds);
}
-void reds_disable_mm_time(void)
+void reds_disable_mm_time(RedsState *reds)
{
reds->mm_time_enabled = FALSE;
}
-static SpiceCharDeviceState *attach_to_red_agent(SpiceCharDeviceInstance *sin)
+static SpiceCharDeviceState *attach_to_red_agent(RedsState *reds, SpiceCharDeviceInstance *sin)
{
VDIPortState *state = &reds->agent_state;
SpiceCharDeviceInterface *sif;
@@ -3086,7 +3087,7 @@ SPICE_GNUC_VISIBLE const char** spice_server_char_device_recognized_subtypes(voi
return spice_server_char_device_recognized_subtypes_list;
}
-static void reds_char_device_add_state(SpiceCharDeviceState *st)
+static void reds_char_device_add_state(RedsState *reds, SpiceCharDeviceState *st)
{
SpiceCharDeviceStateItem *item = spice_new0(SpiceCharDeviceStateItem, 1);
@@ -3095,7 +3096,7 @@ static void reds_char_device_add_state(SpiceCharDeviceState *st)
ring_add(&reds->char_devs_states, &item->link);
}
-static void reds_char_device_remove_state(SpiceCharDeviceState *st)
+static void reds_char_device_remove_state(RedsState *reds, SpiceCharDeviceState *st)
{
RingItem *item;
@@ -3112,9 +3113,9 @@ static void reds_char_device_remove_state(SpiceCharDeviceState *st)
spice_error("char dev state not found %p", st);
}
-void reds_on_char_device_state_destroy(SpiceCharDeviceState *dev)
+void reds_on_char_device_state_destroy(RedsState *reds, SpiceCharDeviceState *dev)
{
- reds_char_device_remove_state(dev);
+ reds_char_device_remove_state(reds, dev);
}
static int spice_server_char_device_add_interface(SpiceServer *s,
@@ -3132,7 +3133,7 @@ static int spice_server_char_device_add_interface(SpiceServer *s,
spice_warning("vdagent already attached");
return -1;
}
- dev_state = attach_to_red_agent(char_device);
+ dev_state = attach_to_red_agent(reds, char_device);
}
#ifdef USE_SMARTCARD
else if (strcmp(char_device->subtype, SUBTYPE_SMARTCARD) == 0) {
@@ -3159,7 +3160,7 @@ static int spice_server_char_device_add_interface(SpiceServer *s,
if (reds->vm_running) {
spice_char_device_start(char_device->st);
}
- reds_char_device_add_state(char_device->st);
+ reds_char_device_add_state(reds, char_device->st);
} else {
spice_warning("failed to create device state for %s", char_device->subtype);
return -1;
@@ -3167,7 +3168,7 @@ static int spice_server_char_device_add_interface(SpiceServer *s,
return 0;
}
-static void spice_server_char_device_remove_interface(SpiceBaseInstance *sin)
+static void spice_server_char_device_remove_interface(RedsState *reds, SpiceBaseInstance *sin)
{
SpiceCharDeviceInstance* char_device =
SPICE_CONTAINEROF(sin, SpiceCharDeviceInstance, base);
@@ -3310,7 +3311,7 @@ SPICE_GNUC_VISIBLE int spice_server_remove_interface(SpiceBaseInstance *sin)
spice_info("remove SPICE_INTERFACE_RECORD");
snd_detach_record(SPICE_CONTAINEROF(sin, SpiceRecordInstance, base));
} else if (strcmp(interface->type, SPICE_INTERFACE_CHAR_DEVICE) == 0) {
- spice_server_char_device_remove_interface(sin);
+ spice_server_char_device_remove_interface(reds, sin);
} else {
spice_warning("VD_INTERFACE_REMOVING unsupported");
return -1;
@@ -3365,7 +3366,7 @@ static int do_spice_init(RedsState *reds, SpiceCoreInterface *core_interface)
ring_init(&reds->mig_wait_disconnect_clients);
reds->vm_running = TRUE; /* for backward compatibility */
- if (!(reds->mig_timer = core->timer_add(core, migrate_timeout, NULL))) {
+ if (!(reds->mig_timer = core->timer_add(core, migrate_timeout, reds))) {
spice_error("migration timer create failed");
}
@@ -3960,7 +3961,7 @@ SPICE_GNUC_VISIBLE int spice_server_migrate_end(SpiceServer *s, int completed)
spice_info("no peer connected");
goto complete;
}
- reds_mig_finished(completed);
+ reds_mig_finished(reds, completed);
return 0;
complete:
if (sif->migrate_end_complete) {
@@ -3978,7 +3979,7 @@ SPICE_GNUC_VISIBLE int spice_server_migrate_switch(SpiceServer *s)
return 0;
}
reds->expect_migrate = FALSE;
- reds_mig_switch();
+ reds_mig_switch(reds);
return 0;
}
diff --git a/server/reds.h b/server/reds.h
index 8bf3210..e398607 100644
--- a/server/reds.h
+++ b/server/reds.h
@@ -50,8 +50,8 @@ struct SpiceMigrateState {
/* main thread only */
void reds_handle_channel_event(int event, SpiceChannelEventInfo *info);
-void reds_disable_mm_time(void);
-void reds_enable_mm_time(void);
+void reds_disable_mm_time(RedsState *reds);
+void reds_enable_mm_time(RedsState *reds);
uint32_t reds_get_mm_time(void);
void reds_set_client_mouse_allowed(RedsState *reds,
int is_client_mouse_allowed,
@@ -111,7 +111,7 @@ int reds_on_migrate_dst_set_seamless(RedsState *reds, MainChannelClient *mcc, ui
void reds_on_client_semi_seamless_migrate_complete(RedsState *reds, RedClient *client);
void reds_on_client_seamless_migrate_complete(RedsState *reds, RedClient *client);
void reds_on_main_channel_migrate(RedsState *reds, MainChannelClient *mcc);
-void reds_on_char_device_state_destroy(SpiceCharDeviceState *dev);
+void reds_on_char_device_state_destroy(RedsState *reds, SpiceCharDeviceState *dev);
void reds_set_client_mm_time_latency(RedsState *reds, RedClient *client, uint32_t latency);
diff --git a/server/sound.c b/server/sound.c
index b785652..0890a87 100644
--- a/server/sound.c
+++ b/server/sound.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_time();
+ reds_disable_mm_time(reds);
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_time();
+ reds_enable_mm_time(reds);
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_time();
+ reds_disable_mm_time(reds);
}
}
@@ -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_time();
+ reds_enable_mm_time(reds);
}
snd_codec_destroy(&playback_channel->codec);
More information about the Spice-commits
mailing list