]> xenbits.xensource.com Git - xen.git/commitdiff
tools/oxenstored: Automatically resume when possible
authorEdwin Török <edvin.torok@citrix.com>
Fri, 8 Jan 2021 11:57:37 +0000 (11:57 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 22 Jan 2021 15:22:42 +0000 (15:22 +0000)
When a `db` file exists use it to resume oxenstored.  It will contains a
xenstore tree, domain reconnection info, and watches.

It is currently missing data about all active socket connections, so a
toolstack should ideally be stopped and restarted too.

Tell systemd about oxenstored's PID and allow it to restart on success.

This should make updating oxenstored as easy as: `systemctl stop -s SIGTERM
xenstored` on a suitable xenstored version.

Signed-off-by: Edwin Török <edvin.torok@citrix.com>
Reviewed-by: Pau Ruiz Safont <pau.safont@citrix.com>
Reviewed-by: Christian Lindig <christian.lindig@citrix.com>
tools/ocaml/xenstored/xenstored.ml

index 53d86618f2b8a517b40c69f939273da403eadcef..a9894f00517b5bf5581fa6cb9ed92215c4d3f56d 100644 (file)
@@ -292,9 +292,8 @@ let _ =
        List.iter (fun path ->
                Store.write store Perms.Connection.full_rights path "") Store.Path.specials;
 
-       let filename = Paths.xen_run_stored ^ "/db" in
-       if cf.restart && Sys.file_exists filename then (
-               DB.from_file store domains cons filename;
+       if cf.restart && Sys.file_exists Disk.xs_daemon_database then (
+               DB.from_file store domains cons Disk.xs_daemon_database;
                Event.bind_dom_exc_virq eventchn
        ) else (
                if !Disk.enable then (
@@ -320,7 +319,7 @@ let _ =
        Sys.set_signal Sys.sigpipe Sys.Signal_ignore;
 
        if cf.activate_access_log then begin
-               let post_rotate () = DB.to_file store cons (Paths.xen_run_stored ^ "/db") in
+               let post_rotate () = DB.to_file store cons Disk.xs_daemon_database in
                Logging.init_access_log post_rotate
        end;
 
@@ -494,5 +493,8 @@ let _ =
                                raise exc
        done;
        info "stopping xenstored";
-       DB.to_file store cons (Paths.xen_run_stored ^ "/db");
+       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 -> ());
        ()