From 3d394e0e4cbf317cbe126c25aed19732008fbf8b Mon Sep 17 00:00:00 2001 From: Christian Lindig Date: Fri, 20 Dec 2024 11:31:11 +0000 Subject: [PATCH] XSI-1773 clean up swtpm service files We have seen swtpm systemd service files not being removed. We now call Fe_systemctl.stop even when the servive is potentially not running to ensure clean up is happening regardless. Signed-off-by: Christian Lindig --- ocaml/xenopsd/xc/service.ml | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/ocaml/xenopsd/xc/service.ml b/ocaml/xenopsd/xc/service.ml index 0fabf791888..98c942d13a9 100644 --- a/ocaml/xenopsd/xc/service.ml +++ b/ocaml/xenopsd/xc/service.ml @@ -608,26 +608,17 @@ module SystemdDaemonMgmt (D : DAEMONPIDPATH) = struct else None - let is_running ~xs domid = - match of_domid domid with - | None -> - Compat.is_running ~xs domid - | Some key -> - Fe_systemctl.is_active ~service:key - let stop ~xs domid = - match (of_domid domid, is_running ~xs domid) with - | None, true -> + match of_domid domid with + | None when Compat.is_running ~xs domid -> Compat.stop ~xs domid - | Some service, true -> - (* xenstore cleanup is done by systemd unit file *) - let (_ : Fe_systemctl.status) = Fe_systemctl.stop ~service in - () - | Some service, false -> - info "Not trying to stop %s since it's not running" service - | None, false -> + | None -> info "Not trying to stop %s for domid %i since it's not running" D.name domid + | Some service -> + (* call even when not running for clean up *) + let (_ : Fe_systemctl.status) = Fe_systemctl.stop ~service in + () let start_daemon ~path ~args ~domid () = debug "Starting daemon: %s with args [%s]" path (String.concat "; " args) ;