CA-299946: Resolve the VM before locking it

Signed-off-by: Mihaela Stoica <mihaela.stoica@citrix.com>
This commit is contained in:
Mihaela Stoica 2018-10-15 16:40:15 +01:00 committed by Konstantina Chremmou
parent 176624e029
commit 8c5e08294c

View File

@ -65,8 +65,9 @@ namespace XenAdmin.Diagnostics.Problems.VMProblem
{
return delegate(Session session)
{
var vmclone = (VM)VM.Clone();
VM.Locked = true;
var vm = VM.Connection.Resolve(new XenRef<VM>(VM.opaque_ref));
var vmclone = (VM)vm.Clone();
vm.Locked = true;
vmclone.SetAutoPowerOn(autostartValue);
try
{
@ -74,10 +75,10 @@ namespace XenAdmin.Diagnostics.Problems.VMProblem
}
finally
{
VM.Locked = false;
vm.Locked = false;
}
int wait = 5000; // wait up to 5 seconds for the cache to be updated
while (wait > 0 && VM.GetAutoPowerOn() != autostartValue)
while (wait > 0 && vm.GetAutoPowerOn() != autostartValue)
{
Thread.Sleep(100);
wait -= 100;