1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-21 13:34:06 +03:00

run: detect daemons when run via wrapper commands

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 <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2021-11-24 12:02:20 +00:00
parent 6e1baedd2f
commit f17b9c57c5

22
run.in
View File

@ -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):