From 968688463a9af8cb0dd2bab4a8634917455e3336 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Sun, 22 May 2022 00:45:46 +0200 Subject: [PATCH] =?UTF-8?q?Meilleure=20verbosit=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blockcommit_all.sh | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/blockcommit_all.sh b/blockcommit_all.sh index 6ab10cc..bb1b646 100755 --- a/blockcommit_all.sh +++ b/blockcommit_all.sh @@ -5,22 +5,33 @@ VMs=$(sudo virsh list --state-running --name | sort -R) #sudo aa-teardown for vm in $VMs do - echo BLOCKCOMMITTING $vm ... + path_vda=$(sudo virsh domblklist $vm | grep vda | cut -d" " -f 8) + path_vdb=$(sudo virsh domblklist $vm | grep vdb | cut -d" " -f 8) - retour=$(sudo virsh blockcommit $vm vda --active --verbose --pivot --delete 2>&1 | tee /dev/tty) - if [[ "$retour" =~ 'block copy still active' ]] + if [ ! -z "$path_vda" ] then - path_img=$(sudo virsh domblklist $vm | grep vda | cut -d" " -f 8) - sudo virsh blockjob $vm $path_img --pivot --info - sudo virsh blockcommit $vm vda --active --verbose --pivot --delete 2>&1 + echo "-- BLOCKCOMMITTING $vm disk vda ..." + retour=$(sudo virsh blockcommit $vm vda --active --verbose --pivot --delete 2>&1 | tee /dev/tty) + if [[ "$retour" =~ 'block copy still active' ]] + then + echo "-- Finishing blockjob for $vm ..." + sudo virsh blockjob $vm $path_vda --pivot --info + echo "-- BLOCKCOMMITTING $vm ..." + sudo virsh blockcommit $vm vda --active --verbose --pivot --delete 2>&1 + fi fi - retour=$(sudo virsh blockcommit $vm vdb --active --verbose --pivot --delete 2>&1 | tee /dev/tty) - if [[ "$retour" =~ 'block copy still active' ]] + if [ ! -z "$path_vdb" ] then - path_img=$(sudo virsh domblklist $vm | grep vdb | cut -d" " -f 8) - sudo virsh blockjob $vm $path_img --pivot --info - sudo virsh blockcommit $vm vda --active --verbose --pivot --delete 2>&1 + echo "-- BLOCKCOMMITTING $vm disk vdb ..." + retour=$(sudo virsh blockcommit $vm vdb --active --verbose --pivot --de> + if [[ "$retour" =~ 'block copy still active' ]] + then + echo "-- Finishing blockjob for $vm ..." + sudo virsh blockjob $vm $path_vdb --pivot --info + echo "-- BLOCKCOMMITTING $vm ..." + sudo virsh blockcommit $vm vdb --active --verbose --pivot --delete > + fi fi done #sudo systemctl restart apparmor.service