@@ -254,7 +254,8 @@ let require_uuid vdi_info =
254254 | Some uuid -> uuid
255255 | None -> failwith " SM backend failed to return <uuid> field"
256256
257- let newvdi ~__context ~sr newvdi =
257+ (* This function updates xapi's database for a single VDI. The row will be created if it doesn't exist *)
258+ let update_vdi_db ~__context ~sr newvdi =
258259 let open Storage_interface in
259260 let open Db_filter_types in
260261 let expr = And (Eq (Field " location" , Literal newvdi.vdi), Eq (Field " SR" , Literal (Ref. string_of sr))) in
@@ -315,7 +316,7 @@ let create ~__context ~name_label ~name_description
315316 (fun () -> C.VDI. create ~dbg: (Ref. string_of task) ~sr: (Db.SR. get_uuid ~__context ~self: sR) ~vdi_info ) in
316317 if virtual_size < sm_vdi.virtual_size
317318 then info " sr:%s vdi:%s requested virtual size %Ld < actual virtual size %Ld" (Ref. string_of sR) sm_vdi.vdi virtual_size sm_vdi.virtual_size;
318- let db_vdi = newvdi ~__context ~sr: sR sm_vdi in
319+ let db_vdi = update_vdi_db ~__context ~sr: sR sm_vdi in
319320 Db.VDI. set_other_config ~__context ~self: db_vdi ~value: other_config;
320321 Db.VDI. set_sharable ~__context ~self: db_vdi ~value: sharable;
321322 Db.VDI. set_tags ~__context ~self: db_vdi ~value: tags;
@@ -393,12 +394,15 @@ let introduce ~__context ~uuid ~name_label ~name_description ~sR ~_type ~sharabl
393394 ref
394395
395396let update ~__context ~vdi =
396- debug " update ref=%s location=%s" (Ref. string_of vdi) (Db.VDI. get_location ~__context ~self: vdi);
397+ let vdi_loc = Db.VDI. get_location ~__context ~self: vdi in
398+ debug " update ref=%s location=%s" (Ref. string_of vdi) vdi_loc;
399+ let task = Context. get_task_id __context in
397400 let sR = Db.VDI. get_SR ~__context ~self: vdi in
401+ let sr' = Db.SR. get_uuid ~__context ~self: sR in
402+ let module C = Storage_interface. Client (struct let rpc = Storage_access. rpc end ) in
398403 Sm. assert_pbd_is_plugged ~__context ~sr: sR;
399- Sm. call_sm_functions ~__context ~s R
400- (fun device_config sr_type ->
401- Sm. vdi_update device_config sr_type sR vdi)
404+ let vdi_info = C.VDI. stat ~dbg: (Ref. string_of task) ~sr: sr' ~vdi: vdi_loc in
405+ ignore(update_vdi_db ~__context ~sr: sR vdi_info)
402406
403407let forget ~__context ~vdi = Db.VDI. destroy ~__context ~self: vdi
404408
@@ -429,7 +433,7 @@ let snapshot_and_clone call_f ~__context ~vdi ~driver_params =
429433 let sr' = Db.SR. get_uuid ~__context ~self: sR in
430434 (* We don't use transform_storage_exn because of the clone/copy fallback below *)
431435 let new_vdi = call_f ~dbg: (Ref. string_of task) ~sr: sr' ~vdi_info in
432- newvdi ~__context ~sr: sR new_vdi
436+ update_vdi_db ~__context ~sr: sR new_vdi
433437 in
434438
435439 (* While we don't have blkback support for pause/unpause we only do this
0 commit comments