From ac29645214aa8c7a642f1cd41fc80d4b86ccfafa Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 11 Mar 2021 18:31:51 +0000 Subject: [PATCH] M #-: Fix SIGSEV on resize failure --- src/lcm/LifeCycleStates.cc | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/lcm/LifeCycleStates.cc b/src/lcm/LifeCycleStates.cc index b61fbbf1a8..01bd77a87d 100644 --- a/src/lcm/LifeCycleStates.cc +++ b/src/lcm/LifeCycleStates.cc @@ -2430,11 +2430,12 @@ void LifeCycleManager::trigger_resize_failure(int vid) { trigger([this, vid] { Template deltas; - HostShareCapacity sr, sr_orig; - int vm_uid, vm_gid, hid; + int vm_uid, vm_gid; if ( auto vm = vmpool->get(vid) ) { + HostShareCapacity sr, sr_orig; + VirtualMachine::LcmState state = vm->get_lcm_state(); if (state == VirtualMachine::HOTPLUG_RESIZE) @@ -2450,8 +2451,6 @@ void LifeCycleManager::trigger_resize_failure(int vid) return; } - hid = vm->get_hid(); - vm->get_capacity(sr); auto vattr = vm->get_template_attribute("RESIZE"); @@ -2491,22 +2490,22 @@ void LifeCycleManager::trigger_resize_failure(int vid) vm->reset_resize(); vmpool->update(vm.get()); + + // Revert host capacity + if (auto host = hpool->get(vm->get_hid())) + { + host->del_capacity(sr); + + host->add_capacity(sr_orig); + + hpool->update(host.get()); + } } else { return; } - // Revert host capacity - if (auto host = hpool->get(hid)) - { - host->del_capacity(sr); - - host->add_capacity(sr_orig); - - hpool->update(host.get()); - } - // Quota rollback Quotas::quota_del(Quotas::VM, vm_uid, vm_gid, &deltas); });