<div dir="ltr">Eric, could you please share your opinion as to what should be more appropriate to use for this functionality: Structs/XML/VirTypedParams ?</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jul 2, 2013 at 7:25 PM, Osier Yang <span dir="ltr"><<a href="mailto:jyang@redhat.com" target="_blank">jyang@redhat.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 02/07/13 18:33, Daniel P. Berrange wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Fri, Jun 28, 2013 at 03:56:10PM +0530, Nehal J. Wani wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello, fellow developers!<br>
       I am a GSoC candidate this year working for <a href="http://libvirt.org" target="_blank">libvirt.org</a>. My<br>
project is "Introduce API to query IP addresses for given domain".<br>
The discussion regarding this feature had started here:<br>
<a href="http://www.mail-archive.com/libvir-list@redhat.com/msg51857.html" target="_blank">http://www.mail-archive.com/<u></u>libvir-list@redhat.com/<u></u>msg51857.html</a> and<br>
then Michal had sent a patch too (refer:<br>
<a href="http://www.mail-archive.com/libvir-list@redhat.com/msg57141.html" target="_blank">http://www.mail-archive.com/<u></u>libvir-list@redhat.com/<u></u>msg57141.html</a>). But<br>
it was not pushed upstream due to lack of extensibility.<br>
<br>
So far I've come up with an API and I want to get your opinion before<br>
I start writing the rest so I don't follow the wrong direction.<br>
<br>
Following are the valid commands:<br>
<br>
domifaddr <domain-name><br>
domifaddr <domain-name> <interface-name><br>
domifaddr <domain-name> <interface-name> <method><br>
domifaddr <domain-name> <method><br>
</blockquote>
What are valid values for '<method>' here ?<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
methods:<br>
(i) Querying qemu-guest-agent<br>
(ii) Getting info from dnsmasq.leases file<br>
(iii) Using the nwfilter to snoop the traffic<br>
<br>
If no method is mentioned, qemu-guest-agent will be used.<br>
<br>
Previous attempts by Michal had used structs and xml. Structs bring in<br>
restrictions and xml has to be parsed. Hence I am not planning to<br>
continue with either of these.<br>
<br>
As a start, I would like to know your comments about my API which<br>
queries the qemu-guest-agent and returns the results in<br>
virTypedParameter **params.<br>
<br>
Format(JSON) in which the qemu guest agent returns info:<br>
<br>
[{"name":"lo",<br>
        "ip-addresses":<br>
                [{"ip-address-type":"ipv4","<u></u>ip-address":"127.0.0.1","<u></u>prefix":8},<br>
                {"ip-address-type":"ipv6","ip-<u></u>address":"::1","prefix":128}],<br>
         "hardware-address":"00:00:00:<u></u>00:00:00"},<br>
{"name":"eth0",<br>
        "ip-addresses":<br>
                [{"ip-address-type":"ipv4","<u></u>ip-address":"192.168.122.42","<u></u>prefix":24},<br>
                {"ip-address-type":"ipv6","ip-<u></u>address":"fe80::5054:ff:fe09:<u></u>d240","prefix":64}],<br>
         "hardware-address":"52:54:00:<u></u>09:d2:40"}]<br>
<br>
//Possible 1-D Structure (A little hassle to maintain)<br>
<br>
params[0] = {"iface-count",int,2}<br>
params[1] = {"iface-name",string,"lo"}<br>
params[2] = {"iface-hwaddr",string,"00:00:<u></u>00:00:00:00"}<br>
params[3] = {"iface-addr-count",int,2}<br>
params[4] = {"iface-addr-type",string,"<u></u>ipv4"}<br>
params[5] = {"iface-addr",string,"127.0.0.<u></u>1"}<br>
params[6] = {"iface-addr-prefix",int,8}<br>
params[7] = {"iface-addr-type",string,"<u></u>ipv6"}<br>
params[8] = {"iface-addr",string,"::1"}<br>
params[9] = {"iface-addr-prefix",int,128}<br>
....<br>
....<br>
....<br>
<br>
//2D Structure: (Not very hasslefree, but easier to maintain as one<br>
interface per row)<br>
<br>
params[0] = {"iface-name",string,"lo"}{"<u></u>iface-hwaddr",string,"00:00:<u></u>00:00:00:00"}{"iface-addr-<u></u>type",string,"ipv4"}{"iface-<u></u>addr",string,"127.0.0.1"}{"<u></u>iface-addr-prefix",int,8}{"<u></u>iface-addr-type",string,"ipv6"<u></u>}{"iface-addr",string,"::1"}{"<u></u>iface-addr-prefix",int,128}<br>

params[1] = {"iface-name",string,"eth0"}{"<u></u>iface-hwaddr",string,"52:54:<u></u>00:09:d2:40"}{"iface-addr-<u></u>type",string,"ipv4"}{"iface-<u></u>addr",string,"192.168.122.42"}<u></u>{"iface-addr-prefix",int,8}{"<u></u>iface-addr-type",string,"ipv6"<u></u>}{"iface-addr",string,"fe80::<u></u>5054:ff:fe09:d240"}{"iface-<u></u>addr-prefix",int,64}<br>

</blockquote>
IMHO both of these approaches to encoding the data in virTypedParameter<br>
are seriously unpleasant for an app to deal with. Now this is a true for<br>
virTypedParameter in general, but I think that the need to deal with a<br>
list of objects here, each containing a list of typed parameters makes<br>
it even worse than normal. I wouldn't really like this as an application<br>
developer.<br>
<br>
Looking at this possible approach of virTypedParameter, I'm think I am<br>
preferring either the XML or fixed struct approach to this API as was<br>
proposed in the past, with a bias towards a fixed struct for simplicity<br>
of use by app developers.<br>
</blockquote>
<br></div></div>
agreed.<br>
<br>
after seeing the trouble caused by multiple addrs, i'm not sure about using virTypedParameter too. even if we have an array type value, it still looks like not easy to use for api user, one has to know how many elements of the array too.<br>

<br>
 <br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Regards,<br>
Danuiel<br>
</blockquote>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Nehal J. Wani<br>
UG2, BTech CS+MS(CL)<br>
IIIT-Hyderabad<div><a href="http://commandlinewani.blogspot.com" target="_blank">http://commandlinewani.blogspot.com</a></div></div>
</div>