[PATCH] tools/oxenstored: Additional debugging commands

Andrew Cooper posted 1 patch 8 months, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20230824123939.1297171-1-andrew.cooper3@citrix.com
tools/ocaml/xenstored/process.ml | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
[PATCH] tools/oxenstored: Additional debugging commands
Posted by Andrew Cooper 8 months, 2 weeks ago
From: Edwin Török <edwin.torok@cloud.com>

These were added to aid security development, and are useful generally for
debugging.

Signed-off-by: Edwin Török <edwin.torok@cloud.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Christian Lindig <christian.lindig@citrix.com>
CC: Edwin Török <edwin.torok@cloud.com>
CC: Rob Hoes <Rob.Hoes@citrix.com>

I found this hiding down the back of the patchqueue.
---
 tools/ocaml/xenstored/process.ml | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/tools/ocaml/xenstored/process.ml b/tools/ocaml/xenstored/process.ml
index 2e62c7a10e7a..432d66321cbb 100644
--- a/tools/ocaml/xenstored/process.ml
+++ b/tools/ocaml/xenstored/process.ml
@@ -235,6 +235,23 @@ let do_debug con t _domains cons data =
     | "watches" :: _ ->
       let watches = Connections.debug cons in
       Some (watches ^ "\000")
+    | "compact" :: _ ->
+      Gc.compact ();
+      Some "Compacted"
+    | "trim" :: _ ->
+      History.trim ();
+      Some "trimmed"
+    | "txn" :: domid :: _ ->
+      let domid = int_of_string domid in
+      let con = Connections.find_domain cons domid in
+      let b = Buffer.create 128 in
+      let () = con.transactions |> Hashtbl.iter @@ fun id tx ->
+        Printf.bprintf b "paths: %d, operations: %d, quota_reached: %b\n"
+          (List.length tx.Transaction.paths)
+          (List.length tx.Transaction.operations)
+          tx.Transaction.quota_reached
+      in
+      Some (Buffer.contents b)
     | "xenbus" :: domid :: _ ->
       let domid = int_of_string domid in
       let con = Connections.find_domain cons domid in

base-commit: b0cd7499ddd281033548a702c6d61ab13fdd1f67
-- 
2.30.2


Re: [PATCH] tools/oxenstored: Additional debugging commands
Posted by Christian Lindig 8 months, 2 weeks ago
Acked-by: Christian Lindig <christian.lindig@cloud.com>


> On 24 Aug 2023, at 13:39, Andrew Cooper <andrew.cooper3@citrix.com> wrote:
> 
> From: Edwin Török <edwin.torok@cloud.com>
> 
> These were added to aid security development, and are useful generally for
> debugging.
> 
> Signed-off-by: Edwin Török <edwin.torok@cloud.com>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Christian Lindig <christian.lindig@citrix.com>
> CC: Edwin Török <edwin.torok@cloud.com>
> CC: Rob Hoes <Rob.Hoes@citrix.com>
> 
> I found this hiding down the back of the patchqueue.
> ---
> tools/ocaml/xenstored/process.ml | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
> 
> diff --git a/tools/ocaml/xenstored/process.ml b/tools/ocaml/xenstored/process.ml
> index 2e62c7a10e7a..432d66321cbb 100644
> --- a/tools/ocaml/xenstored/process.ml
> +++ b/tools/ocaml/xenstored/process.ml
> @@ -235,6 +235,23 @@ let do_debug con t _domains cons data =
>     | "watches" :: _ ->
>       let watches = Connections.debug cons in
>       Some (watches ^ "\000")
> +    | "compact" :: _ ->
> +      Gc.compact ();
> +      Some "Compacted"
> +    | "trim" :: _ ->
> +      History.trim ();
> +      Some "trimmed"
> +    | "txn" :: domid :: _ ->
> +      let domid = int_of_string domid in
> +      let con = Connections.find_domain cons domid in
> +      let b = Buffer.create 128 in
> +      let () = con.transactions |> Hashtbl.iter @@ fun id tx ->
> +        Printf.bprintf b "paths: %d, operations: %d, quota_reached: %b\n"
> +          (List.length tx.Transaction.paths)
> +          (List.length tx.Transaction.operations)
> +          tx.Transaction.quota_reached
> +      in
> +      Some (Buffer.contents b)
>     | "xenbus" :: domid :: _ ->
>       let domid = int_of_string domid in
>       let con = Connections.find_domain cons domid in
> 
> base-commit: b0cd7499ddd281033548a702c6d61ab13fdd1f67
> -- 
> 2.30.2
>