Change in ovirt-engine[master]: core: prevent removal of all images of prestarted stateless vm

ahadas at redhat.com ahadas at redhat.com
Thu Jun 23 08:55:06 UTC 2016


Arik Hadas has submitted this change and it was merged.

Change subject: core: prevent removal of all images of prestarted stateless vm
......................................................................


core: prevent removal of all images of prestarted stateless vm

When prestarted VM shuts down two threads might try to remove its
stateless snapshot:
1. Pool's monitoring that automatically starts prestarted VMs
2. VMs monitoring

If the pool's monitoring is triggered before VMs monitoring we might
get into a race that leads to removal of all images of a prestarted
stateless VM:
Thread 1 - PoolMonitoring calls RunVm that calls ProceedDownVm which
calls RestoreStatelessVm that in turn calls RestoreAllSnapshots
Thread 2 - VmsMonitoring calls ProceedDownVm that in turn calls
RestoreStatelessVm that also calls RestoreAllSnapshots

In thread 1 an exclusive lock is taken for the VM by RunVm and this
lock is passed all the way through to RestoreStatelessVm. This in
turn calls UpdateVmVersion that most of the time fails to run with
its lock and therefore the lock is released. But the instance of the
lock is still passed to RestoreAllSnapshots which basically means
that this command is executed with no lock on the VM.

Then, the second call to RestoreAllSnapshots by thread 2 might also
try to remove the latest images of the disks, after the ones from
the stateless snapshots had been removed -> so the images attached
to the active snapshot is removed as well.

The solution is not to pass the lock to UpdateVmVersion. This change
is safe since the lock was anyway released at the end of the execute
phase of UpdateVmVersion.

Change-Id: I870ef6757418205599e97688a276c75097642456
Bug-Url: https://bugzilla.redhat.com/1346270
Signed-off-by: Arik Hadas <ahadas at redhat.com>
---
M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RestoreStatelessVmCommand.java
M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmVersionCommand.java
M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/UpdateVmVersionParameters.java
3 files changed, 19 insertions(+), 4 deletions(-)

Approvals:
  Shahar Havivi: Looks good to me, approved
  Jenkins CI: Passed CI tests
  Arik Hadas: Verified



-- 
To view, visit https://gerrit.ovirt.org/59450
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I870ef6757418205599e97688a276c75097642456
Gerrit-PatchSet: 6
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Arik Hadas <ahadas at redhat.com>
Gerrit-Reviewer: Arik Hadas <ahadas at redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Liron Aravot <laravot at redhat.com>
Gerrit-Reviewer: Shahar Havivi <shavivi at redhat.com>
Gerrit-Reviewer: Shmuel Leib Melamud <smelamud at redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation at ovirt.org>



More information about the Engine-commits mailing list