From f17b9c57c57bd237cbb21bbc872325a6c35bf77b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Wed, 24 Nov 2021 12:02:20 +0000 Subject: [PATCH] run: detect daemons when run via wrapper commands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The run script tries to detect when a daemon is being run in order to shutdown other systemd unit files that clash. As implemented this only works if the daemon name is the first argument. This won't be the case if running via GDB or strace eg ./run strace -e trace=openat ./build/src/virtqemud We need to check all argv to find which might be a daemon path/name. Reviewed-by: Ján Tomko Signed-off-by: Daniel P. Berrangé --- run.in | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/run.in b/run.in index 64f99751fe..174b191675 100644 --- a/run.in +++ b/run.in @@ -130,18 +130,18 @@ def change_unit(name, action): try_stop_units = [] if is_systemd_host(): - name = os.path.basename(prog) - maybe_stopped_units = [] - if is_modular_daemon(name): - # Only need to stop libvirtd or this specific modular unit - maybe_stopped_units += daemon_units("libvirtd") - maybe_stopped_units += daemon_units(name) - elif is_monolithic_daemon(name): - # Need to stop libvirtd and/or all modular units - maybe_stopped_units += daemon_units("libvirtd") - for entry in modular_daemons: - maybe_stopped_units += daemon_units(entry) + for arg in sys.argv: + name = os.path.basename(arg) + if is_modular_daemon(name): + # Only need to stop libvirtd or this specific modular unit + maybe_stopped_units += daemon_units("libvirtd") + maybe_stopped_units += daemon_units(name) + elif is_monolithic_daemon(name): + # Need to stop libvirtd and/or all modular units + maybe_stopped_units += daemon_units("libvirtd") + for entry in modular_daemons: + maybe_stopped_units += daemon_units(entry) for unit in maybe_stopped_units: if is_unit_active(unit):