From 824e3e07e30c855c86c08d801c89cbb702b2b90a Mon Sep 17 00:00:00 2001 From: "Fabio M. Di Nitto" Date: Sat, 5 Aug 2023 07:49:54 +0200 Subject: [PATCH] virsh: add wrapper to serialize calls to virsh list avoid storm of virsh list that overloads libvirtd API causing unnecessary timeouts during pcmk monitoring operations. Resolves: https://github.com/ClusterLabs/anvil/issues/395 Signed-off-by: Fabio M. Di Nitto --- Anvil/Tools.pm | 2 +- tools/Makefile.am | 5 ++--- tools/anvil-virsh-wrapper | 10 ++++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) create mode 100755 tools/anvil-virsh-wrapper diff --git a/Anvil/Tools.pm b/Anvil/Tools.pm index 6b0373c6..6df7b561 100644 --- a/Anvil/Tools.pm +++ b/Anvil/Tools.pm @@ -1308,7 +1308,7 @@ sub _set_paths useradd => "/usr/sbin/useradd", usermod => "/usr/sbin/usermod", uuidgen => "/usr/bin/uuidgen", - virsh => "/usr/bin/virsh", + virsh => "/usr/sbin/anvil-virsh-wrapper", 'virt-install' => "/usr/bin/virt-install", websockify => "/usr/bin/websockify", wipefs => "/usr/sbin/wipefs", diff --git a/tools/Makefile.am b/tools/Makefile.am index 92974bba..ee9dd223 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,7 +1,5 @@ MAINTAINERCLEANFILES = Makefile.in -# XXX recheck after rebase! - dist_sbin_SCRIPTS = \ anvil-access-module \ anvil-boot-server \ @@ -46,6 +44,7 @@ dist_sbin_SCRIPTS = \ anvil-update-states \ anvil-update-system \ anvil-version-changes \ + anvil-virsh-wrapper \ anvil-watch-bonds \ anvil-watch-drbd \ anvil-watch-power \ @@ -68,7 +67,7 @@ dist_sbin_SCRIPTS = \ striker-scan-network \ striker-show-db-counts \ striker-update-cluster - + fencedir = ${FASEXECPREFIX}/sbin dist_fence_SCRIPTS = \ diff --git a/tools/anvil-virsh-wrapper b/tools/anvil-virsh-wrapper new file mode 100755 index 00000000..c42bc2c4 --- /dev/null +++ b/tools/anvil-virsh-wrapper @@ -0,0 +1,10 @@ +#!/bin/sh -e + +( + if [ "$1" != "list" ]; then + virsh $@ + exit $? + fi + flock -e 200 + virsh $@ +) 200>/tmp/virsh.lock