xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Marcus Granado <marcus.granado@citrix.com>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>,
	xen-devel@lists.xenproject.org, Wei Liu <wei.liu2@citrix.com>,
	joshua Perrett 256 <jperrett256@gmail.com>
Subject: Re: [PATCH] libxl: made vm mac address assignment deterministic
Date: Wed, 12 Sep 2018 10:54:00 +0100	[thread overview]
Message-ID: <2c79bb9f-b6a0-9385-70a2-f46110ea2e38@citrix.com> (raw)

> 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@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

             reply	other threads:[~2018-09-12  9:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-12  9:54 Marcus Granado [this message]
2018-09-12 10:52 ` [PATCH] libxl: made vm mac address assignment deterministic George Dunlap
  -- strict thread matches above, loose matches on Subject: below --
2018-09-05 12:25 Joshua Perrett
2018-09-06 15:51 ` Wei Liu
2018-09-06 16:18   ` Ian Jackson
2018-08-30 15:18 Joshua Perrett
2018-08-31 17:05 ` Wei Liu
2018-08-29 16:34 Joshua Perrett
2018-08-30  8:27 ` Wei Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2c79bb9f-b6a0-9385-70a2-f46110ea2e38@citrix.com \
    --to=marcus.granado@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=jperrett256@gmail.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).