@@ -1763,7 +1763,8 @@ let rec atomics_of_operation = function
1763
1763
serial " VIF.activate_and_plug" ~id
1764
1764
[VIF_set_active (vif.Vif. id, true ); VIF_plug vif.Vif. id]
1765
1765
)
1766
- | VM_restore_devices (id , restore_vifs ) ->
1766
+ | VM_restore_devices (id , migration ) ->
1767
+ let restore_vifs = not migration in
1767
1768
let vbds_rw, vbds_ro = VBD_DB. vbds id |> vbd_plug_sets in
1768
1769
let vgpus = VGPU_DB. vgpus id in
1769
1770
let pcis = PCI_DB. pcis id |> pci_plug_order in
@@ -1773,8 +1774,22 @@ let rec atomics_of_operation = function
1773
1774
let name_multi = pf " VBDs.activate_and_plug %s" typ in
1774
1775
let name_one = pf " VBD.activate_and_plug %s" typ in
1775
1776
parallel_map name_multi ~id vbds (fun vbd ->
1776
- serial name_one ~id
1777
- [VBD_set_active (vbd.Vbd. id, true ); vbd_plug vbd.Vbd. id]
1777
+ (* When migrating, attach early if the vbd's SM allows it.
1778
+ Note: there is a bug here for SxM if migrating between API
1779
+ versions as the Vbd's new SR won't have propagated to xenopsd
1780
+ yet. This means can_attach_early will be based on the origin SR.
1781
+ This is a non-issue as v1 <-> v3 migration is still experimental
1782
+ and v1 is already early-attaching in SxM through mirroring.
1783
+ *)
1784
+ if
1785
+ migration
1786
+ && (not ! xenopsd_vbd_plug_unplug_legacy)
1787
+ && vbd.Vbd. can_attach_early
1788
+ then
1789
+ [VBD_activate vbd.Vbd. id]
1790
+ else
1791
+ serial name_one ~id
1792
+ [VBD_set_active (vbd.Vbd. id, true ); vbd_plug vbd.Vbd. id]
1778
1793
)
1779
1794
in
1780
1795
[
@@ -1897,7 +1912,7 @@ let rec atomics_of_operation = function
1897
1912
]
1898
1913
; vgpu_start_operations
1899
1914
; [VM_restore (id, data, vgpu_data)]
1900
- ; atomics_of_operation (VM_restore_devices (id, true ))
1915
+ ; atomics_of_operation (VM_restore_devices (id, false ))
1901
1916
; [
1902
1917
(* At this point the domain is considered survivable. *)
1903
1918
VM_set_domain_action_request (id, None )
@@ -2696,9 +2711,9 @@ and perform_exn ?result (op : operation) (t : Xenops_task.task_handle) : unit =
2696
2711
| VM_restore_vifs id ->
2697
2712
debug " VM_restore_vifs %s" id ;
2698
2713
perform_atomics (atomics_of_operation op) t
2699
- | VM_restore_devices (id , restore_vifs ) ->
2714
+ | VM_restore_devices (id , migration ) ->
2700
2715
(* XXX: this is delayed due to the 'attach'/'activate' behaviour *)
2701
- debug " VM_restore_devices %s %b" id restore_vifs ;
2716
+ debug " VM_restore_devices %s %b" id migration ;
2702
2717
perform_atomics (atomics_of_operation op) t
2703
2718
| VM_resume (id , _data ) ->
2704
2719
debug " VM.resume %s" id ;
@@ -3022,11 +3037,31 @@ and perform_exn ?result (op : operation) (t : Xenops_task.task_handle) : unit =
3022
3037
( try
3023
3038
let no_sharept = VGPU_DB. vgpus id |> List. exists is_no_sharept in
3024
3039
debug " VM %s no_sharept=%b (%s)" id no_sharept __LOC__ ;
3040
+ (* If plug is split into activate and attach, we could attach
3041
+ early so that it is outside of the VM downtime (if the SM
3042
+ supports this) *)
3043
+ let early_attach =
3044
+ parallel_map " VBDs.set_active_and_attach" ~id (VBD_DB. vbds id)
3045
+ (fun vbd ->
3046
+ if
3047
+ (not ! xenopsd_vbd_plug_unplug_legacy)
3048
+ && vbd.Vbd. can_attach_early
3049
+ then
3050
+ serial " VBD.set_active_and_attach" ~id
3051
+ [
3052
+ VBD_set_active (vbd.Vbd. id, true )
3053
+ ; VBD_attach vbd.Vbd. id
3054
+ ]
3055
+ else
3056
+ []
3057
+ )
3058
+ in
3025
3059
perform_atomics
3026
3060
([VM_create (id, Some memory_limit, Some final_id, no_sharept)]
3027
- @ (* Perform as many operations as possible on the destination
3028
- domain before pausing the original domain *)
3029
- atomics_of_operation (VM_restore_vifs id)
3061
+ (* Perform as many operations as possible on the destination
3062
+ domain before pausing the original domain *)
3063
+ @ atomics_of_operation (VM_restore_vifs id)
3064
+ @ early_attach
3030
3065
)
3031
3066
t ;
3032
3067
Handshake. send s Handshake. Success
@@ -3142,7 +3177,7 @@ and perform_exn ?result (op : operation) (t : Xenops_task.task_handle) : unit =
3142
3177
) ;
3143
3178
debug " VM.receive_memory: restoring remaining devices and unpausing" ;
3144
3179
perform_atomics
3145
- (atomics_of_operation (VM_restore_devices (final_id, false ))
3180
+ (atomics_of_operation (VM_restore_devices (final_id, true ))
3146
3181
@ [
3147
3182
VM_unpause final_id
3148
3183
; VM_set_domain_action_request (final_id, None )
0 commit comments