[libvirt] [Question] Start VMs coincidently failed

Hello, When I start multi VMs coincidently and any of the cgroup directories named machine doesn't exist. There's a chance that VM start failed. And the errors reported are: 1. Unable to initialize /machine cgroup: File exists 2. Unable to create cgroup for sit_vm_16: No such file or directory So I analyze it and find that: If thread A and thread B start VMs at the same time, there's a chance that, thread A creat directory failed and thread B succeed. Then thread A will clean up machine directory, and thread B will do something in the machine directory cleaned up by thread A. At last thread B failed too because it can't find the directory. Thread A reports error 1 and thread B reports error 2. Well, the true reason is that the judgement of dirctory existence and the operation of creating directory is not atomic. At first, I want to find a lock to fix it, but failed. Then I apply a patch to get the EEXIST through to fix it. Guys, any better idea? My best regards WangYufei
participants (1)
-
Wangyufei (James)