<div dir="ltr">Currently, there is no API which returns configuration/state paths of the network driver.<br>Although it is a private implementation of the network driver, I don't see any harm in<br>making the locations public because although the locations might change, there will always<br>
be a location for these files. There is a need for this API to implement method 2 of the<br>"API to query ip addresses of a given domain", refer:<br><a href="http://www.mail-archive.com/libvir-list@redhat.com/msg79793.html">http://www.mail-archive.com/libvir-list@redhat.com/msg79793.html</a> . It is required to parse<div>
the leases file generated by dnsmasq. So, this API will be used by the qemu driver, but it </div><div>can also be made public, so that, if a user wants to know get some information from a </div><div>configuration file, he can get the location from libvirt and analyze it on his own. Right now,</div>
<div>there is an alternate way to get the info: by using networkDnsmasqLeaseFileNameDefault,</div><div>defined in /src/network/bridge_driver.c Since this function is static, it is part of the private </div><div>implementation and not visible outside. To make it public, the following hack is possible:<div>
<div><br>diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c<br>index a7ff602..7274861 100644<br>--- a/src/network/bridge_driver.c<br>+++ b/src/network/bridge_driver.c<br>@@ -124,7 +124,7 @@ static int networkUnplugBandwidth(virNetworkObjPtr net,<br>
<br> static struct network_driver *driverState = NULL;<br><br>-static char *<br>+char *<br> networkDnsmasqLeaseFileNameDefault(const char *netname)<br> {<br>     char *leasefile;<br>diff --git a/src/network/bridge_driver.h b/src/network/bridge_driver.h<br>
index 50258b5..40e3990 100644<br>--- a/src/network/bridge_driver.h<br>+++ b/src/network/bridge_driver.h<br>@@ -49,6 +49,8 @@ int networkDnsmasqConfContents(virNetworkObjPtr network,<br>                         char **configstr,<br>
                         dnsmasqContext *dctx,<br>                         dnsmasqCapsPtr caps);<br>+char * networkDnsmasqLeaseFileNameDefault(const char *netname)<br>+    ATTRIBUTE_NONNULL(1);<br> # else<br> /* Define no-op replacements that don't drag in any link dependencies.  */<br>
 #  define networkAllocateActualDevice(iface) 0<br>@@ -57,6 +59,7 @@ int networkDnsmasqConfContents(virNetworkObjPtr network,<br> #  define networkGetNetworkAddress(netname, netaddr) (-2)<br> #  define networkDnsmasqConfContents(network, pidfile, configstr, \<br>
                     dctx, caps) 0<br>+#  define networkDnsmasqLeaseFileNameDefault(netname) 0<br> # endif<br><br> typedef char *(*networkDnsmasqLeaseFileNameFunc)(const char *netname);<br><br>Similar hack has been used so that <span style="font-family:arial,sans-serif;font-size:13px">networkAllocateActualDevice() can be called</span></div>
<div><span style="font-family:arial,sans-serif;font-size:13px">from </span><span style="font-size:13px;font-family:arial,sans-serif">qemu_command.c. </span>Although the above method works, we want to have a </div><div>formal API and not leave things like a hack.</div>
<div><br>/*<br> * @conn: connection object<br> * @params: array to populate on output<br> * @nparams: number of parameters that will be filled<br> * @flags: not supported, user should pass 0 for now<br> * return 0 on success -1 otherwise<br>
 * Valid parameter field names:<br> * VIR_NETWORK_CONFIG_DIR, VIR_NETWORK_AUTOSTART_DIR, VIR_STATE_DIR,<br> * VIR_PID_DIR, VIR_DNSMASQ_STATE_DIR, VIR_RADVD_STATE_DIR<br> * All the above will of the type VIR_TYPED_PARAM_STRING<br>
 */<br>int virNetworkGetConfigFileName(virConnectPtr conn,<br>                                virTypedParameterPtr params,<br>                                int nparams,<br>                                unsigned int flags)<br>
<br><br>Nehal J. Wani<br>UG3, BTech CS+MS(CL)<br>IIIT-Hyderabad<br><a href="http://commandlinewani.blogspot.com">http://commandlinewani.blogspot.com</a>
</div></div></div></div>