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? Thanks in advance for any ideas. --James
You can use xmldump command to give you the assigned mac address: virsh xmldump <domain> | grep mac -Andrew 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? > > Thanks in advance for any ideas. > > --James > _______________________________________________ > xen-discuss mailing list > xen-discuss@opensolaris.org
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 ;-)
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 <ian@blenke.com> <iblenke@csdvrs.com> http://ian.blenke.com/ On 3/2/09 12:46 AM, "David Edmondson" <dme@sun.com> 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 > xen-discuss@opensolaris.org >
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 <ian@blenke.com> <iblenke@csdvrs.com> http://ian.blenke.com/ > > On 3/2/09 12:46 AM, "David Edmondson" <dme@sun.com> 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 >> xen-discuss@opensolaris.org >> >> > > _______________________________________________ > xen-discuss mailing list > xen-discuss@opensolaris.org >
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 <ian@blenke.com> <iblenke@csdvrs.com> http://ian.blenke.com/ On 3/2/09 1:21 PM, "Joseph Mocker" <mock@sun.com> 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 <ian@blenke.com> <iblenke@csdvrs.com> http://ian.blenke.com/ > > On 3/2/09 12:46 AM, "David Edmondson" <dme@sun.com> 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 >> xen-discuss@opensolaris.org >> >> > > _______________________________________________ > xen-discuss mailing list > xen-discuss@opensolaris.org >
On Mon, Mar 02, 2009 at 10:21:57AM -0800, Joseph Mocker 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.Right. Parsing the XML from virsh dumpxml is (sadly) the only way right now. regards john
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 <ian@blenke.com> <iblenke@csdvrs.com> http://ian.blenke.com/ > > On 3/2/09 1:21 PM, "Joseph Mocker" <mock@sun.com> 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 <ian@blenke.com> <iblenke@csdvrs.com> http://ian.blenke.com/ >> >> On 3/2/09 12:46 AM, "David Edmondson" <dme@sun.com> 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 >>> xen-discuss@opensolaris.org >>> >>> >>> >> _______________________________________________ >> xen-discuss mailing list >> xen-discuss@opensolaris.org >> >> > >
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 <ian@blenke.com> <iblenke@csdvrs.com> >> http://ian.blenke.com/ >> >> On 3/2/09 1:21 PM, "Joseph Mocker" <mock@sun.com> 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 <ian@blenke.com> <iblenke@csdvrs.com> >>> http://ian.blenke.com/ >>> >>> On 3/2/09 12:46 AM, "David Edmondson" <dme@sun.com> 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 >>>> xen-discuss@opensolaris.org >>>> >>>> >>>> >>> _______________________________________________ >>> xen-discuss mailing list >>> xen-discuss@opensolaris.org >>> >>> >> >> > > _______________________________________________ > xen-discuss mailing list > xen-discuss@opensolaris.org
Yes you are right, that is probably a better way to go. It did go through my head at the time, I''m not sure why I didn''t follow through with that . Course since I can create a domain on any number of physical hosts, that would mean I would need to keep the "last mac address" file somewhere that each physical host could read and update it. Then for good measure I should probably put some locking around it so, if two domains were created at the same time, they wouldn''t both get the same mac address. --joe Andrew Chester wrote:> 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 <ian@blenke.com> <iblenke@csdvrs.com> >>> http://ian.blenke.com/ >>> >>> On 3/2/09 1:21 PM, "Joseph Mocker" <mock@sun.com> 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 <ian@blenke.com> <iblenke@csdvrs.com> >>>> http://ian.blenke.com/ >>>> >>>> On 3/2/09 12:46 AM, "David Edmondson" <dme@sun.com> 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 >>>>> xen-discuss@opensolaris.org >>>>> >>>>> >>>>> >>>> _______________________________________________ >>>> xen-discuss mailing list >>>> xen-discuss@opensolaris.org >>>> >>>> >>> >>> >> >> _______________________________________________ >> xen-discuss mailing list >> xen-discuss@opensolaris.org
Joseph Mocker wrote:> Yes you are right, that is probably a better way to go. It did go > through my head at the time, I''m not sure why I didn''t follow through > with that . > Course since I can create a domain on any number of physical hosts, that > would mean I would need to keep the "last mac address" file somewhere > that each physical host could read and update it. Then for good measure > I should probably put some locking around it so, if two domains were > created at the same time, they wouldn''t both get the same mac address.Or you could give each physical host a unique token, and include that in the mac addresses it generates. Then you''re guaranteed to have no conflicts, and no locking needed. Plus it makes the system a little more debuggable and observable, as you can now tell where a domain was created by looking at its mac. - R> > --joe > > Andrew Chester wrote: >> 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 <ian@blenke.com> <iblenke@csdvrs.com> >>>> http://ian.blenke.com/ >>>> >>>> On 3/2/09 1:21 PM, "Joseph Mocker" <mock@sun.com> 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 <ian@blenke.com> <iblenke@csdvrs.com> >>>>> http://ian.blenke.com/ >>>>> >>>>> On 3/2/09 12:46 AM, "David Edmondson" <dme@sun.com> 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 >>>>>> xen-discuss@opensolaris.org >>>>>> >>>>>> >>>>>> >>>>> _______________________________________________ >>>>> xen-discuss mailing list >>>>> xen-discuss@opensolaris.org >>>>> >>>>> >>>> >>>> >>> >>> _______________________________________________ >>> xen-discuss mailing list >>> xen-discuss@opensolaris.org > > _______________________________________________ > xen-discuss mailing list > xen-discuss@opensolaris.org-- ----------------------------------------------------- Russ Blaine | Solaris Kernel | russell.blaine@sun.com
Russ Blaine wrote:> Joseph Mocker wrote: >> Yes you are right, that is probably a better way to go. It did go >> through my head at the time, I''m not sure why I didn''t follow through >> with that . >> Course since I can create a domain on any number of physical hosts, >> that would mean I would need to keep the "last mac address" file >> somewhere that each physical host could read and update it. Then for >> good measure I should probably put some locking around it so, if two >> domains were created at the same time, they wouldn''t both get the >> same mac address. > > Or you could give each physical host a unique token, and include that > in the mac addresses it generates. Then you''re guaranteed to have no > conflicts, and no locking needed. Plus it makes the system a little > more debuggable and observable, as you can now tell where a domain was > created by looking at its mac.Good points. How useful could knowing where a domain was created be? Seems like now managing a N token files and N counter files is now getting more complex than the possible benefits. The Sun DHCP server I''m using has a comment field, which I am using to store domain+hostname information in, I could always extend that to also include a "created on" section. Still, I think some sort of self-generation is a better way to go, since I''m guessing its just a matter of time before letting virsh do it will result in a duplication somewhere. --joe> > - R > >> >> --joe >> >> Andrew Chester wrote: >>> 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 <ian@blenke.com> <iblenke@csdvrs.com> >>>>> http://ian.blenke.com/ >>>>> >>>>> On 3/2/09 1:21 PM, "Joseph Mocker" <mock@sun.com> 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 <ian@blenke.com> <iblenke@csdvrs.com> >>>>>> http://ian.blenke.com/ >>>>>> >>>>>> On 3/2/09 12:46 AM, "David Edmondson" <dme@sun.com> 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 >>>>>>> xen-discuss@opensolaris.org >>>>>>> >>>>>>> >>>>>>> >>>>>> _______________________________________________ >>>>>> xen-discuss mailing list >>>>>> xen-discuss@opensolaris.org >>>>>> >>>>>> >>>>> >>>>> >>>> >>>> _______________________________________________ >>>> xen-discuss mailing list >>>> xen-discuss@opensolaris.org >> >> _______________________________________________ >> xen-discuss mailing list >> xen-discuss@opensolaris.org >
Joseph Mocker wrote:> > Still, I think some sort of self-generation is a better way to go, since > I''m guessing its just a matter of time before letting virsh do it will > result in a duplication somewhere. >Is this really the case? I thought MAC addresses had to be unique, and hence that you could reasonably expect xVM to dynamically allocate them in a way which ensured their uniqueness. If this can''t be relied upon then I agree that self-generation is the way to go, but I was hoping to not go that route in order to avoid the requisite bookkeeping it entails. Can someone who''s really in-the-know verify this one way or the other? --James
On 2 Mar 2009, at 6:32pm, Ian Blenke wrote:> If a domain isn''t running, it won''t have a dynamically assigned MAC > address assigned.Domains created by virt-install are managed domains - their configuration persists when they are not running. Further, the MAC address of the domain is assigned at virt-install time, it will not change from one time the domain is run to another.