<div dir="ltr">  environment:libvirt-4.3.0 qemu-kvm-ev-2.10.0 kernel-3.10.0-1062 centos7 openvswitch-2.3.1 <div> </div><div> vm network xml :<br></div><div><interface type='bridge'><br>  <mac address='52:54:00:46:45:95'/><br>  <source bridge='ovsbr-mgt'/><br>  <vlan><br>    <tag id='0'/><br>  </vlan><br>  <virtualport type='openvswitch'><br>    <parameters interfaceid='596c6ab7-4557-4935-af97-62a35d933f8d'/><br>  </virtualport><br>  <target dev='vnet0'/><br>  <model type='virtio'/><br>  <link state='up'/><br>  <alias name='net0'/><br>  <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/><br></interface><br></div><div><br></div><div>qemuProcessStart in qemu_process.c failed to start. </div><div><span id="gmail-docs-internal-guid-9024127b-7fff-84e9-d86b-f7e2655bfd03"><span style="font-size:10pt;font-family:Montserrat,sans-serif;color:rgb(0,0,0);background-color:transparent;font-variant-numeric:normal;font-variant-east-asian:normal;vertical-align:baseline;white-space:pre-wrap">The first is qemu process stop(At this time, the kernel will recycle tap device,</span></span></div><div><span><span style="font-size:10pt;font-family:Montserrat,sans-serif;color:rgb(0,0,0);background-color:transparent;font-variant-numeric:normal;font-variant-east-asian:normal;vertical-align:baseline;white-space:pre-wrap">and the </span></span>tap device is applied by other virtual machines<span style="background-color:transparent;color:rgb(0,0,0);font-family:Montserrat,sans-serif;font-size:10pt;white-space:pre-wrap">).</span><span style="font-size:10pt;font-family:Montserrat,sans-serif;color:rgb(0,0,0);background-color:transparent;font-variant-numeric:normal;font-variant-east-asian:normal;vertical-align:baseline;white-space:pre-wrap">Then, ovs removevport.</span></div><div>It is possible to processing concurrently qemuProcessStart and qemuProcessStop.</div><div>qemuProcessStop(ovs removevport) may remove ports of other virtual machines </div><div>while using openvswitch virtualport.</div><div><br></div><div>for example:</div><div>Failure to start the vm1, the tap device vnet0 will be recovered first(at this time vm2 starts and</div><div>uses vnet0 device,and ovs add vnet0 port), then the removevport vnet0(
remove vnet0</div><div>belonging to vm2 at this time ). During this time interval,</div><div>vm2 will apply for the same tap device vnet0 and add port vnet0.</div><div> At this time, removing the port from vm1 will cause the port of vm2 to be lost. </div><div>vm2 will not be able to access the network through this vnet0.</div><div><br></div><div>reproduce:</div><div>Batch start or migrate 10 virtual machines to the same node, one of the virtual machines start failed.</div><div>This failure may be that the storage cannot connect or other failures(when we reproduced internally,</div><div> one of the virtual machines was connected to an invalid storage, and it was artificially failed).<br></div><div><br></div><div>this problem will cause:</div><div>After batch migration, the network of a virtual machine cannot be accessed, </div><div>and the virtual machine service is interrupted<br></div><div><br></div><div>libvirt handles ovs logs:</div><div>Jun 10 19:11:32 zbs-sh-elf-11 ovs-vsctl: ovs|00001|vsctl|INFO|Called as ovs-vsctl --timeout=5 -- --if-exists del-port vnet4 -- add-port ovsbr-mgt vnet4 tag=0 -- set Interface vnet4 "external-ids:attached-mac=\"52:54:00:92:7e:7f\"" -- set Interface vnet4 "external-ids:iface-id=\"afb3a67a-5e5d-4ca6-b625-ebce6a9c8d03\"" -- set Interface vnet4 "external-ids:vm-id=\"7b9e4d5a-e8e9-4527-9b89-dd1f74d02526\"" -- set Interface vnet4 external-ids:iface-status=active<br>Jun 10 19:11:32 zbs-sh-elf-11 kernel: device vnet4 entered promiscuous mode<br>Jun 10 19:11:32 zbs-sh-elf-11 kernel: device vnet4 left promiscuous mode<br>Jun 10 19:11:32 zbs-sh-elf-11 ovs-vsctl: ovs|00001|vsctl|INFO|Called as ovs-vsctl --timeout=5 -- --if-exists del-port vnet4 -- add-port ovsbr-mgt vnet4 tag=0 -- set Interface vnet4 "external-ids:attached-mac=\"52:54:00:b7:f4:07\"" -- set Interface vnet4 "external-ids:iface-id=\"c837d02d-4a4e-4f9c-9bee-7e5efce01a8e\"" -- set Interface vnet4 "external-ids:vm-id=\"83035f1e-faed-43d6-951e-08c90c9006a9\"" -- set Interface vnet4 external-ids:iface-status=active<br>Jun 10 19:11:32 zbs-sh-elf-11 kernel: device vnet4 entered promiscuous mode<br>Jun 10 19:11:32 zbs-sh-elf-11 ovs-vsctl: ovs|00001|vsctl|INFO|Called as ovs-vsctl --timeout=5 -- --if-exists del-port vnet4<br></div><div><br></div><div><br></div><div><span style="color:rgb(0,0,0);font-family:"Microsoft YaHei UI",Tahoma;font-size:14px;font-variant-numeric:normal;font-variant-east-asian:normal;line-height:normal">Thanks</span>  <br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Laine Stump <<a href="mailto:laine@redhat.com">laine@redhat.com</a>> 于2020年6月16日周二 上午10:01写道:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 6/15/20 2:04 PM, Daniel Henrique Barboza wrote:<br>
><br>
><br>
> On 6/12/20 3:18 AM, <a href="mailto:gongwei@smartx.com" target="_blank">gongwei@smartx.com</a> wrote:<br>
>> From: gongwei <<a href="mailto:gongwei@smartx.com" target="_blank">gongwei@smartx.com</a>><br>
>><br>
>> start to failed will not remove the openvswitch port,<br>
>> the port recycling in this case lets openvswitch handle it by itself<br>
>><br>
>> Signed-off-by: gongwei <<a href="mailto:gongwei@smartx.com" target="_blank">gongwei@smartx.com</a>><br>
>> ---<br>
><br>
> Can you please elaborate on the commit message? By the commit title and<br>
> the code, I'm assuming that you're saying that we shouldn't remove the<br>
> openvswitch port if the QEMU process failed to start, for any other<br>
> reason aside from SHUTOFF_FAILED.<br>
<br>
<br>
More importantly, what "port recycling" will take effect dependent on <br>
how the qemu process is stopped (which I would think wouldn't make any <br>
different to OVS), and why is it necessary for libvirt to not do it.<br>
<br>
<br>
Up until now, what I have known is that ports will not be removed from <br>
an OVS switch unless they are explicitly removed with ovs-vsctl, and <br>
this attachment will persist across reboots of the host system. As a <br>
matter of fact I've had cases during development where libvirt didn't <br>
remove the OVS port for a tap device when a guest was terminated, and <br>
then many *days* (and several reboots) later the same tap device name <br>
was used for a different guest that was using a Linux host bridge, and <br>
the tap device failed to attach to the Linux host bridge because it had <br>
already been auto-attached back to the OVS switch as soon as it was created.<br>
<br>
<br>
Can you desccribe how to reproduce the situation where libvirt removes <br>
the OVS port when it shouldn't, and what is the bad outcome of that <br>
happening?<br>
<br>
<br>
<br>
><br>
> The code itself looks ok.<br>
><br>
><br>
><br>
>>   src/qemu/qemu_process.c | 3 ++-<br>
>>   1 file changed, 2 insertions(+), 1 deletion(-)<br>
>><br>
>> diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c<br>
>> index d36088ba98..439bd5b396 100644<br>
>> --- a/src/qemu/qemu_process.c<br>
>> +++ b/src/qemu/qemu_process.c<br>
>> @@ -7482,7 +7482,8 @@ void qemuProcessStop(virQEMUDriverPtr driver,<br>
>>           if (vport) {<br>
>>               if (vport->virtPortType == <br>
>> VIR_NETDEV_VPORT_PROFILE_MIDONET) {<br>
>> ignore_value(virNetDevMidonetUnbindPort(vport));<br>
>> -            } else if (vport->virtPortType == <br>
>> VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH) {<br>
>> +            } else if (vport->virtPortType == <br>
>> VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH &&<br>
>> +                       reason != VIR_DOMAIN_SHUTOFF_FAILED) {<br>
>>                   ignore_value(virNetDevOpenvswitchRemovePort(<br>
>> virDomainNetGetActualBridgeName(net),<br>
>>                                    net->ifname));<br>
>><br>
><br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><p style="font-size:12.8px"><span style="font-family:tahoma,sans-serif;font-size:small">龚伟</span><br></p><p style="font-size:12.8px"><img src="https://docs.google.com/a/smartx.com/uc?id=0B6v_9z-4gTszRGFCWVFMSGlsMVE&export=download"><br></p><p style="font-size:12.8px"><span style="font-size:12.8px">手机:18883262137</span></p></div></div>