diff options
author | Frediano Ziglio <fziglio@redhat.com> | 2019-02-16 18:59:56 +0000 |
---|---|---|
committer | Frediano Ziglio <freddy77@gmail.com> | 2023-11-22 07:39:22 +0000 |
commit | 262aab55ef74204dead60a24bfa8e100defe53ee (patch) | |
tree | 96ae0ac013311a530aa96ecf1fbf15aa990f367e | |
parent | 027a0fc816301f3812b7ad88f2dfcdd2b0bed9b2 (diff) |
XXX communicate directly MainChannel* <-> VDIPort
looks for agent_dev in reds.c, still some not right
-rw-r--r-- | server/main-channel-client.cpp | 17 | ||||
-rw-r--r-- | server/main-channel.cpp | 6 | ||||
-rw-r--r-- | server/reds.cpp | 49 | ||||
-rw-r--r-- | server/reds.h | 7 |
4 files changed, 17 insertions, 62 deletions
diff --git a/server/main-channel-client.cpp b/server/main-channel-client.cpp index 17ccaf31..f1f976fe 100644 --- a/server/main-channel-client.cpp +++ b/server/main-channel-client.cpp @@ -116,8 +116,7 @@ static const uint8_t zero_page[ZERO_BUF_SIZE] = {0}; uint8_t *MainChannelClient::alloc_recv_buf(uint16_t type, uint32_t size) { if (type == SPICE_MSGC_MAIN_AGENT_DATA) { - RedChannel *channel = get_channel(); - return reds_get_agent_data_buffer(channel->get_server(), this, size); + return vdi_port_get_agent_data_buffer(priv->agent, this, size); } if (size > sizeof(priv->recv_buf)) { @@ -131,8 +130,7 @@ uint8_t *MainChannelClient::alloc_recv_buf(uint16_t type, uint32_t size) void MainChannelClient::release_recv_buf(uint16_t type, uint32_t size, uint8_t *msg) { if (type == SPICE_MSGC_MAIN_AGENT_DATA) { - RedChannel *channel = get_channel(); - reds_release_agent_data_buffer(channel->get_server(), msg); + vdi_port_release_agent_data_buffer(priv->agent, msg); } } @@ -512,8 +510,7 @@ uint64_t MainChannelClient::get_roundtrip_ms() const void MainChannelClient::migrate() { - RedChannel *channel = get_channel(); - reds_on_main_channel_migrate(channel->get_server(), this); + vdi_port_on_main_channel_migrate(priv->agent, this); RedChannelClient::migrate(); } @@ -635,14 +632,12 @@ static void main_channel_marshall_agent_data(RedChannelClient *rcc, item->add_to_marshaller(m, item->data, item->len); } -static void main_channel_marshall_migrate_data_item(RedChannelClient *rcc, +static void main_channel_marshall_migrate_data_item(MainChannelClient *mcc, SpiceMarshaller *m, RedPipeItem *item) { - RedChannel *channel = rcc->get_channel(); - rcc->init_send_data(SPICE_MSG_MIGRATE_DATA); - // TODO: from reds split. ugly separation. - reds_marshall_migrate_data(channel->get_server(), m); + mcc->init_send_data(SPICE_MSG_MIGRATE_DATA); + vdi_port_marshall_migrate_data(mcc->priv->agent, m); } static void main_channel_marshall_init(RedChannelClient *rcc, diff --git a/server/main-channel.cpp b/server/main-channel.cpp index 0f9fae34..9cbdef28 100644 --- a/server/main-channel.cpp +++ b/server/main-channel.cpp @@ -134,6 +134,8 @@ void MainChannel::migrate_switch(RedsMigSpice *new_mig_target) pipes_add_type(RED_PIPE_ITEM_TYPE_MAIN_MIGRATE_SWITCH_HOST); } +XXX_CAST(RedChannel, MainChannel, MAIN_CHANNEL); + bool MainChannelClient::handle_message(uint16_t type, uint32_t size, void *message) { RedChannel *channel = get_channel(); @@ -144,11 +146,11 @@ bool MainChannelClient::handle_message(uint16_t type, uint32_t size, void *messa SpiceMsgcMainAgentStart *tokens; tokens = static_cast<SpiceMsgcMainAgentStart *>(message); - reds_on_main_agent_start(reds, this, tokens->num_tokens); + vdi_port_on_main_agent_start(MAIN_CHANNEL(channel)->agent, this, tokens->num_tokens); break; } case SPICE_MSGC_MAIN_AGENT_DATA: - reds_on_main_agent_data(reds, this, message, size); + vdi_port_on_main_agent_data(MAIN_CHANNEL(channel)->agent, this, message, size); break; case SPICE_MSGC_MAIN_AGENT_TOKEN: { SpiceMsgcMainAgentTokens *tokens; diff --git a/server/reds.cpp b/server/reds.cpp index c8eb4e8c..5eafddc2 100644 --- a/server/reds.cpp +++ b/server/reds.cpp @@ -572,13 +572,6 @@ SpiceMsgChannels *reds_msg_channels_new(RedsState *reds) return channels_info; } -void reds_on_main_agent_start(RedsState *reds, MainChannelClient *mcc, uint32_t num_tokens) -{ - // XXX maybe vdagent should be really in VDIPort and vdi_on_main_agent_start called by - // MainChannel ?? - vdi_port_on_main_agent_start(reds->agent_dev.get(), mcc, num_tokens); -} - // XXX move to VDIPort void reds_on_main_agent_tokens(RedsState *reds, MainChannelClient *mcc, uint32_t num_tokens) { @@ -590,42 +583,20 @@ void reds_on_main_agent_tokens(RedsState *reds, MainChannelClient *mcc, uint32_t reinterpret_cast<RedCharDeviceClientOpaque *>(client), num_tokens); } -uint8_t *reds_get_agent_data_buffer(RedsState *reds, MainChannelClient *mcc, size_t size) -{ - // XXX - return vdi_port_get_agent_data_buffer(reds->agent_dev.get(), mcc, size); -} - -// XXX MainChannel -void reds_release_agent_data_buffer(RedsState *reds, uint8_t *buf) -{ - vdi_port_release_agent_data_buffer(reds->agent_dev.get(), buf); -} - -// XXX MainChannel +// although this just forward to VDIPort for visibility and separation is +// better to keep separate void reds_send_device_display_info(RedsState *reds) { vdi_port_send_device_display_info(reds->agent_dev.get()); } +// although this just forward to VDIPort for visibility and separation is +// better to keep separate void reds_handle_agent_mouse_event(RedsState *reds, const VDAgentMouseState *mouse_state) { vdi_port_handle_agent_mouse_event(reds->agent_dev.get(), mouse_state); } -// XXX MainChannel -void reds_on_main_channel_migrate(RedsState *reds, MainChannelClient *mcc) -{ - vdi_port_on_main_channel_migrate(reds->agent_dev.get(), mcc); -} - -// XXX MainChannel -void reds_on_main_agent_data(RedsState *reds, MainChannelClient *mcc, const void *message, - size_t size) -{ - vdi_port_on_main_agent_data(reds->agent_dev.get(), mcc, message, size); -} - void reds_on_main_migrate_connected(RedsState *reds, int seamless) { reds->src_do_seamless_migrate = seamless; @@ -652,20 +623,12 @@ void reds_on_main_mouse_mode_request(RedsState *reds, void *message, size_t size } } -// XXX MainChannel -void reds_marshall_migrate_data(RedsState *reds, SpiceMarshaller *m) -{ - // XXX why asking to the device to marshall? It the VDIPort storing some data about migration? - // XXX the structure holds just information for the agent, so make sense that MCC calls - // VDIPort directly! Also make sense other part of this function in VDIPort - vdi_port_marshall_migrate_data(reds->agent_dev.get(), m); -} - /* * The agent device is not attached to the dest before migration is completed. It is * attached only after the vm is started. It might be attached before or after * the migration data has reached the server. */ +// XXX this is no more handling the data, just passing to VDIPort bool reds_handle_migrate_data(RedsState *reds, MainChannelClient *mcc, SpiceMigrateDataMain *mig_data, uint32_t size) { @@ -1040,6 +1003,7 @@ static void reds_handle_main_link(RedsState *reds, RedLinkInfo *link) red_channel_capabilities_reset(&caps); spice_debug("NEW Client %p mcc %p connect-id %d", client, mcc, connection_id); + // XXX move to main_channel_link ?? if (reds->agent_dev->agent_attached()) { if (mig_target) { spice_warning("unexpected: vdagent attached to destination during migration"); @@ -1793,6 +1757,7 @@ listen: return slisten; } +// XXX better in MainChannel !!! just mm_time_latency needed static void reds_send_mm_time(RedsState *reds) { if (!reds_main_channel_connected(reds)) { diff --git a/server/reds.h b/server/reds.h index 8d7ee203..f9f8ebde 100644 --- a/server/reds.h +++ b/server/reds.h @@ -72,17 +72,11 @@ enum { void reds_client_disconnect(RedsState *reds, RedClient *client); // Temporary (?) for splitting main channel -void reds_marshall_migrate_data(RedsState *reds, SpiceMarshaller *m); SpiceMsgChannels *reds_msg_channels_new(RedsState *reds); /* callbacks from main channel messages */ -void reds_on_main_agent_start(RedsState *reds, MainChannelClient *mcc, uint32_t num_tokens); void reds_on_main_agent_tokens(RedsState *reds, MainChannelClient *mcc, uint32_t num_tokens); -uint8_t *reds_get_agent_data_buffer(RedsState *reds, MainChannelClient *mcc, size_t size); -void reds_release_agent_data_buffer(RedsState *reds, uint8_t *buf); -void reds_on_main_agent_data(RedsState *reds, MainChannelClient *mcc, const void *message, - size_t size); void reds_on_main_migrate_connected(RedsState *reds, int seamless); //should be called when all the clients // are connected to the target bool reds_handle_migrate_data(RedsState *reds, MainChannelClient *mcc, @@ -93,7 +87,6 @@ void reds_on_main_mouse_mode_request(RedsState *reds, void *message, size_t size int reds_on_migrate_dst_set_seamless(RedsState *reds, MainChannelClient *mcc, uint32_t src_version); 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_set_client_mm_time_latency(RedsState *reds, RedClient *client, uint32_t latency); uint32_t reds_get_streaming_video(const RedsState *reds); |