From 7689ba7e2c51b3a2b44c55c52722fe82335e68c6 Mon Sep 17 00:00:00 2001 From: David Galloway Date: Wed, 14 Jan 2026 15:36:11 -0500 Subject: [PATCH] scripts: Refactor restart_libvirt_services Signed-off-by: David Galloway --- scripts/build_utils.sh | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/scripts/build_utils.sh b/scripts/build_utils.sh index 91bd3c9b..eed84e97 100755 --- a/scripts/build_utils.sh +++ b/scripts/build_utils.sh @@ -1128,13 +1128,27 @@ clear_libvirt_networks() { } restart_libvirt_services() { - # restart libvirt services - if test -f /etc/redhat-release; then - sudo service libvirtd restart + if command -v systemctl >/dev/null 2>&1; then + # systemd systems + if systemctl list-unit-files | grep -q '^libvirt-bin\.service'; then + sudo systemctl restart libvirt-bin 2>/dev/null || sudo systemctl restart libvirtd + else + sudo systemctl restart libvirtd + fi + + # Restart guests service if it exists + systemctl list-unit-files | grep -q '^libvirt-guests\.service' && \ + sudo systemctl restart libvirt-guests else - sudo service libvirt-bin restart + # SysVinit systems + if sudo service libvirt-bin restart 2>/dev/null; then + : + else + sudo service libvirtd restart + fi + + sudo service libvirt-guests restart 2>/dev/null || true fi - sudo service libvirt-guests restart } # Function to update vagrant boxes on static libvirt Jenkins builders used for ceph-ansible and ceph-docker testing -- 2.47.3