From: David Galloway Date: Wed, 14 Jan 2026 20:36:11 +0000 (-0500) Subject: scripts: Refactor restart_libvirt_services X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F2529%2Fhead;p=ceph-build.git scripts: Refactor restart_libvirt_services Signed-off-by: David Galloway --- 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