To me the easy way would be to just assign them as you create them; you could even make a simple script to just auto-increment the mac address each time you create a new domain. I personally don't see the benefit of having dynamically assigned mac addresses, but to each his own. =)

-Andrew


Joseph Mocker wrote:
Thanks for the info. I'm doing something similar to the original where I want to get the generated MAC addresses when I create a domain, which I then use to create static DHCP assignments.

I was hoping there was a better way, than parsing virsh XML, but it sounds like that's all there is. I suppose I could probably write utility using libvirt, but that's just overachieving then, isn't it.

:-)

 --joe

Ian Blenke wrote:
If a domain isn't running, it won't have a dynamically assigned MAC address assigned.

Starting with Xen 3.0.4, "xm new" keeps a "persistent config" copy to remember the config when a domain isn't running.

The virsh equivalent to this is "virsh define". When you "virsh define config.sxp", that will be parsed by libvirt and turned into an "xm new" persistent config.

Under Solaris xVM, xend keeps this "persistent config" copy in /var/lib/xend/domains/${uuid}/config.sxp

That's that "nasty LISPish" SXP format.

You are correct in that only running domains are shown using the xenstore tools, as the only time xenstored (which hooks into the xen hypervisor xenstore with callbacks, etc) are aware of a domain's configuration is when the domain is running.

Hope this helps.

- Ian C. Blenke <[email protected]> <[email protected]> http://ian.blenke.com/

On 3/2/09 1:21 PM, "Joseph Mocker" <[email protected]> wrote:

Will the xenstore method get all VMs or just running VMs? With my
limited use of the xenstore commands I recall seeing the later behavior.

  --joe

Ian Blenke wrote:
This seems to come up every few months.

If you're dead set on shell scripting it, there are always the xenstore
commands.

You're probably used to seeing the SXP formatted format of "xm list -l".
That's a bit difficult to parse using shell tools. Try this instead:

  /usr/lib/xen/bin/xenstore-ls

To list all of the VMs and their MAC address, you could use:

  /usr/lib/xen/bin/xenstore-list /vm | while read uuid ; do
    echo $(/usr/lib/xen/bin/xenstore-read /vm/${uuid}/name \
           /vm/${uuid}/device/vif/0/mac ) ; \
  done

Hope this helps.

- Ian Blenke <[email protected]> <[email protected]> http://ian.blenke.com/

On 3/2/09 12:46 AM, "David Edmondson" <[email protected]> wrote:


On 28 Feb 2009, at 11:01pm, James Adams wrote:


I'm creating a new domU using 'virsh create <xmlfile>' without
specifying the MAC address within the XML file, under the assumption
that the dom0 or hypervisor generates the MAC address for me.  Next
I'd like to get the MAC address that was assigned to this new domU,
and I don't see a way to get that information from the command line
via virsh or xm.  The closest thing I've found is that you can use
'xm info' and it will give you some MAC address-looking values in
its hw_caps line, but I can't find any documentation which explains
how to interpret these values and whether or not they're actually
related to any of the domUs.  I'd like to leverage a shell command
if possible for this since I'm communicating with the machine that
is running xVM via ssh from a Java program.  Can anyone give me any
suggestions on how I'd go about doing this?

As Andrew says, dumping the configuration of the domain is the right
way to go. I'd encourage you to parse the XML with a more complete
tool than 'grep' though ;-)

_______________________________________________
xen-discuss mailing list
[email protected]


_______________________________________________
xen-discuss mailing list
[email protected]



_______________________________________________
xen-discuss mailing list
[email protected]
_______________________________________________
xen-discuss mailing list
[email protected]

Reply via email to