Skip to content

Commit

Permalink
Ensure hairpin_mode is set whenever vifs is added to bridge.
Browse files Browse the repository at this point in the history
Fix the bug that when create a snapshot of an instance, the
instance cann't ping it's floating ip.
fix bug lp:1040537

Change-Id: I25aa1a323fa84e8c72f969cb56ada4dffa509150
  • Loading branch information
yaguangtang committed Aug 29, 2012
1 parent 4d2a4af commit 014fcbc
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions nova/virt/libvirt/connection.py
Expand Up @@ -928,8 +928,8 @@ def poll_unconfirmed_resizes(self, resize_confirm_window):
LOG.info(_("Automatically confirming migration %d"), migration.id)
self.compute_api.confirm_resize(ctxt, migration.instance_uuid)

def _enable_hairpin(self, instance):
interfaces = self.get_interfaces(instance['name'])
def _enable_hairpin(self, xml):
interfaces = self.get_interfaces(xml)
for interface in interfaces:
utils.execute('tee',
'/sys/class/net/%s/brport/hairpin_mode' % interface,
Expand All @@ -951,7 +951,6 @@ def spawn(self, context, instance, image_meta, network_info,

self._create_new_domain(xml)
LOG.debug(_("Instance is running"), instance=instance)
self._enable_hairpin(instance)
self.firewall_driver.apply_instance_filter(instance, network_info)

def _wait_for_boot():
Expand Down Expand Up @@ -1619,6 +1618,7 @@ def _create_new_domain(self, xml, persistent=True, launch_flags=0):
else:
# createXML call creates a transient domain
domain = self._conn.createXML(xml, launch_flags)
self._enable_hairpin(domain.XMLDesc(0))

return domain

Expand Down Expand Up @@ -1675,14 +1675,12 @@ def get_disks(self, instance_name):

return disks

def get_interfaces(self, instance_name):
def get_interfaces(self, xml):
"""
Note that this function takes an instance name.
Note that this function takes an instance domain xml.
Returns a list of all network interfaces for this instance.
"""
domain = self._lookup_by_name(instance_name)
xml = domain.XMLDesc(0)
doc = None

try:
Expand Down

0 comments on commit 014fcbc

Please sign in to comment.