[libvirt] [v2 RESEND PATCH] qemu: reduce packet loss rate for vm with macvtap passthrough mode in migration
Laine Stump
laine at laine.org
Sun Jul 16 21:00:56 UTC 2017
On 06/14/2017 04:29 AM, ZhiPeng Lu wrote:
> Before libvirt that calls virNetDevMacVLanCreateWithVPortProfile sets mac address
> or vlan of a Virtual Function(VF) linked to a macvtap passthrough device of migration
> destination host in migration start step. If we ping the migrating vm,
> we get the network does not pass. Because VFs of migration source and destination
> have the same MAC address. The patch later calling qemuMigrationVPAssociatePortProfiles
> sets mac address of VF in migration finish step instead of start step.
> The patch aims to reduce packet loss rate.
I missed this patch when you initially sent it, and see that nobody else
responded...
What you're doing here shouldn't be needed. During migration, a macvtap
device should be created with ~IFF_UP, and not brought online until
qemuInterfaceStartDevice() is called just prior to starting the guest
CPUs on the destination; by this time the guest CPUs on the source have
already been stopped (and the guest's macvtap interfaces on the source
have been set offline). Until a device is IFF_UP, it shouldn't send out
any traffic with its MAC address.
If you look at the macvtap device on the destination and it has IFF_UP
set prior to the completion of migration, then there is a bug in libvirt
that we need to fix. Otherwise, I think any packet loss you're seeing is
coming from something else.
>
> Signed-off-by: ZhiPeng Lu <lu.zhipeng at zte.com.cn>
> ---
> src/qemu/qemu_migration.c | 18 ++++++++++++++++--
> src/util/virnetdevmacvlan.c | 17 +++++++++++------
> 2 files changed, 27 insertions(+), 8 deletions(-)
>
> diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
> index 09adb04..795ed71 100644
> --- a/src/qemu/qemu_migration.c
> +++ b/src/qemu/qemu_migration.c
> @@ -5004,7 +5004,7 @@ qemuMigrationPerform(virQEMUDriverPtr driver,
> }
>
> static int
> -qemuMigrationVPAssociatePortProfiles(virDomainDefPtr def)
> +qemuMigrationVPAssociatePortProfiles(virDomainDefPtr def, const char *stateDir)
> {
> size_t i;
> int last_good_net = -1;
> @@ -5013,6 +5013,20 @@ qemuMigrationVPAssociatePortProfiles(virDomainDefPtr def)
> for (i = 0; i < def->nnets; i++) {
> net = def->nets[i];
> if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_DIRECT) {
> + if ((!virDomainNetGetActualVirtPortProfile(net) || (virDomainNetGetActualVirtPortProfile(net) &&
> + virDomainNetGetActualVirtPortProfile(net)->virtPortType != VIR_NETDEV_VPORT_PROFILE_8021QBG &&
> + virDomainNetGetActualVirtPortProfile(net)->virtPortType != VIR_NETDEV_VPORT_PROFILE_8021QBH)) &&
> + virDomainNetGetActualDirectMode(net) ==
> + VIR_NETDEV_MACVLAN_MODE_PASSTHRU) {
> + if (virNetDevSaveNetConfig(virDomainNetGetActualDirectDev(net),
> + -1, stateDir, false) < 0) {
> + goto err_exit;
> + }
> + if (virNetDevSetNetConfig(virDomainNetGetActualDirectDev(net),
> + -1, NULL, virDomainNetGetActualVlan(net), &net->mac, false) < 0) {
> + goto err_exit;
> + }
> + }
> if (virNetDevVPortProfileAssociate(net->ifname,
> virDomainNetGetActualVirtPortProfile(net),
> &net->mac,
> @@ -5187,7 +5201,7 @@ qemuMigrationFinish(virQEMUDriverPtr driver,
> goto endjob;
> }
>
> - if (qemuMigrationVPAssociatePortProfiles(vm->def) < 0)
> + if (qemuMigrationVPAssociatePortProfiles(vm->def, cfg->stateDir) < 0)
> goto endjob;
>
> if (mig->network && qemuDomainMigrateOPDRelocate(driver, vm, mig) < 0)
> diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
> index 7222b0f..682dcd1 100644
> --- a/src/util/virnetdevmacvlan.c
> +++ b/src/util/virnetdevmacvlan.c
> @@ -1020,12 +1020,17 @@ virNetDevMacVLanCreateWithVPortProfile(const char *ifnameRequested,
> */
> setVlan = false;
> }
> -
> - if (virNetDevSaveNetConfig(linkdev, -1, stateDir, setVlan) < 0)
> - return -1;
> -
> - if (virNetDevSetNetConfig(linkdev, -1, NULL, vlan, macaddress, setVlan) < 0)
> - return -1;
> + if (vmOp != VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_IN_START &&
> + virtPortProfile && (virtPortProfile->virtPortType == VIR_NETDEV_VPORT_PROFILE_8021QBH ||
> + virtPortProfile->virtPortType == VIR_NETDEV_VPORT_PROFILE_8021QBG)) {
> + if (virNetDevSaveNetConfig(linkdev, -1, stateDir, setVlan) < 0) {
> + return -1;
> + }
> + if (virNetDevSetNetConfig(linkdev, -1, NULL, vlan, macaddress,
> + setVlan) < 0) {
> + return -1;
> + }
> + }
> }
>
> if (ifnameRequested) {
More information about the libvir-list
mailing list