tools: acrn-manager: fix a race condition on updating VM state

For a running or suspended VM, its state is updated in 2 steps.
It is first set to VM_CREATED, then set to VM_STARTED/VM_PAUSED. IF
one thread check a running/suspend VM, it may get wrong state VM_CREATED,
while another thread is updating the VMs state.

Tracked-On: #2716
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
Acked-by: Yan, Like <like.yan@intel.com>
This commit is contained in:
yuhong.tao@intel.com
2019-01-08 15:01:19 +00:00
committed by wenlingz
parent d5ec844f86
commit 5d6f6ab798
2 changed files with 9 additions and 6 deletions

View File

@@ -38,6 +38,7 @@ struct vmmngr_struct *vmmngr_find(const char *vmname);
struct vmmngr_struct {
char name[MAX_NAME_LEN];
unsigned long state;
unsigned long state_tmp;
unsigned long update; /* update count, remove a vm if no update for it */
LIST_ENTRY(vmmngr_struct) list;
};