[libvirt] virsh "net-create" explanation
Osier Yang
jyang at redhat.com
Thu Dec 27 02:16:27 UTC 2012
On 2012年12月26日 23:36, Bilal Ahmad wrote:
> Hi all,
>
> I am new to libvirt and started looking at the source code. While
> tracing back the virsh command "net-create", I got stuck into a loop and
> I would really like someone to explain how this works.
>
> In the virsh-network.c, from:
>
> network = virNetworkCreateXML(ctl->conn, buffer);
>
> I traced back to:
>
> if (conn->networkDriver && conn->networkDriver->networkCreateXML) {
> virNetworkPtr ret;
> ret = conn->networkDriver->networkCreateXML(conn, xmlDesc);
>
> Then I traced back to the following struct to find how networkCreateXML
> is working:
>
> struct _virNetworkDriver {
> const char * name; /* the name of the driver */
> virDrvOpen open;
> virDrvClose close;
> virDrvNumOfNetworks numOfNetworks;
> virDrvListNetworks listNetworks;
> virDrvNumOfDefinedNetworks numOfDefinedNetworks;
> virDrvListDefinedNetworks listDefinedNetworks;
> virDrvListAllNetworks listAllNetworks;
> virDrvNetworkLookupByUUID networkLookupByUUID;
> virDrvNetworkLookupByName networkLookupByName;
> virDrvNetworkCreateXML networkCreateXML;
>
> From the above code, I located the definition of virDrvNetworkCreateXML
> and found the following:
>
> typedef virNetworkPtr
> (*virDrvNetworkCreateXML) (virConnectPtr conn,
> const char *xmlDesc);
> This is where I am unable to trace back to any other code. Can someone
> please explain the code with typedef above and where is the definition
> of the function this function pointer is pointing to? I want to get to
> the root of the networkCreateXML function and how it exactly works. Can
> someone please explain?
>
It's implemented in network driver (src/network/bridge_driver.*).
Similar for other drivers.
> Thanks a lot,
> Bilal
>
>
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
More information about the libvir-list
mailing list