[Spice-devel] [RFC PATCH spice 0.8 16/19] client: main channel migration: do partial cleanup when switching hosts

Alon Levy alevy at redhat.com
Tue Sep 20 05:58:52 PDT 2011


On Mon, Sep 19, 2011 at 12:47:09PM +0300, Yonit Halperin wrote:
> Implement on_disconnect_mig_src and on_connect_mig_target in order to avoid
> unnecessary cleanups done in on_(disconnet|connect).
> In addition, do not request guest display settings changes after migration.
> 
> Signed-off-by: Yonit Halperin <yhalperi at redhat.com>
> ---
>  client/red_client.cpp |   37 ++++++++++++++++++++++++++-----------
>  client/red_client.h   |    2 ++
>  2 files changed, 28 insertions(+), 11 deletions(-)
> 
> diff --git a/client/red_client.cpp b/client/red_client.cpp
> index 51ed7b5..01a5d87 100644
> --- a/client/red_client.cpp
> +++ b/client/red_client.cpp
> @@ -491,6 +491,15 @@ void RedClient::on_disconnect()
>      (*sync_event)->wait();
>  }
>  
> +void RedClient::on_disconnect_mig_src()
> +{
> +    _application.deactivate_interval_timer(*_agent_timer);
> +    delete[] _agent_msg_data;
> +    _agent_msg_data = NULL;
> +    _agent_msg_pos = 0;
> +    _agent_tokens = 0;
> +}
> +
>  void RedClient::delete_channels()
>  {
>      Lock lock(_channels_lock);
> @@ -1032,7 +1041,9 @@ void RedClient::handle_init(RedPeer::InMessage* message)
>      LOG_INFO("");
>      _connection_id = init->session_id;
>      set_mm_time(init->multi_media_time);
> -    calc_pixmap_cach_and_glz_window_size(init->display_channels_hint, init->ram_hint);
> +    if (!_during_migration) {
> +        calc_pixmap_cach_and_glz_window_size(init->display_channels_hint, init->ram_hint);
> +    }

Is it possible to bunch all the !_during_migration to a single function and call it, would avoid
the ugliness of an inner scope and make it more readable IMHO.

>      set_mouse_mode(init->supported_mouse_modes, init->current_mouse_mode);
>      _agent_tokens = init->agent_tokens;
>      _agent_connected = !!init->agent_connected;
> @@ -1043,20 +1054,24 @@ void RedClient::handle_init(RedPeer::InMessage* message)
>          _marshallers->msgc_main_agent_start(msg->marshaller(), &agent_start);
>          post_message(msg);
>          send_agent_announce_capabilities(true);
> -        if (_auto_display_res) {
> -            send_agent_monitors_config();
> -        }
> +        if (!_during_migration) {
> +            if (_auto_display_res) {
> +                send_agent_monitors_config();
> +            }
>  
> -        if (_auto_display_res || !_display_setting.is_empty()) {
> -            _application.activate_interval_timer(*_agent_timer, AGENT_TIMEOUT);
> -        } else {
> -            send_main_attach_channels();
> +            if (_auto_display_res || !_display_setting.is_empty()) {
> +                _application.activate_interval_timer(*_agent_timer, AGENT_TIMEOUT);
> +            } else {
> +                send_main_attach_channels();
> +            }
>          }
>      } else {
> -        if (_auto_display_res || !_display_setting.is_empty()) {
> -            LOG_WARN("no agent running, display options have been ignored");
> +        if (!_during_migration) {
> +            if (_auto_display_res || !_display_setting.is_empty()) {
> +                LOG_WARN("no agent running, display options have been ignored");
> +            }
> +            send_main_attach_channels();
>          }
> -        send_main_attach_channels();
>      }
>  
>      if (_during_migration) {
> diff --git a/client/red_client.h b/client/red_client.h
> index 6b9ffd1..8c33a85 100644
> --- a/client/red_client.h
> +++ b/client/red_client.h
> @@ -279,6 +279,8 @@ protected:
>      virtual void on_connecting();
>      virtual void on_connect();
>      virtual void on_disconnect();
> +    virtual void on_connect_mig_target() {}
> +    virtual void on_disconnect_mig_src();
>  
>  private:
>      void on_channel_disconnected(RedChannel& channel);
> -- 
> 1.7.4.4
> 


More information about the Spice-devel mailing list