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

[xen master] tools/oxenstored: Start live update process



commit 00c48f57ab3614e9ff1e16aa1d27ce4880d425ce
Author:     Edwin Török <edvin.torok@xxxxxxxxxx>
AuthorDate: Fri Jan 8 11:57:37 2021 +0000
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Fri Jan 22 16:50:18 2021 +0000

    tools/oxenstored: Start live update process
    
    Signed-off-by: Edwin Török <edvin.torok@xxxxxxxxxx>
    Reviewed-by: Pau Ruiz Safont <pau.safont@xxxxxxxxxx>
    Reviewed-by: Christian Lindig <christian.lindig@xxxxxxxxxx>
---
 tools/ocaml/xenstored/logging.ml   |  3 +++
 tools/ocaml/xenstored/process.ml   |  6 ++++--
 tools/ocaml/xenstored/xenstored.ml | 19 +++++++++++++++----
 3 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/tools/ocaml/xenstored/logging.ml b/tools/ocaml/xenstored/logging.ml
index 1ede131329..39c3036155 100644
--- a/tools/ocaml/xenstored/logging.ml
+++ b/tools/ocaml/xenstored/logging.ml
@@ -327,6 +327,9 @@ let end_transaction ~tid ~con =
        if !access_log_transaction_ops && tid <> 0
        then access_logging ~tid ~con (XbOp Xenbus.Xb.Op.Transaction_end) 
~level:Debug
 
+let live_update () =
+       xb_op ~tid:0 ~con:"" ~ty:Xenbus.Xb.Op.Debug "Live update begin"
+
 let xb_answer ~tid ~con ~ty data =
        let print, level = match ty with
                | Xenbus.Xb.Op.Error when String.startswith "ENOENT" data -> 
!access_log_read_ops , Warn
diff --git a/tools/ocaml/xenstored/process.ml b/tools/ocaml/xenstored/process.ml
index bf18488094..7f7b72e1a1 100644
--- a/tools/ocaml/xenstored/process.ml
+++ b/tools/ocaml/xenstored/process.ml
@@ -111,6 +111,7 @@ let string_of_t t =
 let launch_exn t =
        let executable, rest = args_of_t t in
        let args = Array.of_list (executable :: rest) in
+       info "Launching %s, args: %s" executable (String.concat " " rest);
        Unix.execv args.(0) args
 
 let validate_exn t =
@@ -147,7 +148,7 @@ let parse_live_update args =
                | "-s" :: _ ->
                        let timeout = ref 60 in
                        let force = ref false in
-                       Arg.parse_argv ~current:(ref 1) (Array.of_list args)
+                       Arg.parse_argv ~current:(ref 0) (Array.of_list args)
                                [ ( "-t"
                                  , Arg.Set_int timeout
                                  , "timeout in seconds to wait for active 
transactions to finish"
@@ -197,7 +198,8 @@ let do_debug con t _domains cons data =
        then None
        else try match split None '\000' data with
        | "live-update" :: params ->
-               LiveUpdate.parse_live_update params
+               let dropped_trailing_nul = params |> List.rev |> List.tl |> 
List.rev in
+               LiveUpdate.parse_live_update dropped_trailing_nul
        | "print" :: msg :: _ ->
                Logging.xb_op ~tid:0 ~ty:Xenbus.Xb.Op.Debug ~con:"=======>" msg;
                None
diff --git a/tools/ocaml/xenstored/xenstored.ml 
b/tools/ocaml/xenstored/xenstored.ml
index a9894f0051..b7b3b43f79 100644
--- a/tools/ocaml/xenstored/xenstored.ml
+++ b/tools/ocaml/xenstored/xenstored.ml
@@ -483,18 +483,29 @@ let _ =
                in
 
        Systemd.sd_notify_ready ();
+       let live_update = ref false in
        while not (!quit && Connections.prevents_quit cons = [])
        do
                try
-                       main_loop ()
+                       main_loop ();
+                       live_update := Process.LiveUpdate.should_run cons;
+                       if !live_update || !quit then begin
+                               (* don't initiate live update if saving state 
fails *)
+                               DB.to_file store cons Disk.xs_daemon_database;
+                               quit := true;
+                       end
                with exc ->
-                       error "caught exception %s" (Printexc.to_string exc);
+                       let bt = Printexc.get_backtrace () in
+                       error "caught exception %s: %s" (Printexc.to_string 
exc) bt;
                        if cf.reraise_top_level then
                                raise exc
        done;
        info "stopping xenstored";
-       DB.to_file store cons Disk.xs_daemon_database;
        (* unlink pidfile so that launch-xenstore works again *)
        Unixext.unlink_safe pidfile;
        (match cf.pidfile with Some pidfile -> Unixext.unlink_safe pidfile | 
None -> ());
-       ()
+
+       if !live_update then begin
+               Logging.live_update ();
+               Process.LiveUpdate.launch_exn !Process.LiveUpdate.state
+       end
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

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