]> xenbits.xensource.com Git - xen.git/commitdiff
oxenstored: implement XS_RESET_WATCHES
authorWei Liu <wei.liu2@citrix.com>
Tue, 9 Jun 2015 10:08:14 +0000 (11:08 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 17 Jun 2015 10:36:53 +0000 (11:36 +0100)
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: David Scott <dave.scott@citrix.com>
tools/ocaml/libs/xb/op.ml
tools/ocaml/libs/xb/xb.mli
tools/ocaml/xenstored/connection.ml
tools/ocaml/xenstored/logging.ml
tools/ocaml/xenstored/process.ml

index 0ee866676f3ee6cef53b391007303b24e094e2d0..69346d806657a47bce95cb56291f53ce8b70c2ed 100644 (file)
@@ -19,7 +19,8 @@ type operation = Debug | Directory | Read | Getperms |
                  Transaction_end | Introduce | Release |
                  Getdomainpath | Write | Mkdir | Rm |
                  Setperms | Watchevent | Error | Isintroduced |
-                 Resume | Set_target | Restrict | Invalid
+                 Resume | Set_target | Restrict | Reset_watches |
+                 Invalid
 
 let operation_c_mapping =
        [| Debug; Directory; Read; Getperms;
@@ -27,7 +28,7 @@ let operation_c_mapping =
            Transaction_end; Introduce; Release;
            Getdomainpath; Write; Mkdir; Rm;
            Setperms; Watchevent; Error; Isintroduced;
-           Resume; Set_target; Restrict |]
+           Resume; Set_target; Restrict; Reset_watches |]
 let size = Array.length operation_c_mapping
 
 let array_search el a =
@@ -68,4 +69,5 @@ let to_string ty =
        | Resume                -> "RESUME"
        | Set_target            -> "SET_TARGET"
        | Restrict              -> "RESTRICT"
+       | Reset_watches         -> "RESET_WATCHES"
        | Invalid               -> "INVALID"
index 4e1f833b9f61c23d66564678462e6e7eccf31eb2..6c242da4463ef2b480d4f705aa73c7f8a78b255b 100644 (file)
@@ -23,6 +23,7 @@ module Op :
       | Resume
       | Set_target
       | Restrict
+      | Reset_watches
       | Invalid
     val operation_c_mapping : operation array
     val size : int
index b4dc9cbe642ec38b99ce80e212eb2ebc4a002cb5..9de49780da695e483d70c1e2f814ed16495b012c 100644 (file)
@@ -186,6 +186,13 @@ let del_watch con path token =
        con.nb_watches <- con.nb_watches - 1;
        apath, w
 
+let del_watches con =
+  Hashtbl.clear con.watches
+
+let del_transactions con =
+  Hashtbl.clear con.transactions;
+  con.nb_watches <- 0
+
 let list_watches con =
        let ll = Hashtbl.fold 
                (fun _ watches acc -> List.map (fun watch -> watch.path, watch.token) watches :: acc)
index 665b922419655fa80c2e84dc75273e5e463ee1bc..4c9003264abb67400bdfa6325a7ccf922da6322b 100644 (file)
@@ -242,6 +242,7 @@ let string_of_access_type = function
        | Xenbus.Xb.Op.Rm                -> "rm       "
        | Xenbus.Xb.Op.Setperms          -> "setperms "
        | Xenbus.Xb.Op.Restrict          -> "restrict "
+       | Xenbus.Xb.Op.Reset_watches     -> "reset watches"
        | Xenbus.Xb.Op.Set_target        -> "settarget"
 
        | Xenbus.Xb.Op.Error             -> "error    "
index 0620585297371eff6ad602f29c590c7044240242..e8276787b88eaa48c235b5588f130cf5360c9c51 100644 (file)
@@ -272,6 +272,11 @@ let do_restrict con t domains cons data =
        in
        Connection.restrict con domid
 
+(* only in xen >= 4.2 *)
+let do_reset_watches con t domains cons data =
+  Connection.del_watches con;
+  Connection.del_transactions con
+
 (* only in >= xen3.3                                                                                    *)
 (* we ensure backward compatibility with restrict by counting the number of argument of set_target ...  *)
 (* This is not very elegant, but it is safe as 'restrict' only restricts permission of dom0 connections *)
@@ -324,6 +329,7 @@ let function_of_type ty =
        | Xenbus.Xb.Op.Resume            -> reply_ack do_resume
        | Xenbus.Xb.Op.Set_target        -> reply_ack do_set_target
        | Xenbus.Xb.Op.Restrict          -> reply_ack do_restrict
+       | Xenbus.Xb.Op.Reset_watches     -> reply_ack do_reset_watches
        | Xenbus.Xb.Op.Invalid           -> reply_ack do_error
        | _                              -> reply_ack do_error