On 26.12.2012 16: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);
Some hypervisors manage networks on their own (e.g. VBox) while others
rely on our bridge driver. Since we've switched to C99 struct initialization,
you can simply grep for networkCreateXML:
$ git grep networkCreateXML
and you'll see which functions implements the functionality:
[...]
src/network/bridge_driver.c: .networkCreateXML = networkCreate, /* 0.2.0 */
src/remote/remote_driver.c: .networkCreateXML = remoteNetworkCreateXML, /* 0.3.0 */
src/test/test_driver.c: .networkCreateXML = testNetworkCreate, /* 0.3.2 */
src/vbox/vbox_tmpl.c: .networkCreateXML = vboxNetworkCreateXML, /* 0.6.4 */
And now you can look deeper into networkCreate(), testNetworkCreate() or
vboxNetworkCreateXML().
You can repeat the process with other driver methods and drivers as well.
Michal