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

[PATCH v2 5/8] tools/ocaml/xenstored: Automatically resume when possible


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Edwin Török <edvin.torok@xxxxxxxxxx>
  • Date: Fri, 15 Jan 2021 22:28:47 +0000
  • Authentication-results: esa4.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>, Pau Ruiz Safont <pau.safont@xxxxxxxxxx>
  • Delivery-date: Fri, 15 Jan 2021 22:30:00 +0000
  • Ironport-sdr: 8JIRRQ/vTnM8hZE8q0nckRqCFDUqGtRyZFzsPEFzkfGMNg4c5LceWHyUP9Jxq7zq2wErry/YY6 p8azCp7mDxtfmHPk5pnN0E8LDinNV9HZm7OYn6Nn1wfrJiWO8n4HQMpkv3v6JsML2mAC/G/nkF R7HdRGjbgRQV46p7co/hjVDRB/mieTIbLw2y/Q7LIRfsOmMwVCRzSS8cl9P8ZheLCpbdcU1orK Vp8BlpFnAS9hMgrqkDIaa+gTHCb07n3Ot13bPjyGuR4SfgwmnyX8ZWFg2/XvL5M8zqeHQIJOdE his=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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@xxxxxxxxxx>
Reviewed-by: Pau Ruiz Safont <pau.safont@xxxxxxxxxx>
Reviewed-by: Christian Lindig <christian.lindig@xxxxxxxxxx>

---
Changed since V1:
* post publicly now that the XSA is out
---
 tools/ocaml/xenstored/xenstored.ml | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/tools/ocaml/xenstored/xenstored.ml 
b/tools/ocaml/xenstored/xenstored.ml
index 6b5381962b..500d96753b 100644
--- a/tools/ocaml/xenstored/xenstored.ml
+++ b/tools/ocaml/xenstored/xenstored.ml
@@ -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 -> ());
        ()
-- 
2.29.2




 


Rackspace

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