M #-: Fix SIGSEV on resize failure

This commit is contained in:
Ruben S. Montero committed 2021-03-11 18:47:06 +00:00
1 parent a5001bfa1e
commit ac29645214
1 file changed
+13 -14
+13 -14
View File
@@ -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);
});