[libvirt] virsh "net-create" explanation

Bilal Ahmad bilalahmadlog at gmail.com
Wed Dec 26 15:36:00 UTC 2012


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?

Thanks a lot,
Bilal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20121226/4f09dc95/attachment-0001.htm>


More information about the libvir-list mailing list