#!/bin/bash count=$1 VMs=$(sudo virsh list --state-running --name | sort -R) #sudo aa-teardown for vm in $VMs do echo BLOCKCOMMITTING $vm ... retour=$(sudo virsh blockcommit $vm vda --active --verbose --pivot --delete 2>&1 | tee /dev/tty) if [[ "$retour" =~ 'block copy still active' ]] 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 fi retour=$(sudo virsh blockcommit $vm vdb --active --verbose --pivot --delete 2>&1 | tee /dev/tty) if [[ "$retour" =~ 'block copy still active' ]] 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 fi done #sudo systemctl restart apparmor.service