Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

CA-77726: Use a new session to create the return value from Host.migr…


If and event.from are being used concurrently using the same
session, event.from dynamically adds and removes event subscriptions for
that session, which can cause to intermittently fail with
SESSION_NOT_REGISTERED, even if the client has registered for events.

This prevents XenCenter from migrating VMs, since XenCenter and the
source host's xapi use the same session to talk to the destination
host's xapi, and xapi uses as part of
Cli_util.wait_for_task_completion while XenCenter calls event.from all
the time.

Returning a new session from Host.migrate_receive is a quick fix - we
should investigate whether and event.from can be called
concurrently with themselves and each other when a session reference is

Signed-off-by: John Else <>
  • Loading branch information...
commit 67bda85462f7da34690793f308a58bad763b9fd0 1 parent 5147ecd
@johnelse authored
Showing with 13 additions and 4 deletions.
  1. +13 −4 ocaml/xapi/
17 ocaml/xapi/
@@ -1533,12 +1533,21 @@ let sync_pif_currently_attached ~__context ~host ~bridges =
) pifs
let migrate_receive ~__context ~host ~network ~options =
- let session_id = Ref.string_of (Context.get_session_id __context) in
+ let session_id = Context.get_session_id __context in
+ let session_rec = Db.Session.get_record ~__context ~self:session_id in
+ let new_session_id = Xapi_session.login_no_password ~__context ~uname:None ~host
+ ~pool:session_rec.API.session_pool
+ ~is_local_superuser:session_rec.API.session_is_local_superuser
+ ~subject:session_rec.API.session_subject
+ ~auth_user_sid:session_rec.API.session_auth_user_sid
+ ~auth_user_name:session_rec.API.session_auth_user_name
+ ~rbac_permissions:session_rec.API.session_rbac_permissions in
+ let new_session_id = (Ref.string_of new_session_id) in
let ip = Db.Host.get_address ~__context ~self:host in
- let sm_url = Printf.sprintf "http://%s/services/SM?session_id=%s" ip session_id in
- let xenops_url = Printf.sprintf "http://%s/services/xenops?session_id=%s" ip session_id in
+ let sm_url = Printf.sprintf "http://%s/services/SM?session_id=%s" ip new_session_id in
+ let xenops_url = Printf.sprintf "http://%s/services/xenops?session_id=%s" ip new_session_id in
[ Xapi_vm_migrate._sm, sm_url;
Xapi_vm_migrate._host, Ref.string_of host;
Xapi_vm_migrate._xenops, xenops_url;
- Xapi_vm_migrate._session_id, session_id;
+ Xapi_vm_migrate._session_id, new_session_id;

0 comments on commit 67bda85

Please sign in to comment.
Something went wrong with that request. Please try again.