@@ -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
@@ -1777,10 +1778,23 @@ let rec atomics_of_operation = function
1777
1778
[VBD_set_active (vbd.Vbd. id, true ); vbd_plug vbd.Vbd. id]
1778
1779
)
1779
1780
in
1781
+ let activate_vbds typ vbds =
1782
+ let name_multi = Printf. sprintf " VBDs.activate %s" typ in
1783
+ parallel name_multi ~id
1784
+ (List. map (fun vbd -> VBD_activate vbd.Vbd. id) vbds)
1785
+ in
1786
+ let prep_vbds =
1787
+ if ! xenopsd_vbd_plug_unplug_legacy || not migration then
1788
+ plug_vbds
1789
+ else
1790
+ (* If plug is split into activate and attach, when migrating we don't
1791
+ need to attach here as we attached outside of the VM downtime *)
1792
+ activate_vbds
1793
+ in
1780
1794
[
1781
1795
(* rw vbds must be plugged before ro vbds, see vbd_plug_sets *)
1782
- plug_vbds " RW" vbds_rw
1783
- ; plug_vbds " RO" vbds_ro
1796
+ prep_vbds " RW" vbds_rw
1797
+ ; prep_vbds " RO" vbds_ro
1784
1798
; (if restore_vifs then atomics_of_operation (VM_restore_vifs id) else [] )
1785
1799
; (* Nvidia SRIOV PCI devices have been already been plugged *)
1786
1800
parallel_map " VGPUs.activate" ~id vgpus (fun vgpu ->
@@ -1897,7 +1911,7 @@ let rec atomics_of_operation = function
1897
1911
]
1898
1912
; vgpu_start_operations
1899
1913
; [VM_restore (id, data, vgpu_data)]
1900
- ; atomics_of_operation (VM_restore_devices (id, true ))
1914
+ ; atomics_of_operation (VM_restore_devices (id, false ))
1901
1915
; [
1902
1916
(* At this point the domain is considered survivable. *)
1903
1917
VM_set_domain_action_request (id, None )
@@ -2696,9 +2710,9 @@ and perform_exn ?result (op : operation) (t : Xenops_task.task_handle) : unit =
2696
2710
| VM_restore_vifs id ->
2697
2711
debug " VM_restore_vifs %s" id ;
2698
2712
perform_atomics (atomics_of_operation op) t
2699
- | VM_restore_devices (id , restore_vifs ) ->
2713
+ | VM_restore_devices (id , migration ) ->
2700
2714
(* XXX: this is delayed due to the 'attach'/'activate' behaviour *)
2701
- debug " VM_restore_devices %s %b" id restore_vifs ;
2715
+ debug " VM_restore_devices %s %b" id migration ;
2702
2716
perform_atomics (atomics_of_operation op) t
2703
2717
| VM_resume (id , _data ) ->
2704
2718
debug " VM.resume %s" id ;
@@ -3022,11 +3036,27 @@ and perform_exn ?result (op : operation) (t : Xenops_task.task_handle) : unit =
3022
3036
( try
3023
3037
let no_sharept = VGPU_DB. vgpus id |> List. exists is_no_sharept in
3024
3038
debug " VM %s no_sharept=%b (%s)" id no_sharept __LOC__ ;
3039
+ let early_attach =
3040
+ if ! xenopsd_vbd_plug_unplug_legacy then
3041
+ []
3042
+ else
3043
+ (* If plug is split into activate and attach, we can attach
3044
+ early so that it is outside of the VM downtime *)
3045
+ parallel_map " VBDs.set_active_and_attach" ~id (VBD_DB. vbds id)
3046
+ (fun vbd ->
3047
+ serial " VBD.set_active_and_attach" ~id
3048
+ [
3049
+ VBD_set_active (vbd.Vbd. id, true )
3050
+ ; VBD_attach vbd.Vbd. id
3051
+ ]
3052
+ )
3053
+ in
3025
3054
perform_atomics
3026
3055
([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)
3056
+ (* Perform as many operations as possible on the destination
3057
+ domain before pausing the original domain *)
3058
+ @ atomics_of_operation (VM_restore_vifs id)
3059
+ @ early_attach
3030
3060
)
3031
3061
t ;
3032
3062
Handshake. send s Handshake. Success
@@ -3142,7 +3172,7 @@ and perform_exn ?result (op : operation) (t : Xenops_task.task_handle) : unit =
3142
3172
) ;
3143
3173
debug " VM.receive_memory: restoring remaining devices and unpausing" ;
3144
3174
perform_atomics
3145
- (atomics_of_operation (VM_restore_devices (final_id, false ))
3175
+ (atomics_of_operation (VM_restore_devices (final_id, true ))
3146
3176
@ [
3147
3177
VM_unpause final_id
3148
3178
; VM_set_domain_action_request (final_id, None )
0 commit comments