Skip to content

Commit 9b19f9a

Browse files
author
Jon Ludlam
committed
Merge pull request #1014 from johnelse/ca-98492
CA-98492: Fix for VDI.create for certain VDI types
2 parents eda9fbd + a87bea4 commit 9b19f9a

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

ocaml/xapi/OMakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ XAPI_MODULES = $(COMMON) \
8686
storage_mux \
8787
storage_migrate \
8888
storage_proxy \
89+
storage_utils \
8990
xapi_services \
9091
sm_exec \
9192
sm \

ocaml/xapi/storage_access.ml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ let find_content ~__context ?sr name =
4545
let redirect sr =
4646
raise (Redirect (Some (Pool_role.get_master_address ())))
4747

48-
let string_of_vdi_type vdi_type =
49-
Rpc.string_of_rpc (API.rpc_of_vdi_type vdi_type)
50-
5148
module SMAPIv1 = struct
5249
(** xapi's builtin ability to call local SM plugins using the existing
5350
protocol. The code here should only call the SM functions and encapsulate
@@ -185,7 +182,7 @@ module SMAPIv1 = struct
185182
content_id = content_id; (* PR-1255 *)
186183
name_label = vdi_rec.API.vDI_name_label;
187184
name_description = vdi_rec.API.vDI_name_description;
188-
ty = string_of_vdi_type vdi_rec.API.vDI_type;
185+
ty = Storage_utils.string_of_vdi_type vdi_rec.API.vDI_type;
189186
metadata_of_pool = Ref.string_of vdi_rec.API.vDI_metadata_of_pool;
190187
is_a_snapshot = vdi_rec.API.vDI_is_a_snapshot;
191188
snapshot_time = Date.to_string vdi_rec.API.vDI_snapshot_time;
@@ -338,7 +335,7 @@ module SMAPIv1 = struct
338335
content_id = r.API.vDI_location; (* PR-1255 *)
339336
name_label = r.API.vDI_name_label;
340337
name_description = r.API.vDI_name_description;
341-
ty = string_of_vdi_type r.API.vDI_type;
338+
ty = Storage_utils.string_of_vdi_type r.API.vDI_type;
342339
metadata_of_pool = Ref.string_of r.API.vDI_metadata_of_pool;
343340
is_a_snapshot = r.API.vDI_is_a_snapshot;
344341
snapshot_time = Date.to_string r.API.vDI_snapshot_time;

ocaml/xapi/storage_utils.ml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
(*
2+
* Copyright (C) 2006-2013 Citrix Systems Inc.
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published
6+
* by the Free Software Foundation; version 2.1 only. with the special
7+
* exception on linking described in file LICENSE.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*)
14+
15+
let string_of_vdi_type vdi_type =
16+
Rpc.string_of_rpc (API.rpc_of_vdi_type vdi_type)
17+
18+
let vdi_type_of_string str =
19+
API.vdi_type_of_rpc (Rpc.String str)

ocaml/xapi/xapi_sr.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ let update_vdis ~__context ~sr db_vdis vdi_infos =
333333
~snapshot_time:(Date.of_string vdi.snapshot_time)
334334
~sR:sr ~virtual_size:vdi.virtual_size
335335
~physical_utilisation:vdi.physical_utilisation
336-
~_type:(Opt.default `user (Record_util.string_to_vdi_type vdi.ty))
336+
~_type:(try Storage_utils.vdi_type_of_string vdi.ty with _ -> `user)
337337
~sharable:false ~read_only:vdi.read_only
338338
~xenstore_data:[] ~sm_config:[]
339339
~other_config:[] ~storage_lock:false ~location:vdi.vdi
@@ -354,7 +354,7 @@ let update_vdis ~__context ~sr db_vdis vdi_infos =
354354
debug "%s name_description <- %s" (Ref.string_of r) vi.name_description;
355355
Db.VDI.set_name_description ~__context ~self:r ~value:vi.name_description
356356
end;
357-
let ty = Opt.default `user (Record_util.string_to_vdi_type vi.ty) in
357+
let ty = (try Storage_utils.vdi_type_of_string vi.ty with _ -> `user) in
358358
if v.API.vDI_type <> ty then begin
359359
debug "%s type <- %s" (Ref.string_of r) vi.ty;
360360
Db.VDI.set_type ~__context ~self:r ~value:ty

0 commit comments

Comments
 (0)