[PATCH] network: Fix a race condition when shutdown & start vm at the same time

Michal Privoznik mprivozn at redhat.com
Fri Jun 19 16:00:56 UTC 2020


On 6/17/20 1:46 AM, Laine Stump wrote:

> 
> What do I think should be done? Good question. Possibly we could:
> 
> 
> A) Call virNetDevTapReattachBridge() rather than 
> virNetDevTapAttachBridge() in virNetDevTapCreateInBridgePort(). This 
> would eliminate problem (2).
> 
> 
> B) Instead of checking if the tap device MAC address matches, just call 
> virNetDevExists() - if it exists, then skip the RemovePort() - this 
> eliminates problems (3) and (4). (NB - this would fail if it turns out 
> that tap device deletion isn't completed synchronously with qemu process 
> termination!)
> 
> 
> C) If we want to make it 100% sound, we need to make "check for 
> interface existence + removeport" an atomic operation, and mutually 
> exclusive with virNetDevTapCreate(). This would eliminate problem (1)
> 

I still don't quite understand how there can be a race. I mean, from 
system POV, libvirt creates a TAP, plugs it into a bridge (when starting 
the first domain). And when shutting it down and starting the second 
domain in parallel a new TAP device (with different index and MAC) is 
created independent of the first TAP, no?

Michal




More information about the libvir-list mailing list