<div class="zcontentRow"> <p><br></p><p>i <span style="line-height: 21px;">explain the case again.  the net config xml of two vms is :</span></p><p><span style="line-height: 21px;"></span> <interface type='bridge'></p><p>      <mac address='fa:16:3e:e1:b2:01'/></p><p>      <source bridge='br100'/></p><p>      <model type='virtio'/></p><p>      <driver name='vhost'/></p><p>      <virtualport type='openvswitch'/></p><p>    </interface></p><p>of cause the mac of two vms is different. the bridge named br100 is created in <span id="w_14" high-light-id="w_3,w_14" class="" style="color: rgb(51, 51, 51); font-family: Arial, STHeiti, 宋体, 'WenQuanYi Micro Hei', sans-serif; line-height: 22px; background-color: rgb(249, 249, 249);">advance.</span></p><p><span high-light-id="w_3,w_14" class="" style="color: rgb(51, 51, 51); font-family: Arial, STHeiti, 宋体, 'WenQuanYi Micro Hei', sans-serif; line-height: 22px; background-color: rgb(249, 249, 249);">when the first vm started ,we can find the tao device named "vnet0" by virsh domiflist domid command.</span></p><p><font color="#333333" face="Arial, STHeiti, 宋体, WenQuanYi Micro Hei, sans-serif"><span style="line-height: 22px; background-color: rgb(249, 249, 249);">we can shutdow the first vm and start the second vm at or around the same time. we  can find  the tap device of  the second vm  is also named "vnet0".</span></font></p><p><font color="#333333" face="Arial, STHeiti, 宋体, WenQuanYi Micro Hei, sans-serif"><span style="line-height: 22px; background-color: rgb(249, 249, 249);">starting up and shutdowning vm <span id="w_9" high-light-id="w_2,w_9" class="" style="color: rgb(51, 51, 51); font-family: Arial, STHeiti, 宋体, 'WenQuanYi Micro Hei', sans-serif; line-height: 22px; background-color: rgb(249, 249, 249);">are </span><span id="w_10" high-light-id="w_3,w_10" class="" style="color: rgb(51, 51, 51); font-family: Arial, STHeiti, 宋体, 'WenQuanYi Micro Hei', sans-serif; line-height: 22px; background-color: rgb(249, 249, 249);">not </span><span id="w_11" high-light-id="w_4,w_11,w_12" class="" style="color: rgb(51, 51, 51); font-family: Arial, STHeiti, 宋体, 'WenQuanYi Micro Hei', sans-serif; line-height: 22px; background-color: rgb(249, 249, 249);">mutually </span><span id="w_12" high-light-id="w_4,w_11,w_12" class="" style="color: rgb(51, 51, 51); font-family: Arial, STHeiti, 宋体, 'WenQuanYi Micro Hei', sans-serif; line-height: 22px; background-color: rgb(249, 249, 249);">exclusive. adding port named "vnet0" to bridge and  deleting port from bridge <span id="w_9" high-light-id="w_2,w_9" class="" style="line-height: 22px; color: rgb(51, 51, 51); font-family: Arial, STHeiti, 宋体, 'WenQuanYi Micro Hei', sans-serif; background-color: rgb(249, 249, 249);">are </span><span id="w_10" high-light-id="w_3,w_10" class="" style="line-height: 22px; color: rgb(51, 51, 51); font-family: Arial, STHeiti, 宋体, 'WenQuanYi Micro Hei', sans-serif; background-color: rgb(249, 249, 249);">not </span><span id="w_11" high-light-id="w_4,w_11,w_12" class="" style="line-height: 22px; color: rgb(51, 51, 51); font-family: Arial, STHeiti, 宋体, 'WenQuanYi Micro Hei', sans-serif; background-color: rgb(249, 249, 249);">mutually </span><span id="w_12" high-light-id="w_4,w_11,w_12" class="" style="line-height: 22px; color: rgb(51, 51, 51); font-family: Arial, STHeiti, 宋体, 'WenQuanYi Micro Hei', sans-serif; background-color: rgb(249, 249, 249);">exclusive.</span></span></span></font></p><p><font color="#333333" face="Arial, STHeiti, 宋体, WenQuanYi Micro Hei, sans-serif"><span style="line-height: 22px; background-color: rgb(249, 249, 249);"><span high-light-id="w_4,w_11,w_12" class="" style="color: rgb(51, 51, 51); font-family: Arial, STHeiti, 宋体, 'WenQuanYi Micro Hei', sans-serif; line-height: 22px; background-color: rgb(249, 249, 249);"><span high-light-id="w_4,w_11,w_12" class="" style="line-height: 22px; color: rgb(51, 51, 51); font-family: Arial, STHeiti, 宋体, 'WenQuanYi Micro Hei', sans-serif; background-color: rgb(249, 249, 249);">so the problem occurred. the port of the second vm added to the bridge is deteled by calling virNetDevOpenvswitchRemovePort in shutdowning  the first vm .</span></span></span></font></p><p><font color="#333333" face="Arial, STHeiti, 宋体, WenQuanYi Micro Hei, sans-serif"><span style="line-height: 22px; background-color: rgb(249, 249, 249);"><br></span></font></p><p><br></p><p><font color="#ffffff" face="Arial, STHeiti, 宋体, WenQuanYi Micro Hei, sans-serif"><span style="line-height: 22px; background-color: rgb(67, 149, 255);"><br></span></font></p><p><span style="line-height: 21px;"><br></span><br></p><p><span style="line-height: 21px;"><br></span></p><p><br></p><p><br></p><p><br></p><div class="zMailSign"><div><div><div><div><p style="font-family: 宋体; font-size: 7.0px; line-height: normal; widows: 1;"><span style="font-size:12px;color:#58595B;font-family:微软雅黑;font-size: 7.0px;"><span class="signedit"><br></span></span></p><p style="font-family: 宋体; font-size: 7.0px; line-height: normal; widows: 1;"><span style="font-size:12px;color:#58595B;font-family:微软雅黑;font-size: 7.0px;"><span class="signedit"><strong style="box-sizing: border-box; color: rgb(255, 192, 0); font-family: 宋体; line-height: normal; white-space: normal; outline: none !important; background-color: rgb(255, 255, 255);"><span style="box-sizing: border-box; outline: none !important; font-family: 微软雅黑; font-size: 18px;"><span style="box-sizing: border-box; font-family: 微软雅黑, 'Microsoft YaHei'; font-size: 20px; line-height: 36px; outline: none !important;">为了让您的VPlat虚拟化故障得到高效的处理,请上报故障到: </span><span style="box-sizing: border-box; font-family: 微软雅黑, 'Microsoft YaHei'; font-size: 20px; line-height: 17.1420001983643px; outline: none !important;">$VPlat技术支持。</span></span></strong></span></span></p><p style="font-family: 宋体; font-size: medium; line-height: normal; widows: 1;"><span style="font-size:12px;color:#58595B;font-family:微软雅黑"><span class="signedit" id="sign_name">芦志朋</span> <span style="font-family:Arial"><span class="signedit" id="sign_name_eng">luzhipeng</span></span></span></p><p style="font-size: 7.0px; line-height: normal; widows: 1;"><span style="font-size:12px;color:#58595B;font-family:微软雅黑;font-size: 7.0px;"><span style=""><span class="signedit"><br></span></span></span></p><p style="font-family: 宋体; font-size: medium; line-height: normal; widows: 1;"><span style="font-size:10px;color:#58595B;font-family:微软雅黑"><span class="signedit" id="sign_position">IT开发工程师</span> <span style="font-family:Arial"><span class="signedit" id="sign_position_eng">IT Development
Engineer</span></span></span><br><span style="font-size:10px;color:#58595B;font-family:微软雅黑"><span class="signedit" id="sign_dept">操作系统产品部/中心研究院/系统产品</span> <span style="font-family:Arial"> <span class="signedit" id="sign_dept_eng">OS Product Dept./Central R&D Institute/System Product</span></span></span></p><p style="font-size: 7.0px; line-height: normal; widows: 1;"><span style="font-size:10px;color:#58595B;font-family:微软雅黑;font-size: 7.0px;"><span style=""><span class="signedit"><br></span></span></span></p><p style="font-size: 7.0px; line-height: normal; widows: 1;"><span style="font-size:10px;color:#58595B;font-family:微软雅黑;font-size: 7.0px;"></span></p><table style="color: rgb(0, 0, 0); font-family: 宋体; widows: 1;"><tbody><tr class="firstRow"><td valign="top" width="100"><img id="sign-icon" src="cid:9ae3e214c17d49ed935d87c674ba3ee2" width="130" height="120"></td><td valign="top" width="500"><img id="sign-logo" src="cid:24242e5637af428891c4db731e7765ad" width="115" height="38"><br><span style="font-size:10px;color:#58595B;font-family:微软雅黑"><span class="signedit" id="sign_addr">深圳市南山区科技南路55号中兴通讯研发大楼33楼 </span><br><span style="font-family:Arial"><span class="signedit" id="sign_addr_eng_1">33/F, R&D Building, ZTE
Corporation Hi-tech Road South</span>, <br><span class="signedit" id="sign_addr_eng_2">Hi-tech
Industrial Park Nanshan District, Shenzhen, P.R.China, 518057</span> <br><span style="color:#008FD4">T</span>: <span class="signedit" id="sign_fix_phone">+86 755 xxxxxxxx</span> <span style="color:#008FD4">F</span>:<span class="signedit" id="sign_fax">+86 755 xxxxxxxx</span> <br><span style="color:#008FD4">M</span>: <span class="signedit" id="sign_phone">+86 xxxxxxxxxxx</span> <br><span style="color:#008FD4">E</span>: <span class="signedit" id="sign_email">lu.zhipeng@zte.com.cn</span> <br><span style="color:#008FD4"><a href="http://www.zte.com.cn/" target="_blank">www.zte.com.cn</a></span></span></span></td></tr></tbody></table><span style="line-height: normal; widows: 1; font-size: 7.0px;;color:#58595b;font-size:10px"></span></div></div></div></div></div><div><div class="zhistoryRow" style="display:block"><div class="zhistoryDes" style="width: 100%; height: 28px; line-height: 28px; background-color: #E0E5E9; color: #1388FF; text-align: center;" language-data="HistoryOrgTxt">原始邮件</div><div id="zwriteHistoryContainer"><div class="control-group zhistoryPanel"><div class="zhistoryHeader" style="padding: 8px; background-color: #F5F6F8;"><div><strong language-data="HistorySenderTxt">发件人:</strong><span class="zreadUserName"> <joel@aenertia.net>;</span></div><div><strong language-data="HistoryTOTxt">收件人:</strong><span class="zreadUserName" style="display: inline-block;"> <laine@laine.org>;</span></div><div><strong language-data="HistoryCCTxt">抄送人:</strong><span class="zreadUserName" style="display: inline-block;"> <libvir-list@redhat.com>;</span><span class="zreadUserName" style="display: inline-block;">芦志朋10108272;</span></div><div><strong language-data="HistoryDateTxt">日 期 :</strong><span class="">2017年04月29日 11:21</span></div><div><strong language-data="HistorySubjectTxt">主 题 :</strong><span class="zreadTitle"><strong>Re: [libvirt]答复: Re: [PATCH] qemu: change the name of tap device for a tapand bridge network</strong></span></div></div><p class="zhistoryContent"><br></p><div><div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif">I'll try and explain the steps/situation where this is an issue.<br><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">Say for example you have your router/dhcpd done inside a VM guest - you use macvtap devices and vlans off the hypervisor to get the traffic in and out (WAN and LAN). And you want the LAN side to provide connectivity to the host as well as to the network beyond the host.<br><br>this is on a Ubuntu 16.04 host.<br><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">1) Create and isolated virtual Network via libvirt xml - say 'LAN' this is the second network (assume default exists) creates virbr1 and a vnic1 This is addition to the WAN and LAN macvtap devices. Unbeknown-st to libvirt the LAN macvtap is going to end up bridge to the 'isolated' network by the VM.<br></div><div class="gmail_default" style="font-family:verdana,sans-serif">2) the virbr1 bridge needs numbering<br><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">vnic1 is attached inside the VM to a dhcpd server but you still need the virbr1 interface to be numbered on the hypervisor (but you don't want the libvirt networking to take care of the numbering etc becuase that's what your fancy NFV VM is going to handle). Manually it's easy at this point you just run dhclient <a href="http://et.al" target="_blank">et.al</a> on the bridge and you are good to go.<br><br></div><div class="gmail_default" style="font-family:verdana,sans-serif">BUT you want this to happen at boot; adding any sort of etc/network or /etc/sysconfig/networking scripts refering to that virbr1 will create a race condition which will stop the vm from getting started as you mention.<br><br></div><br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On 29 April 2017 at 14:45, Laine Stump <span dir="ltr"><<a href="mailto:laine@laine..org" target="_blank">laine@laine.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 04/28/2017 07:23 PM, Joel Wirāmu Pauling wrote:<br> > Possibly related I notice race conditions caused by vnic never getting<br> > loaded if an existing bridge is already up (by OS init scripts etc) and<br> > stopping VM's from getting started.<br> <br> </span>Can you explain this more exactly? In particular, by "vnic" do you mean<br> the network device as seen by the guest? And what do you mean by the<br> term "getting loaded"? (It doesn't make sense to me that you should mean<br> the network device in the guest, unless "stopping VM's from getting<br> started" just means that the guest doesn't become fully functional,<br> rather than that the qemu process doesn't start). Beyond that, of course<br> the bridge that the tap device will be connected to needs to exist<br> before you can connect something to it - I don't understand how its<br> existence could cause a failure; rather its *non*-existence would cause<br> a failure. (As you can see by my wild suppositions that make no sense,<br> the terms you've used are a bit too vague/open to interpretation for me<br> to understand exactly the problem you're referring to)<br> <br> (Hmm - perhaps you're referring to the situation where libvirt attempts<br> to create a bridge on the host for one of its virtual networks, but<br> either a bridge by that name has already been created by "someone else"<br> or another netdev already exists on the host that is on the same subnet<br> (and thus has the same route)? Your description doesn't fit that very<br> well, but that is a known problem and unrelated to the patch/problem<br> we're discussing here.<br> <span class=""><br> ><br> > Often this is behavior you want ; i.e having Host Hypervisor NIC's added<br> > and up before libvirtd sets up it's nics/bridges.<br> <br> <br> <br> ><br> ><br> > On 29 April 2017 at 11:15, <<a href="mailto:lu.zhipeng@zte.com.cn" target="_blank">lu.zhipeng@zte.com.cn</a><br> </span><span class="">> <mailto:<a href="mailto:lu.zhipeng@zte.com.cn" target="_blank">lu.zhipeng@zte.com.cn</a>><wbr>> wrote:<br> ><br> ><br> >     >On Fri, Apr 28, 2017 at 05:23:19PM +0800, ZhiPeng Lu wrote:<br> >     >><br> >     Creating tap device and adding the device to bridge are not atomic operation.<br> >     >><br> >     Similarly deleting tap device and removing it from bridge are not atomic operation.<br> >     >>The Problem occurs when two vms start and shutdown. When one vm with the nic<br> >     >><br> >     named "vnet0" stopping, it deleted tap device but not removing port from bridge.<br> >     >><br> >     At this time, another vm created the tap device named "vnet0" and added port to the<br> >     >><br> >     same bridge. Then, the first vm deleted the tap device from the same bridge.<br> >     >><br> >     Finally, the tap device of the second vm don't attached to the bridge.<br> >     >><br> >     So, we can add domid to vm's nic name. For example, the vm's domid is 1 and vnet0<br> >     >> is renamed to vnet1.0.<br> ><br> >     >Surely deleting the NIC automatically removes it from the bridge so we<br> >     >can just remove the code that delets the bridge port.<br> ><br> >     i have done some tests for a tap + openvswitch bridge network.  i<br> >     find  the nic named "vnet0" don't exsit before calling<br> >     the virNetDevOpenvswitchRemovePort<wbr>.<br> ><br> >     i think  the tap is deleted not by removingport  from bridge. i<br> >     think hotpluging net has the same problem.<br> ><br> ><br> >     by the way:<br> ><br> >           my company's e-mail  does not support thread posting  and has<br> >     some other problems. i believe that my colleagues can soon resloved<br> >     them.<br> ><br> ><br> ><br> ><br> ><br> ><br> </span>>     *为了让您的VPlat虚拟化故障得到高效的处理,<wbr>请上报故障到: $VPlat技术支<br> >     持。*<br> <span class="">><br> >     芦志朋 luzhipeng<br> ><br> ><br> >     IT开发工程师 IT Development Engineer<br> >     操作系统产品部/中心研究院/系统产品 OS Product Dept./Central R&D<br> >     Institute/System Product<br> ><br> ><br> ><br> </span><span class="">>     深圳市南山区科技南路55号中兴通讯研发大楼33楼<br> >     33/F, R&D Building, ZTE Corporation Hi-tech Road South,<br> >     Hi-tech Industrial Park Nanshan District, Shenzhen, P.R.China, 518057<br> >     T: +86 755 xxxxxxxx F:+86 755 xxxxxxxx<br> >     M: +86 xxxxxxxxxxx<br> </span>>     E: <a href="mailto:lu.zhipeng@zte.com.cn" target="_blank">lu.zhipeng@zte.com.cn</a> <mailto:<a href="mailto:lu.zhipeng@zte.com.cn" target="_blank">lu.zhipeng@zte.com.cn</a>><br> >     <a href="http://www.zte.com.cn" rel="noreferrer" target="_blank">www.zte.com.cn</a> <<a href="http://www.zte.com.cn/" rel="noreferrer" target="_blank">http://www.zte.com.cn/</a>><br> ><br> >     原始邮件<br> >     *发件人:*<<a href="mailto:berrange@redhat.com" target="_blank">berrange@redhat.com</a> <mailto:<a href="mailto:berrange@redhat.com" target="_blank">berrange@redhat.com</a>>>;<br> >     *收件人:*芦志朋10108272;<br> >     *抄送人:*<<a href="mailto:libvir-list@redhat.com" target="_blank">libvir-list@redhat.com</a> <mailto:<a href="mailto:libvir-list@redhat.com" target="_blank">libvir-list@redhat.com</a><wbr>>>;<br> >     *日 期 :*2017年04月28日 19:27<br> >     *主 题 :**Re: [libvirt] [PATCH] qemu: change the name of tap device<br> >     for a tapand bridge network*<br> <span class="">><br> ><br> >     On Fri, Apr 28, 2017 at 05:23:19PM +0800, ZhiPeng Lu wrote:<br> >     > Creating tap device and adding the device to bridge are not atomic operation.<br> >     > Similarly deleting tap device and removing it from bridge are not atomic operation.<br> >     > The Problem occurs when two vms start and shutdown. When one vm with the nic<br> >     > named "vnet0" stopping, it deleted tap device but not removing port from bridge.<br> >     > At this time, another vm created the tap device named "vnet0" and added port to the<br> >     > same bridge. Then, the first vm deleted the tap device from the same bridge.<br> >     > Finally, the tap device of the second vm don't attached to the bridge.<br> >     > So, we can add domid to vm's nic name.. For example, the vm's domid is 1 and vnet0<br> >     > is renamed to vnet1.0.<br> ><br> >     Surely deleting the NIC automatically removes it from the bridge so we<br> >     can just remove the code that delets the bridge port.<br> ><br> ><br> >     Regards,<br> >     Daniel<br> >     --<br> >     |: <a href="https://berrange.com" rel="noreferrer" target="_blank">https://berrange.com</a>      -o-    <a href="https://www.flickr.com/photos/dberrange" rel="noreferrer" target="_blank">https://www.flickr.com/photos/<wbr>dberrange</a><br> >     <<a href="https://www.flickr.com/photos/dberrange" rel="noreferrer" target="_blank">https://www.flickr.com/<wbr>photos/dberrange</a>> :|<br> >     |: <a href="https://libvirt.org" rel="noreferrer" target="_blank">https://libvirt.org</a>         -o-            <a href="https://fstop138..berrange.com" rel="noreferrer" target="_blank">https://fstop138.berrange.com</a><br> >     <<a href="https://fstop138.berrange.com" rel="noreferrer" target="_blank">https://fstop138.berrange.com</a><wbr>> :|<br> >     |: <a href="https://entangle-photo.org" rel="noreferrer" target="_blank">https://entangle-photo.org</a>    -o-    <a href="https://www.instagram.com/dberrange" rel="noreferrer" target="_blank">https://www.instagram.com/<wbr>dberrange</a><br> >     <<a href="https://www.instagram.com/dberrange" rel="noreferrer" target="_blank">https://www.instagram.com/<wbr>dberrange</a>> :|<br> ><br> >     --<br> >     libvir-list mailing list<br> </span>>     <a href="mailto:libvir-list@redhat.com" target="_blank">libvir-list@redhat.com</a> <mailto:<a href="mailto:libvir-list@redhat.com" target="_blank">libvir-list@redhat.com</a><wbr>><br> >     <a href="https://www.redhat.com/mailman/listinfo/libvir-list" rel="noreferrer" target="_blank">https://www.redhat.com/<wbr>mailman/listinfo/libvir-list</a><br> <span class="">>     <<a href="https://www.redhat.com/mailman/listinfo/libvir-list" rel="noreferrer" target="_blank">https://www.redhat.com/<wbr>mailman/listinfo/libvir-list</a>><br> ><br> ><br> ><br> ><br> >     --<br> >     libvir-list mailing list<br> </span>>     <a href="mailto:libvir-list@redhat.com" target="_blank">libvir-list@redhat.com</a> <mailto:<a href="mailto:libvir-list@redhat.com" target="_blank">libvir-list@redhat.com</a><wbr>><br> >     <a href="https://www.redhat.com/mailman/listinfo/libvir-list" rel="noreferrer" target="_blank">https://www.redhat.com/<wbr>mailman/listinfo/libvir-list</a><br> <div class="HOEnZb"><div class="h5">>     <<a href="https://www.redhat.com/mailman/listinfo/libvir-list" rel="noreferrer" target="_blank">https://www.redhat.com/<wbr>mailman/listinfo/libvir-list</a>><br> ><br> ><br> ><br> ><br> > --<br> > libvir-list mailing list<br> > <a href="mailto:libvir-list@redhat.com" target="_blank">libvir-list@redhat.com</a><br> > <a href="https://www.redhat.com/mailman/listinfo/libvir-list" rel="noreferrer" target="_blank">https://www.redhat.com/<wbr>mailman/listinfo/libvir-list</a><br> ><br> <br> </div></div></blockquote></div><br></div></div><p><br></p></div></div></div></div><p><br></p> </div>