From c194e6c6641d28da123af6a8ed76c99302900e4e Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Sat, 14 Oct 2023 07:26:51 +0200 Subject: [PATCH] kvm-host: revert remote DRBD role on migration error (untested) --- kvm-host/files/migrate-vm.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kvm-host/files/migrate-vm.sh b/kvm-host/files/migrate-vm.sh index 4676a123..622dc228 100644 --- a/kvm-host/files/migrate-vm.sh +++ b/kvm-host/files/migrate-vm.sh @@ -299,6 +299,12 @@ migrate_to() { if is_vm_running_locally "${vm}"; then migrate_vm_to "${vm}" "${remote_ip}" + retcode=$? + if [ ${retcode} != 0 ]; then + echo "An error occured while migrating ${vm}: ${retval}" >&2 + set_drbd_role secondary "${resource}" "${remote_ip}" + exit 1 + fi else echo "${vm} is not running locally, so it won't be started on ${remote_host}" fi