[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 15/17] 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: Tue, 11 May 2021 19:05:28 +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" <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Delivery-date: Tue, 11 May 2021 18:19:57 +0000
  • Ironport-hdrordr: A9a23:jUJ+BaDEC34bMKflHelo55DYdb4zR+YMi2TDt3oddfU1SL38qy nKpp4mPHDP5wr5NEtPpTniAtjjfZq/z/5ICOAqVN/PYOCPggCVxepZnOjfKlPbehEX9oRmpN 1dm6oVMqyMMbCt5/yKnDVRELwbsaa6GLjDv5a785/0JzsaE52J6W1Ce2GmO3wzfiZqL7wjGq GR48JWzgDQAkj+PqyAdx84t/GonayzqK7b
  • Ironport-sdr: CKYOs+i1d3uxTBukfgQWpA1/0Q6N5xF4YW3jDwQw4XsDP1Yu/ygVFpSXvRJ3wFHVWtIMu3qyOX F9MHR0nLkK4Jyspb534EhqoXML/Esnp857rRv0rWlQ5smYpGBZDZx0sGM3p6785xDL2X7wBbEX Qb5pYN3pIQllJJ3iigpKUx5qV+7pSHODIad8Vvb/r5S/HNEiwr5l2rtW5DFqtLRrgjc6ygT9t2 zkO4fJLvzYevOalpREIDVvSWqSfkDcLy1i2K+LfbAv9VRyHxi/RD7guWQCnoUkR43o9Ah/vROA G+8=
  • 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 a6b86b167c..75c35107d5 100644
--- a/tools/ocaml/xenstored/xenstored.ml
+++ b/tools/ocaml/xenstored/xenstored.ml
@@ -446,6 +446,7 @@ let main () =
 
        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)
@@ -453,7 +454,7 @@ let main () =
        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®.