[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


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Edwin Török <edvin.torok@xxxxxxxxxx>
  • Date: Thu, 27 Aug 2020 18:35:57 +0100
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Edwin Török <edvin.torok@xxxxxxxxxx>, "Christian Lindig" <christian.lindig@xxxxxxxxxx>, David Scott <dave@xxxxxxxxxx>, "Ian Jackson" <ian.jackson@xxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Delivery-date: Thu, 27 Aug 2020 17:37:03 +0000
  • Ironport-sdr: BELEP7zOoNqOqGTxOXNCRHluZrhHnLuPRXsfTI5Cn3m1swmjv5IrvyQ+R/WCq23uJLuo4mF/Ry 4nKV5AM7L1VZ73yDWX6JIA+UXnyB+qZCaF8cdJhETWDw4HDXvZt3WC6iOYPPTuXD2ceZ2m82TT 3UAm9uJObUmXH0dqsTA2HSlfN5JlAv1KubDeBQhgk2hvW7NtxcvSniLL0ylepA2o6RDuJBVdAu +mKDuaj9M+y6NE5RgsjHC8ucF2MdN9AgZe5YnmxpqVMe+tfJz7Fgs422r/KT6CJ5chtT2F0w+D muk=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.