Skip to content

Commit d57d22d

Browse files
author
Jon Ludlam
committed
Use SMAPIv2 VDI.stat for XenAPI VDI.update rather than SMAPIv1 vdi_update
Signed-off-by: Jon Ludlam <[email protected]>
1 parent ffb36e9 commit d57d22d

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

ocaml/xapi/storage_access.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,8 @@ module SMAPIv1 = struct
542542
Server_helpers.exec_with_new_task "VDI.stat" ~subtask_of:(Ref.of_string dbg)
543543
(fun __context ->
544544
for_vdi ~dbg ~sr ~vdi "VDI.stat"
545-
(fun device_config _type _ self ->
545+
(fun device_config _type sr self ->
546+
Sm.vdi_update device_config _type sr self;
546547
vdi_info_of_vdi_rec __context (Db.VDI.get_record ~__context ~self)
547548
)
548549
)

ocaml/xapi/xapi_vdi.ml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,8 @@ let require_uuid vdi_info =
249249
| Some uuid -> uuid
250250
| None -> failwith "SM backend failed to return <uuid> field"
251251

252-
let newvdi ~__context ~sr newvdi =
252+
(* This function updates xapi's database for a single VDI. The row will be created if it doesn't exist *)
253+
let update_vdi_db ~__context ~sr newvdi =
253254
let open Storage_interface in
254255
let open Db_filter_types in
255256
let expr = And(Eq(Field "location", Literal newvdi.vdi), Eq(Field "SR", Literal (Ref.string_of sr))) in
@@ -310,7 +311,7 @@ let create ~__context ~name_label ~name_description
310311
(fun () -> C.VDI.create ~dbg:(Ref.string_of task) ~sr:(Db.SR.get_uuid ~__context ~self:sR) ~vdi_info) in
311312
if virtual_size < sm_vdi.virtual_size
312313
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;
313-
let db_vdi = newvdi ~__context ~sr:sR sm_vdi in
314+
let db_vdi = update_vdi_db ~__context ~sr:sR sm_vdi in
314315
Db.VDI.set_other_config ~__context ~self:db_vdi ~value:other_config;
315316
Db.VDI.set_sharable ~__context ~self:db_vdi ~value:sharable;
316317
Db.VDI.set_tags ~__context ~self:db_vdi ~value:tags;
@@ -388,12 +389,15 @@ let introduce ~__context ~uuid ~name_label ~name_description ~sR ~_type ~sharabl
388389
ref
389390

390391
let update ~__context ~vdi =
391-
debug "update ref=%s location=%s" (Ref.string_of vdi) (Db.VDI.get_location ~__context ~self:vdi);
392+
let vdi_loc = Db.VDI.get_location ~__context ~self:vdi in
393+
debug "update ref=%s location=%s" (Ref.string_of vdi) vdi_loc;
394+
let task = Context.get_task_id __context in
392395
let sR = Db.VDI.get_SR ~__context ~self:vdi in
396+
let sr' = Db.SR.get_uuid ~__context ~self:sR in
397+
let module C = Storage_interface.Client(struct let rpc = Storage_access.rpc end) in
393398
Sm.assert_pbd_is_plugged ~__context ~sr:sR;
394-
Sm.call_sm_functions ~__context ~sR
395-
(fun device_config sr_type ->
396-
Sm.vdi_update device_config sr_type sR vdi)
399+
let vdi_info = C.VDI.stat ~dbg:(Ref.string_of task) ~sr:sr' ~vdi:vdi_loc in
400+
ignore(update_vdi_db ~__context ~sr:sR vdi_info)
397401

398402
let forget ~__context ~vdi = Db.VDI.destroy ~__context ~self:vdi
399403

@@ -423,7 +427,7 @@ let snapshot_and_clone call_f ~__context ~vdi ~driver_params =
423427
let sr' = Db.SR.get_uuid ~__context ~self:sR in
424428
(* We don't use transform_storage_exn because of the clone/copy fallback below *)
425429
let new_vdi = call_f ~dbg:(Ref.string_of task) ~sr:sr' ~vdi_info in
426-
newvdi ~__context ~sr:sR new_vdi
430+
update_vdi_db ~__context ~sr:sR new_vdi
427431
in
428432

429433
(* While we don't have blkback support for pause/unpause we only do this

0 commit comments

Comments
 (0)