Skip to content

Commit 0817102

Browse files
author
David Scott
committed
SR.ls: pick up the LV size in 'lvs'
Signed-off-by: David Scott <dave.scott@citrix.com>
1 parent bccf5d3 commit 0817102

File tree

2 files changed

+9
-8
lines changed
  • examples/volume/org.xen.xcp.storage.plainlvm

2 files changed

+9
-8
lines changed

examples/volume/org.xen.xcp.storage.plainlvm/SR.ls

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module Command = struct
3030
description = "";
3131
read_write = true;
3232
uri = ["block://" ^ (Lvm.path_of sr lv.Lvm.name) ];
33-
virtual_size = 0L;
33+
virtual_size = lv.Lvm.size;
3434
} ) (Lvm.lvs sr)
3535
end
3636

@@ -47,7 +47,7 @@ module Test = struct
4747
finally
4848
(fun () ->
4949
match Lvm.lvs vg_name with
50-
| [ { Lvm.name = "testvol"; tags = [] } ] -> ()
50+
| [ { Lvm.name = "testvol" } ] -> ()
5151
| [ ] -> failwith "I created 'testvol' but it didnt show in 'lvs'"
5252
| _ -> failwith "I created 'testvol' but multiple volumes showed up in 'lvs'"
5353
) (fun () ->

examples/volume/org.xen.xcp.storage.plainlvm/lvm.ml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ let lvremove vg_name lv_name =
5858

5959
type lv = {
6060
name: string;
61-
tags: string list;
61+
size: int64;
6262
}
6363

6464
let newline = Re_str.regexp_string "\n"
@@ -68,16 +68,17 @@ let comma = Re_str.regexp_string ","
6868
let to_lines output = List.filter (fun x -> x <> "") (Re_str.split_delim newline output)
6969

7070
let lvs vg_name =
71-
Common.run "lvs" [ "-o"; "lv_name,tags"; "--noheadings"; vg_name ]
71+
Common.run "lvs" [ "-o"; "lv_name,lv_size"; "--units"; "b"; "--noheadings"; vg_name ]
7272
|> to_lines
7373
|> List.map
7474
(fun line ->
7575
match List.filter (fun x -> x <> "") (Re_str.split_delim whitespace line) with
76-
| [ x; y ] -> { name = x; tags = Re_str.split_delim comma y }
77-
| [ x ] -> { name = x; tags = [] }
76+
| [ x; y ] ->
77+
let size = Int64.of_string (String.sub y 0 (String.length y - 1)) in
78+
{ name = x; size }
7879
| _ ->
79-
debug "Couldn't parse the LV name/ list of tags: [%s]" line;
80-
failwith (Printf.sprintf "Couldn't parse the LV name/ list of tags: [%s]" line)
80+
debug "Couldn't parse the LV name/ size: [%s]" line;
81+
failwith (Printf.sprintf "Couldn't parse the LV name/ size: [%s]" line)
8182
)
8283

8384
let device vg_name lv_name = Printf.sprintf "/dev/%s/%s" vg_name lv_name

0 commit comments

Comments
 (0)