From cc8a8ed759049bdaa32649f0aa20dded6c9eddc9 Mon Sep 17 00:00:00 2001 From: Apollon Oikonomopoulos <apollon@noc.grnet.gr> Date: Wed, 22 Jun 2011 12:03:41 +0300 Subject: [PATCH] KVM: configure bridged NICs at migration start Commit 5d9bfd870 moved tap interface handling from KVM to Ganeti, partly to also solve the problem of routed interfaces getting configured too early during live migrations, causing network anomalies. In that direction, configuration of NICs of incoming instances was deferred to FinalizeMigration time. However, this causes minor issues with bridged interfaces; KVM sends out an ARP-like packet upon migration finish, which is lost because the tap interface is not yet configured. As a consequence, intermediate network equipment (i.e. switches) does not get notified about the topology change, until the instance transmits another packet after the bridge has been configured, or the switch's ARP cache expires. The proper solution to that is to support different phases in network configuration (pre/post migration), which also requires separate ifup scripts. Until then we fall back to configuring bridged interfaces on incoming instances at migration start, instead of finish. Signed-off-by: Apollon Oikonomopoulos <apollon@noc.grnet.gr> Signed-off-by: Guido Trotter <ultrotter@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- lib/hypervisor/hv_kvm.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py index e65d3309c..475b99d7e 100644 --- a/lib/hypervisor/hv_kvm.py +++ b/lib/hypervisor/hv_kvm.py @@ -857,11 +857,13 @@ class KVMHypervisor(hv_base.BaseHypervisor): utils.EnsureDirs([(self._InstanceChrootDir(name), constants.SECURE_DIR_MODE)]) - if not incoming: - # Configure the network now for starting instances, during - # FinalizeMigration for incoming instances - for nic_seq, nic in enumerate(kvm_nics): - self._ConfigureNIC(instance, nic_seq, nic, taps[nic_seq]) + # Configure the network now for starting instances and bridged interfaces, + # during FinalizeMigration for incoming instances' routed interfaces + for nic_seq, nic in enumerate(kvm_nics): + if (incoming and + nic.nicparams[constants.NIC_MODE] != constants.NIC_MODE_BRIDGED): + continue + self._ConfigureNIC(instance, nic_seq, nic, taps[nic_seq]) if security_model == constants.HT_SM_POOL: ss = ssconf.SimpleStore() @@ -1026,6 +1028,9 @@ class KVMHypervisor(hv_base.BaseHypervisor): kvm_nics = kvm_runtime[1] for nic_seq, nic in enumerate(kvm_nics): + if nic.nicparams[constants.NIC_MODE] == constants.NIC_MODE_BRIDGED: + # Bridged interfaces have already been configured + continue try: tap = utils.ReadFile(self._InstanceNICFile(instance.name, nic_seq)) except EnvironmentError, err: -- GitLab