package xenstore

  1. Overview
  2. Docs
Xenstore protocol in pure OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

xenstore-2.3.0.tbz
sha256=d63c6bbcb2d3c297767d83c0a0f6dd46cecfd4e691f1cf5c5b6554445ec1b3f4
sha512=5cea990ab16ef708e53605172f708dde6ed15981cca6890939274db6efde1e5b2f9ec5c659d4d2f4115c5e0c3b69bcacc798a0d7fd5c1b75b83ddccd699de189

doc/src/xenstore.server/quota_interface.ml.html

Source file quota_interface.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
include Namespace.Unsupported

let ( |> ) a b = b a

let read t (perms: Perms.t) (path: Store.Path.t) =
  Perms.has perms Perms.CONFIGURE;
  match Store.Path.to_string_list path with
  | [] -> ""
  | "default" :: [] -> ""
  | "entries-per-domain" :: [] -> ""
  | "number-of-entries" :: [] -> ""
  | "number-of-registered-watches" :: [] -> ""
  | "number-of-active-transactions" :: [] -> ""
  | "number-of-queued-watch-events" :: [] -> ""
  | "default" :: "number-of-entries" :: [] ->
    string_of_int (!Quota.maxent)
  | "default" :: "entry-length" :: [] ->
    string_of_int (!Quota.maxsize)
  | "default" :: "number-of-registered-watches" :: [] ->
    string_of_int (!Quota.maxwatch)
  | "default" :: "number-of-active-transactions" :: [] ->
    string_of_int (!Quota.maxtransaction)
  | "default" :: "number-of-queued-watch-events" :: [] ->
    string_of_int (!Quota.maxwatchevent)
  | "entries-per-domain" :: domid :: [] ->
    let q = t.Transaction.store.Store.quota in
    let domid = int_of_string domid in
    let n = Quota.get q domid in
    string_of_int n
  | "number-of-entries" :: domid :: [] ->
    begin match Quota.get_override Quota.maxent_overrides (int_of_string domid) with
      | Some x -> string_of_int x
      | None -> Store.Path.doesnt_exist path
    end
  | "number-of-registered-watches" :: domid :: [] ->
    begin match Quota.get_override Quota.maxwatch_overrides (int_of_string domid) with
      | Some x -> string_of_int x
      | None -> Store.Path.doesnt_exist path
    end
  | "number-of-active-transactions" :: domid :: [] ->
    begin match Quota.get_override Quota.maxtransaction_overrides (int_of_string domid) with
      | Some x -> string_of_int x
      | None -> Store.Path.doesnt_exist path
    end
  | "number-of-queued-watch-events" :: domid :: [] ->
    begin match Quota.get_override Quota.maxwatchevent_overrides (int_of_string domid) with
      | Some x -> string_of_int x
      | None -> Store.Path.doesnt_exist path
    end
  | _ -> Store.Path.doesnt_exist path

let exists t perms path = try ignore(read t perms path); true with Store.Path.Doesnt_exist _ -> false

let write _t _creator perms path value =
  Perms.has perms Perms.CONFIGURE;
  match Store.Path.to_string_list path with
  | "default" :: "number-of-entries" :: [] ->
    Quota.maxent := int_of_string value
  | "default" :: "entry-length" :: [] ->
    Quota.maxsize := int_of_string value
  | "default" :: "number-of-registered-watches" :: [] ->
    Quota.maxwatch := int_of_string value
  | "default" :: "number-of-active-transactions" :: [] ->
    Quota.maxtransaction := int_of_string value
  | "default" :: "number-of-queued-watch-events" :: [] ->
    Quota.maxwatchevent := int_of_string value
  | "number-of-entries" :: domid :: [] ->
    Quota.set_override Quota.maxent_overrides (int_of_string domid) (Some (int_of_string value))
  | "number-of-registered-watches" :: domid :: [] ->
    Quota.set_override Quota.maxwatch_overrides (int_of_string domid) (Some (int_of_string value))
  | "number-of-active-transactions" :: domid :: [] ->
    Quota.set_override Quota.maxtransaction_overrides (int_of_string domid) (Some (int_of_string value))
  | "number-of-queued-watch-events" :: domid :: [] ->
    Quota.set_override Quota.maxwatchevent_overrides (int_of_string domid) (Some (int_of_string value))
  | _ -> Store.Path.doesnt_exist path

let list t perms path =
  Perms.has perms Perms.CONFIGURE;
  match Store.Path.to_string_list path with
  | [] -> [ "default"; "entries-per-domain"; "number-of-entries"; "number-of-registered-watches"; "number-of-active-transactions"; "number-of-queued-watch-events" ]
  | [ "default" ] -> [ "number-of-entries"; "entry-length"; "number-of-registered-watches"; "number-of-active-transactions"; "number-of-queued-watch-events" ]
  | [ "entries-per-domain" ] ->
    let q = t.Transaction.store.Store.quota in
    Quota.list q |> List.map fst |> List.map string_of_int
  | [ "number-of-entries" ] ->
    Quota.list_overrides Quota.maxent_overrides |> List.map fst |> List.map string_of_int
  | [ "number-of-registered-watches" ] ->
    Quota.list_overrides Quota.maxwatch_overrides |> List.map fst |> List.map string_of_int
  | [ "number-of-active-transactions" ] ->
    Quota.list_overrides Quota.maxtransaction_overrides |> List.map fst |> List.map string_of_int
  | [ "number-of-queued-watch-events" ] ->
    Quota.list_overrides Quota.maxwatchevent_overrides |> List.map fst |> List.map string_of_int
  | _ -> []


let rm _t perms path =
  Perms.has perms Perms.CONFIGURE;
  match Store.Path.to_string_list path with
  | "number-of-entries" :: domid :: [] ->
    Quota.set_override Quota.maxent_overrides (int_of_string domid) None
  | "number-of-registered-watches" :: domid :: [] ->
    Quota.set_override Quota.maxwatch_overrides (int_of_string domid) None
  | "number-of-active-transactions" :: domid :: [] ->
    Quota.set_override Quota.maxtransaction_overrides (int_of_string domid) None
  | "number-of-queued-watch-events" :: domid :: [] ->
    Quota.set_override Quota.maxwatchevent_overrides (int_of_string domid) None
  | _ -> raise Perms.Permission_denied
OCaml

Innovation. Community. Security.