Skip to content
This repository has been archived by the owner on May 22, 2018. It is now read-only.

Merge the cooper2 changes #88

Merged
merged 3 commits into from May 4, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
57 changes: 57 additions & 0 deletions tapctl/tapctl.ml
Expand Up @@ -3,6 +3,48 @@ open Listext
open Threadext
open Forkhelpers

(* Tapdisk stats *)
module Stats = struct
module Tap = struct
type t = {
minor: int;
reqs: (int64 * int64);
kicks: (int64 * int64);
} with rpc
end

module Driver = struct
type t = {
ty : int;
name : string;
} with rpc

let rpc_of_t x = match (rpc_of_t x) with | Rpc.Dict x -> Rpc.Dict (List.map (function ("ty",y) -> ("type",y) | x -> x) x) | y -> y
let t_of_rpc rpc = t_of_rpc (match rpc with | Rpc.Dict x -> Rpc.Dict (List.map (function ("type",y) -> ("ty",y) | x -> x) x ) | y -> y)

end

module Image = struct
type t = {
name : string;
hits : int64 * int64;
fail : int64 * int64;
driver : Driver.t
} with rpc
end

type t = {
name : string;
secs : (int64 * int64);
images : Image.t list;
tap : Tap.t;
nbd_mirror_failed : int;
} with rpc
end




type tapdev = {
minor : int;
tapdisk_pid : int;
Expand Down Expand Up @@ -228,6 +270,16 @@ module Dummy = struct
else
None
| _ -> None) list)

let stats ctx t =
let open Stats in
{ name = "none";
secs = 0L,0L;
images = [];
tap = { Tap.minor = t.minor;
reqs = 0L,0L;
kicks = 0L,0L; };
nbd_mirror_failed = 0; }
end


Expand Down Expand Up @@ -338,6 +390,11 @@ let is_active ctx t =
| [(tapdev,state,Some _ )] -> true
| _ -> false

let stats ctx t =
if ctx.dummy then Dummy.stats ctx t else begin
Stats.t_of_rpc (Jsonrpc.of_string (invoke_tap_ctl ctx "stats" (args t)))
end

(* We need to be able to check that a given device's major number corresponds to the right driver *)
let read_proc_devices () : (int * string) list =
let parse_line x = match List.filter (fun x -> x <> "") (String.split ' ' x) with
Expand Down
34 changes: 34 additions & 0 deletions tapctl/tapctl.mli
@@ -1,5 +1,38 @@
(** Represents an active tapdisk instance *)
type tapdev

module Stats :
sig
module Tap :
sig
type t = {
minor : int;
reqs : int64 * int64;
kicks : int64 * int64;
}
end
module Driver :
sig
type t = { ty : int; name : string; }
end
module Image :
sig
type t = {
name : string;
hits : int64 * int64;
fail : int64 * int64;
driver : Driver.t;
}
end
type t = {
name : string;
secs : int64 * int64;
images : Image.t list;
tap : Tap.t;
nbd_mirror_failed : int;
}
end

val tapdev_of_rpc : Rpc.t -> tapdev
val rpc_of_tapdev : tapdev -> Rpc.t

Expand Down Expand Up @@ -32,6 +65,7 @@ val free : context -> int -> unit
val list : ?t:tapdev -> context -> t list
val is_paused : context -> tapdev -> bool
val is_active : context -> tapdev -> bool
val stats : context -> tapdev -> Stats.t

(** Thrown by [of_device x] when [x] is a device not owned by blktap *)
exception Not_blktap
Expand Down