<div class="zcontentRow"> <p><span style="font-size: 12px;">Hi John,</span></p><p><span style="font-size: 12px;">I have reworked this patch on the other new thread[1], please review that</span></p><p><span style="font-size: 12px;">patch.</span></p><p><span style="font-size: 12px;">Thank you :-)</span></p><p><br></p><p><span style="font-size: 12px;">[1] https://www.redhat.com/archives/libvir-list/2017-July/msg00921.html</span></p><p><br></p><p><span style="font-size: 12px;">>On 07/12/2017 07:34 AM, wang.yi59@zte.com.cn wrote:</span></p><p><span style="font-size: 12px;">>> Hi John,</span></p><p><span style="font-size: 12px;">>> </span></p><p><span style="font-size: 12px;">>> Thanks for your review!</span></p><p><span style="font-size: 12px;">>> </span></p><p><span style="font-size: 12px;">></span></p><p><span style="font-size: 12px;">>Somehow your response is out of synch with the rest of the series -</span></p><p><span style="font-size: 12px;">>things like this get lost very quickly.</span></p><p><span style="font-size: 12px;">></span></p><p><span style="font-size: 12px;">>>> This seems to be a strange sequence of operations, but the claim is that</span></p><p><span style="font-size: 12px;">>> </span></p><p><span style="font-size: 12px;">>>> by adding this logic to CreateWithFlags, then the problem you're facing</span></p><p><span style="font-size: 12px;">>> </span></p><p><span style="font-size: 12px;">>>> is resolved. However, is adding this to the Create logic the right thing</span></p><p><span style="font-size: 12px;">>> </span></p><p><span style="font-size: 12px;">>>> to do?</span></p><p><span style="font-size: 12px;">>> </span></p><p><span style="font-size: 12px;">>>> IIUC:</span></p><p><span style="font-size: 12px;">>> </span></p><p><span style="font-size: 12px;">>> This condition is rare, so I designed some operations which can help us</span></p><p><span style="font-size: 12px;">>> to understand what happened:</span></p><p><span style="font-size: 12px;">>> </span></p><p><span style="font-size: 12px;">>> # virsh define win7 -> successful</span></p><p><span style="font-size: 12px;">>> </span></p><p><span style="font-size: 12px;">>> # virsh start win7 &; sleep 0.2; virsh undefine win7 -> start failed and</span></p><p><span style="font-size: 12px;">>> undefine successful</span></p><p><span style="font-size: 12px;">>> </span></p><p><span style="font-size: 12px;">>>  </span></p><p><span style="font-size: 12px;">>> </span></p><p><span style="font-size: 12px;">>> and we may see libvirtd output such logs like this:</span></p><p><span style="font-size: 12px;">>> </span></p><p><span style="font-size: 12px;">>> qemuDomainDefineXMLFlags:7386 : Creating domain win7</span></p><p><span style="font-size: 12px;">>> </span></p><p><span style="font-size: 12px;">>> qemuProcessStart:6086 : conn=....</span></p><p><span style="font-size: 12px;">>> </span></p><p><span style="font-size: 12px;">>> qemuDomainUndefineFlags:7501 : Undefining domain win7</span></p><p><span style="font-size: 12px;">>> </span></p><p><span style="font-size: 12px;">>> error : qemuMonitorOpenUnix:379 : failed to connect to monitor socket</span></p><p><span style="font-size: 12px;">>> </span></p><p><span style="font-size: 12px;">>>  </span></p><p><span style="font-size: 12px;">>> </span></p><p><span style="font-size: 12px;">>> Libvirtd unlocked vm during qemuProcessStart, so qemuDomainUndefineFlags</span></p><p><span style="font-size: 12px;">>> can get the lock and undefine vm successfully.</span></p><p><span style="font-size: 12px;">></span></p><p><span style="font-size: 12px;">>Can you be a bit more specific. Do you mean during qemuConnectMonitor</span></p><p><span style="font-size: 12px;">>processing during ProcessLaunch? Or perhaps Agent processing?</span></p><p><span style="font-size: 12px;">></span></p><p><span style="font-size: 12px;">>In any case, perhaps then the better fix is to prohibit undefine whilst</span></p><p><span style="font-size: 12px;">>unlocked for Monitor or Agent start. The perhaps interesting question is</span></p><p><span style="font-size: 12px;">>where to set flag. Setting/clearing just around Monitor/Agent startup</span></p><p><span style="font-size: 12px;">>would be a seemingly short window and perhaps where you're seeing the</span></p><p><span style="font-size: 12px;">>virObjectUnlock; however, I wonder if perhaps all of qemuProcessLaunch</span></p><p><span style="font-size: 12px;">>should be "protected" as there's some really critical things happening</span></p><p><span style="font-size: 12px;">>in there. Thus at the top one sets a boolean "obj->starting = true" and</span></p><p><span style="font-size: 12px;">>at cleanup "obj->starting = false".</span></p><p><span style="font-size: 12px;">></span></p><p><span style="font-size: 12px;">>In qemuDomainUndefineFlags, there'd need to be a similar check to the if</span></p><p><span style="font-size: 12px;">>(!persistent) along the lines of "if (starting)" then an error message</span></p><p><span style="font-size: 12px;">>indicating that the domain is starting up and cannot be undefined.</span></p><p><span style="font-size: 12px;">>Perhaps similarly for Destroy just to be safe.</span></p><p><span style="font-size: 12px;">></span></p><p><span style="font-size: 12px;">>I didn't think all that long about it, but hopefully it's enough to</span></p><p><span style="font-size: 12px;">>perhaps have to generate more patches...  I don't believe with that it'd</span></p><p><span style="font-size: 12px;">>be possible to have the need to qemuDomainRemoveInactive in the</span></p><p><span style="font-size: 12px;">>CreateWithFlags, but I could be wrong.</span></p><p></p><p><br></p><div class="zMailSign"><div><div><p><span style="font-size: 12px;">---</span></p><p><span style="font-size: 12px;">Best wishes</span></p><p><span style="font-size: 12px;">Yi Wang</span></p></div></div></div><p><br></p></div>