From 577ba6267994baecd5f9e05105624536d320cc9b Mon Sep 17 00:00:00 2001 From: Akihiro MOTOKI Date: Fri, 21 Sep 2012 10:08:43 +0900 Subject: Ensure hybrid driver creates veth pair only once. Fixes bug 1053312 This commit fixes a bug that an instance can't obtain IP address by DHCP when using LibvirtHybridOVSBridgeDriver. When nova-compute launches an instance on KVM, vif driver plug() may be called twice and this causes a behavior that a port of OVS cannot seen as a bridge port. So this patch make sure create_veth_pair() is not called if a port already exists. Change-Id: I76792df9f0dd28224d7d57989bf1e8ecadb92606 --- nova/virt/libvirt/vif.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'nova') diff --git a/nova/virt/libvirt/vif.py b/nova/virt/libvirt/vif.py index 1a64765b1..ea0834d87 100644 --- a/nova/virt/libvirt/vif.py +++ b/nova/virt/libvirt/vif.py @@ -212,15 +212,15 @@ class LibvirtHybridOVSBridgeDriver(LibvirtBridgeDriver, br_name = self.get_br_name(iface_id) v1_name, v2_name = self.get_veth_pair_names(iface_id) - linux_net._create_veth_pair(v1_name, v2_name) - if not linux_net._device_exists(br_name): utils.execute('brctl', 'addbr', br_name, run_as_root=True) - utils.execute('ip', 'link', 'set', br_name, 'up', run_as_root=True) - utils.execute('brctl', 'addif', br_name, v1_name, run_as_root=True) - self.create_ovs_vif_port(v2_name, iface_id, mapping['mac'], - instance['uuid']) + if not linux_net._device_exists(v2_name): + linux_net._create_veth_pair(v1_name, v2_name) + utils.execute('ip', 'link', 'set', br_name, 'up', run_as_root=True) + utils.execute('brctl', 'addif', br_name, v1_name, run_as_root=True) + self.create_ovs_vif_port(v2_name, iface_id, mapping['mac'], + instance['uuid']) network['bridge'] = br_name return self._get_configurations(instance, network, mapping) -- cgit