<div class="zcontentRow"> <p><br></p><p><br></p><p><span style="line-height: 21px;">On 06/14/2017 04:29 AM, ZhiPeng Lu wrote:</span><br style="white-space: normal;"><span style="line-height: 21px;">> Before libvirt that calls virNetDevMacVLanCreateWithVPortProfile sets mac address</span><br style="white-space: normal;"><span style="line-height: 21px;">> or vlan of a Virtual Function(VF) linked to a macvtap passthrough device of migration</span><br style="white-space: normal;"><span style="line-height: 21px;">> destination host in migration start step. If we ping the migrating vm,</span><br style="white-space: normal;"><span style="line-height: 21px;">> we get the network does not pass. Because VFs of migration source and destination</span><br style="white-space: normal;"><span style="line-height: 21px;">> have the same MAC address. The patch later calling qemuMigrationVPAssociatePortProfiles</span><br style="white-space: normal;"><span style="line-height: 21px;">> sets mac address of VF in migration finish step instead of start step.</span><br style="white-space: normal;"><span style="line-height: 21px;">> The patch aims to reduce packet loss rate.</span><br style="white-space: normal;"><br style="white-space: normal;"><span style="line-height: 21px;">>I missed this patch when you initially sent it, and see that nobody else</span><br style="white-space: normal;"><span style="line-height: 21px;">>responded...</span><br style="white-space: normal;"><br style="white-space: normal;"><br style="white-space: normal;"><span style="line-height: 21px;">>What you're doing here shouldn't be needed. During migration, a macvtap</span><br style="white-space: normal;"><span style="line-height: 21px;">>device should be created with ~IFF_UP, and not brought online until</span><br style="white-space: normal;"><span style="line-height: 21px;">>qemuInterfaceStartDevice() is called just prior to starting the guest</span><br style="white-space: normal;"><span style="line-height: 21px;">>CPUs on the destination; by this time the guest CPUs on the source have</span><br style="white-space: normal;"><span style="line-height: 21px;">>already been stopped (and the guest's macvtap interfaces on the source</span><br style="white-space: normal;"><span style="line-height: 21px;">>have been set offline). Until a device is IFF_UP, it shouldn't send out</span><br style="white-space: normal;"><span style="line-height: 21px;">>any traffic with its MAC address.</span><br style="white-space: normal;"><br><br>----Probably not understanding what I mean when the network packet loss happens. </p><p>This patch describes  the time before the guest CPU on the  source  has been stopped and the <span style="line-height: 21px;">macvtap</span> device was <span style="line-height: 21px;">IFF_UP.</span></p><p>if we send network data from the <span style="line-height: 21px;">destination, the network packet loss.</span><br><br><br><br><br style="white-space: normal;"><span style="line-height: 21px;">>If you look at the macvtap device on the destination and it has IFF_UP</span><br style="white-space: normal;"><span style="line-height: 21px;">>set prior to the completion of migration, then there is a bug in libvirt</span><br style="white-space: normal;"><span style="line-height: 21px;">>that we need to fix. Otherwise, I think any packet loss you're seeing is</span><br style="white-space: normal;"><span style="line-height: 21px;">>coming from something else.</span><br style="white-space: normal;"><br style="white-space: normal;"><br style="white-space: normal;"><span style="line-height: 21px;">></span><br style="white-space: normal;"><span style="line-height: 21px;">> Signed-off-by: ZhiPeng Lu <lu.zhipeng@zte.com.cn></span><br style="white-space: normal;"><span style="line-height: 21px;">> ---</span><br style="white-space: normal;"><span style="line-height: 21px;">>  src/qemu/qemu_migration.c   | 18 ++++++++++++++++--</span><br style="white-space: normal;"><span style="line-height: 21px;">>  src/util/virnetdevmacvlan.c | 17 +++++++++++------</span><br style="white-space: normal;"><span style="line-height: 21px;">>  2 files changed, 27 insertions(+), 8 deletions(-)</span><br style="white-space: normal;"><span style="line-height: 21px;">></span><br style="white-space: normal;"><span style="line-height: 21px;">> diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c</span><br style="white-space: normal;"><span style="line-height: 21px;">> index 09adb04..795ed71 100644</span><br style="white-space: normal;"><span style="line-height: 21px;">> --- a/src/qemu/qemu_migration.c</span><br style="white-space: normal;"><span style="line-height: 21px;">> +++ b/src/qemu/qemu_migration.c</span><br style="white-space: normal;"><span style="line-height: 21px;">> @@ -5004,7 +5004,7 @@ qemuMigrationPerform(virQEMUDriverPtr driver,</span><br style="white-space: normal;"><span style="line-height: 21px;">>  }</span><br style="white-space: normal;"><span style="line-height: 21px;">>  </span><br style="white-space: normal;"><span style="line-height: 21px;">>  static int</span><br style="white-space: normal;"><span style="line-height: 21px;">> -qemuMigrationVPAssociatePortProfiles(virDomainDefPtr def)</span><br style="white-space: normal;"><span style="line-height: 21px;">> +qemuMigrationVPAssociatePortProfiles(virDomainDefPtr def, const char *stateDir)</span><br style="white-space: normal;"><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: 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"><a href="mailto:lu.zhipeng@zte.com.cn">lu.zhipeng@zte.com.cn</a></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"> <laine@laine.org>;</span></div><div><strong language-data="HistoryTOTxt">收件人:</strong><span class="zreadUserName" style="display: inline;"> <libvir-list@redhat.com>;</span></div><div><strong language-data="HistoryCCTxt">抄送人:</strong><span class="zreadUserName" style="display: inline;">芦志朋10108272;</span></div><div><strong language-data="HistoryDateTxt">日 期 :</strong><span class="">2017年07月17日 05:01</span></div><div><strong language-data="HistorySubjectTxt">主 题 :</strong><span class="zreadTitle"><strong>Re: [libvirt] [v2 RESEND PATCH] qemu: reduce packet loss rate for vmwith macvtap passthrough mode in migration</strong></span></div></div><p class="zhistoryContent"><br></p><div>On 06/14/2017 04:29 AM, ZhiPeng Lu wrote:<br>> Before libvirt that calls virNetDevMacVLanCreateWithVPortProfile sets mac address<br>> or vlan of a Virtual Function(VF) linked to a macvtap passthrough device of migration<br>> destination host in migration start step. If we ping the migrating vm,<br>> we get the network does not pass. Because VFs of migration source and destination<br>> have the same MAC address. The patch later calling qemuMigrationVPAssociatePortProfiles<br>> sets mac address of VF in migration finish step instead of start step.<br>> The patch aims to reduce packet loss rate.<br><br>I missed this patch when you initially sent it, and see that nobody else<br>responded...<br><br><br>What you're doing here shouldn't be needed. During migration, a macvtap<br>device should be created with ~IFF_UP, and not brought online until<br>qemuInterfaceStartDevice() is called just prior to starting the guest<br>CPUs on the destination; by this time the guest CPUs on the source have<br>already been stopped (and the guest's macvtap interfaces on the source<br>have been set offline). Until a device is IFF_UP, it shouldn't send out<br>any traffic with its MAC address.<br><br>If you look at the macvtap device on the destination and it has IFF_UP<br>set prior to the completion of migration, then there is a bug in libvirt<br>that we need to fix. Otherwise, I think any packet loss you're seeing is<br>coming from something else.<br><br><br>><br>> Signed-off-by: ZhiPeng Lu <lu.zhipeng@zte.com.cn><br>> ---<br>>  src/qemu/qemu_migration.c   | 18 ++++++++++++++++--<br>>  src/util/virnetdevmacvlan.c | 17 +++++++++++------<br>>  2 files changed, 27 insertions(+), 8 deletions(-)<br>><br>> diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c<br>> index 09adb04..795ed71 100644<br>> --- a/src/qemu/qemu_migration.c<br>> +++ b/src/qemu/qemu_migration.c<br>> @@ -5004,7 +5004,7 @@ qemuMigrationPerform(virQEMUDriverPtr driver,<br>>  }<br>>  <br>>  static int<br>> -qemuMigrationVPAssociatePortProfiles(virDomainDefPtr def)<br>> +qemuMigrationVPAssociatePortProfiles(virDomainDefPtr def, const char *stateDir)<br>>  {<br>>      size_t i;<br>>      int last_good_net = -1;<br>> @@ -5013,6 +5013,20 @@ qemuMigrationVPAssociatePortProfiles(virDomainDefPtr def)<br>>      for (i = 0; i < def->nnets; i++) {<br>>          net = def->nets[i];<br>>          if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_DIRECT) {<br>> +            if ((!virDomainNetGetActualVirtPortProfile(net) || (virDomainNetGetActualVirtPortProfile(net) &&<br>> +                 virDomainNetGetActualVirtPortProfile(net)->virtPortType != VIR_NETDEV_VPORT_PROFILE_8021QBG &&<br>> +                virDomainNetGetActualVirtPortProfile(net)->virtPortType != VIR_NETDEV_VPORT_PROFILE_8021QBH)) &&<br>> +                virDomainNetGetActualDirectMode(net) ==<br>> +                 VIR_NETDEV_MACVLAN_MODE_PASSTHRU) {<br>> +                if (virNetDevSaveNetConfig(virDomainNetGetActualDirectDev(net),<br>> +                    -1, stateDir, false) < 0) {<br>> +                    goto err_exit;<br>> +                }<br>> +                if (virNetDevSetNetConfig(virDomainNetGetActualDirectDev(net),<br>> +                    -1, NULL, virDomainNetGetActualVlan(net), &net->mac, false) < 0) {<br>> +                    goto err_exit;<br>> +                }<br>> +            }<br>>              if (virNetDevVPortProfileAssociate(net->ifname,<br>>                                                 virDomainNetGetActualVirtPortProfile(net),<br>>                                                 &net->mac,<br>> @@ -5187,7 +5201,7 @@ qemuMigrationFinish(virQEMUDriverPtr driver,<br>>          goto endjob;<br>>      }<br>>  <br>> -    if (qemuMigrationVPAssociatePortProfiles(vm->def) < 0)<br>> +    if (qemuMigrationVPAssociatePortProfiles(vm->def, cfg->stateDir) < 0)<br>>          goto endjob;<br>>  <br>>      if (mig->network && qemuDomainMigrateOPDRelocate(driver, vm, mig) < 0)<br>> diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c<br>> index 7222b0f..682dcd1 100644<br>> --- a/src/util/virnetdevmacvlan.c<br>> +++ b/src/util/virnetdevmacvlan.c<br>> @@ -1020,12 +1020,17 @@ virNetDevMacVLanCreateWithVPortProfile(const char *ifnameRequested,<br>>               */<br>>              setVlan = false;<br>>          }<br>> -<br>> -        if (virNetDevSaveNetConfig(linkdev, -1, stateDir, setVlan) < 0)<br>> -           return -1;<br>> -<br>> -        if (virNetDevSetNetConfig(linkdev, -1, NULL, vlan, macaddress, setVlan) < 0)<br>> -           return -1;<br>> +        if (vmOp != VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_IN_START &&<br>> +            virtPortProfile && (virtPortProfile->virtPortType == VIR_NETDEV_VPORT_PROFILE_8021QBH ||<br>> +            virtPortProfile->virtPortType == VIR_NETDEV_VPORT_PROFILE_8021QBG)) {<br>> +            if (virNetDevSaveNetConfig(linkdev, -1, stateDir, setVlan) < 0) {<br>> +                return -1;<br>> +            }<br>> +            if (virNetDevSetNetConfig(linkdev, -1, NULL, vlan, macaddress,<br>> +                setVlan) < 0) {<br>> +                return -1;<br>> +            }<br>> +        }<br>>      }<br>>  <br>>      if (ifnameRequested) {<br><br><br></div><p><br></p></div></div></div></div><p><br></p> </div>