[collectd] [PATCH] Stabilise interface names in libvirt plugin

Florian Forster octo at verplant.org
Tue Feb 2 23:04:36 CET 2010


Hi Gianni,

thanks for your patch and sorry for the delayed reply.

On Mon, Jan 25, 2010 at 12:47:59PM +0000, Gianni Tedesco wrote:
> Xen interface names default to the format "vifXX.Y" where XX is the
> domain ID and Y is the interface ID. The patch works by stripping the
> "vifXX." from the interface name iff it conforms to the described
> naming convention.

on my Xen server the guests' interfaces are named vif2.0, vif7.0 and
vif15.0. So if I strip away the vif{number} part, I get "0" three times.
What would you expect to end up with? Is it possible the convention has
changed since I set up that machine?

> The patch assumes the interface naming scheme so not sure how portable
> it is. Perhaps a better fix would be to use interface MAC addresses.
> It appears that libvirt has no suitable interface for determining the
> interface ID...

Maybe something like this would be a good alternative:

  const char *domain_name = virDomainGetName (dom);
  char expected_if_name[] = "vif{dom id}.";
  if ((domain_name == NULL)
      || (strncmp (if_name, expected_if_name) != 0)
    continue;
  return (domain_name + "-"
    + (if_name = strlen (expected_if_name)))

I.e. if the interface name starts with "vif%u" and you can determine a
domain name, replace that string with that name. In my (possibly
unusual) case, I'd end up with names like "eskarina.0".

As a last note: Such behavior breaks backwards compatibility. It is
therefore necessary that the behavior is optional (configurable) and
defaults to "off".

Regards,
-octo
-- 
Florian octo Forster
Hacker in training
GnuPG: 0x91523C3D
http://verplant.org/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20100202/e26e995a/attachment.pgp 


More information about the collectd mailing list