WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-users

Re: [Xen-users] handling mac addresses and guid's

To: Florian Heigl <florian.heigl@xxxxxxxxx>
Subject: Re: [Xen-users] handling mac addresses and guid's
From: Tim Post <tim.post@xxxxxxxxxxxxxxx>
Date: Mon, 19 Feb 2007 09:35:55 +0800
Cc: xen-users@xxxxxxxxxxxxxxxxxxx
Delivery-date: Sun, 18 Feb 2007 17:35:43 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <77abe410702171909p45430ba0x261ea7d95f7af749@xxxxxxxxxxxxxx>
List-help: <mailto:xen-users-request@lists.xensource.com?subject=help>
List-id: Xen user discussion <xen-users.lists.xensource.com>
List-post: <mailto:xen-users@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=unsubscribe>
Organization: Net Kinetics
References: <77abe410702171909p45430ba0x261ea7d95f7af749@xxxxxxxxxxxxxx>
Reply-to: tim.post@xxxxxxxxxxxxxxx
Sender: xen-users-bounces@xxxxxxxxxxxxxxxxxxx
On Sun, 2007-02-18 at 04:09 +0100, Florian Heigl wrote:
> Hi,
> 
> I like Xen's feature of autogenerating those values if they are not supplied 
> in
> a config file, but for sake of persistency I want to inherit the 
> once-generated
> values and reuse them after the first creation of a domU.
> 
> I found it possible to query the values at runtime using xm list
> --long but I'm not sure I'm going the most elegant route with that, it
> would mean either wrapping around xm create or hacking a script to be
> executed after domU creation to edit the configfile. This sounds messy
> to me.
> 
> How are You handling this?
> 
> Thanks!
> Florian
> 

I use the following shell function to generate macs. The following is my
own code which I'm hereby donating to the public domain. It may be used
for any purpose without credit to the author. This code is not
copyrighted and comes with no warranty.

# Sets a global _MAC , usage :
# makemac
# echo ${_MAC}

makemac()
{
        local prefix="00:00:6d"
        local hextet[3]=""
        local hextet[4]=""
        local hextet[5]=""
        local tmp=""
        local i=3;
        local digi='0a1b2c3d4e5f6789h'
        local offset=$((${#digi} - 1))

        _MAC="$prefix"

        while [ "$i" -le 5 ]; do
                tmp[1]="${digi:$(($RANDOM%${offset})):1}"
                tmp[2]="${digi:$(($RANDOM%${offset})):1}"
                hextet[$i]="${tmp[1]}${tmp[2]}"
                _MAC="${_MAC}:${hextet[i]}"
                let "i += 1"
        done

        unset octet
        unset tmp
        unset prefix
        unset i
}

Change $prefix to match what you want, I believe that is the prefix Xen
was granted to indicate a 'virtual' nic. 

This should be used when creating the guest, so that it keeps its mac.

Hope this helps.

Best,
--Tim


_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-users

<Prev in Thread] Current Thread [Next in Thread>