Skip to content

Commit 14d84e2

Browse files
committed
CP-31450: Add domid to Datapath.attach
We now honour the existing API of Datapath.attach by passing the domid of vm that the vbd is being attached to. This will enable a qemu process per vm. Signed-off-by: ben sims <[email protected]>
1 parent 9d87488 commit 14d84e2

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

main.ml

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ let vdi_of_volume x =
528528
persistent = true;
529529
}
530530

531-
let choose_datapath ?(persistent = true) response =
531+
let choose_datapath ?(persistent = true) domain response =
532532
(* We can only use a URI with a valid scheme, since we use the scheme
533533
to name the datapath plugin. *)
534534
let possible =
@@ -558,7 +558,7 @@ let choose_datapath ?(persistent = true) response =
558558
supports_nonpersistent @ others in
559559
match preference_order with
560560
| [] -> return (Error (missing_uri ()))
561-
| (script_dir, scheme, u) :: us -> return (Ok (fork_exec_rpc ~script_dir, scheme, u, "0"))
561+
| (script_dir, scheme, u) :: us -> return (Ok (fork_exec_rpc ~script_dir, scheme, u, domain))
562562

563563

564564
(* Bind the implementations *)
@@ -601,7 +601,7 @@ let bind ~volume_script_dir =
601601
Deferred.Result.return { response with keys = (key, value) :: response.keys }
602602
in
603603

604-
let vdi_attach_common dbg sr vdi =
604+
let vdi_attach_common dbg sr vdi domain =
605605
let open Deferred.Result.Monad_infix in
606606
Attached_SRs.find sr
607607
>>= fun sr ->
@@ -615,7 +615,7 @@ let bind ~volume_script_dir =
615615
| Some temporary ->
616616
stat ~dbg ~sr ~vdi:temporary
617617
) >>= fun response ->
618-
choose_datapath response
618+
choose_datapath domain response
619619
>>= fun (rpc, datapath, uri, domain) ->
620620
return_data_rpc (fun () -> Datapath_client.attach rpc dbg uri domain)
621621
in
@@ -976,10 +976,11 @@ let bind ~volume_script_dir =
976976
in
977977
S.VDI.introduce vdi_introduce_impl;
978978

979-
let vdi_attach2_impl dbg _dp sr vdi' _readwrite =
979+
let vdi_attach3_impl dbg _dp sr vdi' vm' _readwrite =
980980
begin
981981
let vdi = Storage_interface.Vdi.string_of vdi' in
982-
vdi_attach_common dbg sr vdi >>>= fun response ->
982+
let domain = Storage_interface.Vm.string_of vm' in
983+
vdi_attach_common dbg sr vdi domain >>>= fun response ->
983984
let convert_implementation = function
984985
| Xapi_storage.Data.XenDisk { params; extra; backend_type } -> Storage_interface.XenDisk { params; extra; backend_type }
985986
| BlockDevice { path } -> BlockDevice { path }
@@ -989,11 +990,12 @@ let bind ~volume_script_dir =
989990
Deferred.Result.return { Storage_interface.implementations = List.map ~f:convert_implementation response.Xapi_storage.Data.implementations }
990991
end |> wrap
991992
in
992-
S.VDI.attach2 vdi_attach2_impl;
993+
S.VDI.attach3 vdi_attach3_impl;
993994

994-
let vdi_activate_impl dbg _dp sr vdi' =
995+
let vdi_activate3_impl dbg _dp sr vdi' vm'=
995996
begin
996997
let vdi = Storage_interface.Vdi.string_of vdi' in
998+
let domain = Storage_interface.Vm.string_of vm' in
997999
Attached_SRs.find sr >>>= fun sr ->
9981000
(* Discover the URIs using Volume.stat *)
9991001
stat ~dbg ~sr ~vdi >>>= fun response ->
@@ -1004,16 +1006,17 @@ let bind ~volume_script_dir =
10041006
| Some temporary ->
10051007
stat ~dbg ~sr ~vdi:temporary
10061008
) >>>= fun response ->
1007-
choose_datapath response
1009+
choose_datapath domain response
10081010
>>>= fun (rpc, datapath, uri, domain) ->
10091011
return_data_rpc (fun () -> Datapath_client.activate rpc dbg uri domain)
10101012
end |> wrap
10111013
in
1012-
S.VDI.activate vdi_activate_impl;
1014+
S.VDI.activate3 vdi_activate3_impl;
10131015

1014-
let vdi_deactivate_impl dbg _dp sr vdi' =
1016+
let vdi_deactivate_impl dbg _dp sr vdi' vm'=
10151017
begin
10161018
let vdi = Storage_interface.Vdi.string_of vdi' in
1019+
let domain = Storage_interface.Vm.string_of vm' in
10171020
Attached_SRs.find sr >>>= fun sr ->
10181021
(* Discover the URIs using Volume.stat *)
10191022
stat ~dbg ~sr ~vdi >>>= fun response ->
@@ -1022,15 +1025,16 @@ let bind ~volume_script_dir =
10221025
return (Ok response)
10231026
| Some temporary ->
10241027
stat ~dbg ~sr ~vdi:temporary) >>>= fun response ->
1025-
choose_datapath response >>>= fun (rpc, datapath, uri, domain) ->
1028+
choose_datapath domain response >>>= fun (rpc, datapath, uri, domain) ->
10261029
return_data_rpc (fun () -> Datapath_client.deactivate rpc dbg uri domain)
10271030
end |> wrap
10281031
in
10291032
S.VDI.deactivate vdi_deactivate_impl;
10301033

1031-
let vdi_detach_impl dbg _dp sr vdi' =
1034+
let vdi_detach_impl dbg _dp sr vdi' vm'=
10321035
begin
10331036
let vdi = Storage_interface.Vdi.string_of vdi' in
1037+
let domain = Storage_interface.Vm.string_of vm' in
10341038
Attached_SRs.find sr >>>= fun sr ->
10351039
(* Discover the URIs using Volume.stat *)
10361040
stat ~dbg ~sr ~vdi >>>= fun response ->
@@ -1039,7 +1043,7 @@ let bind ~volume_script_dir =
10391043
return (Ok response)
10401044
| Some temporary ->
10411045
stat ~dbg ~sr ~vdi:temporary) >>>= fun response ->
1042-
choose_datapath response >>>= fun (rpc, datapath, uri, domain) ->
1046+
choose_datapath domain response >>>= fun (rpc, datapath, uri, domain) ->
10431047
return_data_rpc (fun () -> Datapath_client.detach rpc dbg uri domain)
10441048
end |> wrap
10451049
in
@@ -1066,13 +1070,14 @@ let bind ~volume_script_dir =
10661070
in
10671071
S.SR.stat sr_stat_impl;
10681072

1069-
let vdi_epoch_begin_impl dbg sr vdi' persistent =
1073+
let vdi_epoch_begin_impl dbg sr vdi' vm' persistent =
10701074
begin
10711075
let vdi = Storage_interface.Vdi.string_of vdi' in
1076+
let domain = Storage_interface.Vm.string_of vm' in
10721077
Attached_SRs.find sr >>>= fun sr ->
10731078
(* Discover the URIs using Volume.stat *)
10741079
stat ~dbg ~sr ~vdi >>>= fun response ->
1075-
choose_datapath ~persistent response >>>= fun (rpc, datapath, uri, domain) ->
1080+
choose_datapath ~persistent domain response >>>= fun (rpc, datapath, uri, domain) ->
10761081
(* If non-persistent and the datapath plugin supports NONPERSISTENT
10771082
then we delegate this to the datapath plugin. Otherwise we will
10781083
make a temporary clone now and attach/detach etc this file. *)
@@ -1096,13 +1101,14 @@ let bind ~volume_script_dir =
10961101
in
10971102
S.VDI.epoch_begin vdi_epoch_begin_impl;
10981103

1099-
let vdi_epoch_end_impl dbg sr vdi' =
1104+
let vdi_epoch_end_impl dbg sr vdi' vm' =
11001105
begin
11011106
let vdi = Storage_interface.Vdi.string_of vdi' in
1107+
let domain = Storage_interface.Vm.string_of vm' in
11021108
Attached_SRs.find sr >>>= fun sr ->
11031109
(* Discover the URIs using Volume.stat *)
11041110
stat ~dbg ~sr ~vdi >>>= fun response ->
1105-
choose_datapath response >>>= fun (rpc, datapath, uri, domain) ->
1111+
choose_datapath domain response >>>= fun (rpc, datapath, uri, domain) ->
11061112
if Datapath_plugins.supports_feature datapath _nonpersistent then begin
11071113
return_data_rpc (fun () -> Datapath_client.close rpc dbg uri)
11081114
end else begin
@@ -1152,6 +1158,8 @@ let bind ~volume_script_dir =
11521158
S.TASK.cancel u;
11531159
S.SR.list u;
11541160
S.VDI.attach u;
1161+
S.VDI.attach2 u;
1162+
S.VDI.activate u;
11551163
S.DATA.MIRROR.stat u;
11561164
S.TASK.list u;
11571165
S.VDI.get_url u;

0 commit comments

Comments
 (0)