Skip to content

Commit c6209de

Browse files
author
David Scott
committed
'xenvm lvcreate': fix support for '-l segments' and implement '-l PERCENT%F'
The API call uses bytes but the regular parse function takes care of that by multiplying the user-supplied MiB by 1024 * 1024. We need to also translate extents into bytes. Signed-off-by: David Scott <[email protected]>
1 parent 22c853e commit c6209de

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

xenvm/lvcreate.ml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@ let lvcreate copts lv_name real_size percent_size tags vg_name =
1212
set_uri copts info;
1313
Client.get () >>= fun vg ->
1414

15-
let extent_size_mib = Int64.(div (mul 512L vg.Lvm.Vg.extent_size) (mul 1024L 1024L)) in
15+
let extent_size_bytes = Int64.(mul 512L vg.Lvm.Vg.extent_size) in
1616

1717
let size = match parse_size real_size percent_size with
1818
| `Absolute size -> size
19-
| `Extents extents -> Int64.mul extent_size_mib extents
19+
| `Extents extents -> Int64.mul extent_size_bytes extents
20+
| `Free percent ->
21+
let extents = Int64.(div (mul (Lvm.Pv.Allocator.size vg.Lvm.Vg.free_space) percent) 100L) in
22+
let bytes = Int64.mul extent_size_bytes extents in
23+
bytes
2024
| _ -> failwith "Initial size must be absolute" in
21-
2225
if vg.Lvm.Vg.name <> vg_name then failwith "Invalid VG name";
2326
Client.create lv_name size tags >>= fun () ->
2427
return info) in

0 commit comments

Comments
 (0)