From: Jonathan Davies Date: Fri, 7 Apr 2017 13:27:22 +0000 (+0100) Subject: oxenstored: make --restart option best-effort X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=ce70926b4f88d3f7510bd4699dc7fc3996539084;p=people%2Froyger%2Fxen.git oxenstored: make --restart option best-effort Only attempt to restore from saved state if it exists. Without this, oxenstored immediately exits with an exception if the --restart option is provided but the state file is not present. (The time-of-check to time-of-use race isn't a concern as oxenstored is the only thing that should write the state file.) Signed-off-by: Jonathan Davies Reviewed-by: Wei Liu Reviewed-by: Christian Lindig Release-acked-by: Julien Grall --- diff --git a/tools/ocaml/xenstored/xenstored.ml b/tools/ocaml/xenstored/xenstored.ml index 77fd9e3bac..bb780d0459 100644 --- a/tools/ocaml/xenstored/xenstored.ml +++ b/tools/ocaml/xenstored/xenstored.ml @@ -287,8 +287,9 @@ let _ = Logging.init_xenstored_log(); - if cf.restart then ( - DB.from_file store domains cons (Paths.xen_run_stored ^ "/db"); + let filename = Paths.xen_run_stored ^ "/db" in + if cf.restart && Sys.file_exists filename then ( + DB.from_file store domains cons filename; Event.bind_dom_exc_virq eventchn ) else ( if !Disk.enable then (