[libvirt] [PATCH 2/4] Update modified mac address in place in virGetInterface

Daniel Veillard veillard at redhat.com
Wed Jul 22 14:20:24 UTC 2009


On Wed, Jul 22, 2009 at 12:22:08PM +0100, Daniel P. Berrange wrote:
> On Wed, Jul 22, 2009 at 01:20:57AM -0400, Laine Stump wrote:
> > If the mac address of an interface is changed, we must either create a
> > new virInterface object in the cache that has the new name/mac, or
> > modify the existing object in the cache. Because the cache is in a
> > hash that's indexed by name only, we can't create a new entry having
> > the same name without destroying the old one first (which isn't a
> > possibility as someone else is already referencing the old one), so
> > we're stuck modifying the existing entry. We have to do that without
> > changing the pointer to the mac though, so we really can only do it if
> > the length of the new mac is equal to or less than the old
> > mac. Otherwise, we have to just bail.
> > 
> > Fixing this problem to properly handle this corner case would require
> > a hash table that used both name and mac as keys, but that would be
> > inefficient (using the existing hash table implementation, which only
> > allows a single key), and probably unnecessary, as the length of mac
> > for any given interface will never change in practice.
> 
> Yep, the odds of this error case happening are sooooo small, that
> giving a fatal error here is more than good enough.

  Agreed, patch applied, I only had to add _() to get the message
  localized,

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/




More information about the libvir-list mailing list