[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] libxl: made vm mac address assignment deterministic



Wei Liu writes ("Re: [PATCH] libxl: made vm mac address assignment deterministic"):
On Wed, Sep 05, 2018 at 12:25:55PM +0000, Joshua Perrett wrote:
> Uses MD5 on the host mac address, vm name and vif index to generate the
> last three bytes of the vm mac address (for each vm).

There is no such thing as "the" host mac address.  The host might
have several.  However, generally there is a specific interface that
will be used for this guest, depending on the vif connection mode.  In
bridge mode, for example, there is the mac address of the bridge.  I
think you should make sure to use the right interface.

I think you need to add something to the documentation.  You should
mention that this approach is only deterministic *on the same host*
(so in setups where the guest might be started on multiple hosts, with
networked storage, it won't work) and only *with the same physical
nic* (so swapping out the physical nic will change all the guests'
addresses).

As discussed, it looks like the use of a mac address from one of the host physical nics is actually a sort of fixed seed to create a non-changing context for the vm name and the vif index. I noticed two different, simpler to obtain seeds that are designed to be unique, non-changing values for a specific host:

- systemd-based systems use /etc/machine-id as a unique id:https://www.freedesktop.org/software/systemd/man/machine-id.html - libc-based systems use gethostid() as a unique id: http://man7.org/linux/man-pages/man3/gethostid.3.html


I wonder if it is sufficient for the purposes of https://xenproject.atlassian.net/browse/XEN-110 to create the non-changing seed using the following algorithm, instead of using a mac address:

1) if the seed is in the libxl config file, then use it. Useful to create a logical group of hosts sharing the same seed, so that the mac address won't change when vm migrates to another host in this group. Not to be added to the current patch being worked out, but can be easily added in the future.

2) if the seed is not present in the libxl config file, then use /etc/machine-id if present as the seed.

3) if /etc/machine-id is not present, then fall back to gethostid() as the seed. This call seems to be present in both linux and bsds' libc, so I believe this means it's always available for libxl. The reason for using gethostid() only as a fallback is that its man page says it attempts to return a unique id but it doesn't guarantee this in some situations.


The purpose of the above should be simple to understand and improve if necessary from a cursory glance at the code.

Thoughts?

Marcus


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.