| 
    
 [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v1 6/9] tools/ocaml/xenstored: use gnttab instead of xenctrl's foreign_map_range
 This is an oxenstored port of the following C xenstored commit:
38eeb3864de40aa568c48f9f26271c141c62b50b tools/xenstored: Drop mapping of the 
ring via foreign map
Now only Xenctrl.domain_getinfo remains as the last use of unstable xenctrl 
interface
in oxenstored.
Depends on: tools/ocaml: safer Xenmmap interface
(without it the code would build but the wrong unmap function would get
 called on domain destruction)
CC: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Signed-off-by: Edwin Török <edvin.torok@xxxxxxxxxx>
---
 tools/ocaml/xenstored/domains.ml   | 7 +++++--
 tools/ocaml/xenstored/xenstored.ml | 3 ++-
 2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/tools/ocaml/xenstored/domains.ml b/tools/ocaml/xenstored/domains.ml
index 17fe2fa257..d9cb693751 100644
--- a/tools/ocaml/xenstored/domains.ml
+++ b/tools/ocaml/xenstored/domains.ml
@@ -22,6 +22,7 @@ let xc = Xenctrl.interface_open ()
 
 type domains = {
        eventchn: Event.t;
+       gnttab: Gnt.Gnttab.interface;
        table: (Xenctrl.domid, Domain.t) Hashtbl.t;
 
        (* N.B. the Queue module is not thread-safe but oxenstored is 
single-threaded. *)
@@ -42,8 +43,9 @@ type domains = {
        mutable n_penalised: int; (* Number of domains with less than maximum 
credit *)
 }
 
-let init eventchn on_first_conflict_pause = {
+let init eventchn gnttab on_first_conflict_pause = {
        eventchn = eventchn;
+       gnttab;
        table = Hashtbl.create 10;
        doms_conflict_paused = Queue.create ();
        doms_with_conflict_penalty = Queue.create ();
@@ -123,7 +125,8 @@ let resume _doms _domid =
        ()
 
 let create doms domid mfn port =
-       let interface = Xenctrl.map_foreign_range xc domid 
(Xenmmap.getpagesize()) mfn in
+       let mapping = Gnt.(Gnttab.map_exn doms.gnttab { domid; ref = xenstore} 
true) in
+       let interface = Gnt.Gnttab.Local_mapping.to_pages doms.gnttab mapping in
        let dom = Domain.make domid mfn port interface doms.eventchn in
        Hashtbl.add doms.table domid dom;
        Domain.bind_interdomain dom;
diff --git a/tools/ocaml/xenstored/xenstored.ml 
b/tools/ocaml/xenstored/xenstored.ml
index f3e4697dea..a232e4c616 100644
--- a/tools/ocaml/xenstored/xenstored.ml
+++ b/tools/ocaml/xenstored/xenstored.ml
@@ -265,6 +265,7 @@ let _ =
 
        let store = Store.create () in
        let eventchn = Event.init () in
+       let gnttab = Gnt.Gnttab.interface_open () in
        let next_frequent_ops = ref 0. in
        let advance_next_frequent_ops () =
                next_frequent_ops := (Unix.gettimeofday () +. 
!Define.conflict_max_history_seconds)
@@ -272,7 +273,7 @@ let _ =
        let delay_next_frequent_ops_by duration =
                next_frequent_ops := !next_frequent_ops +. duration
        in
-       let domains = Domains.init eventchn advance_next_frequent_ops in
+       let domains = Domains.init eventchn gnttab advance_next_frequent_ops in
 
        (* For things that need to be done periodically but more often
         * than the periodic_ops function *)
-- 
2.25.1
 
  | 
  
![]()  | 
            
         Lists.xenproject.org is hosted with RackSpace, monitoring our  |