Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > 0f4597dfcea382fbcd278f684e302b8e > files > 81

lib64virt-devel-1.2.1-1.1.mga4.x86_64.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
        This file is autogenerated from internals.html.in
        Do not edit this file. Changes will be lost.
      -->
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" type="text/css" href="main.css" />
    <link rel="SHORTCUT ICON" href="32favicon.png" />
    <title>libvirt: libvirt internals</title>
    <meta name="description" content="libvirt, virtualization, virtualization API" />
  </head>
  <body>
    <div id="header">
      <div id="headerLogo"></div>
      <div id="headerSearch">
        <form action="search.php" enctype="application/x-www-form-urlencoded" method="get"><div>
            <input id="query" name="query" type="text" size="12" value="" />
            <input id="submit" name="submit" type="submit" value="Search" />
          </div></form>
      </div>
    </div>
    <div id="body">
      <div id="menu">
        <ul class="l0"><li>
            <div>
              <a title="Front page of the libvirt website" class="inactive" href="index.html">Home</a>
            </div>
          </li><li>
            <div>
              <a title="Details of new features and bugs fixed in each release" class="inactive" href="news.html">News</a>
            </div>
          </li><li>
            <div>
              <a title="Applications known to use libvirt" class="inactive" href="apps.html">Applications</a>
            </div>
          </li><li>
            <div>
              <a title="Get the latest source releases, binary builds and get access to the source repository" class="inactive" href="downloads.html">Downloads</a>
            </div>
          </li><li>
            <div>
              <a title="Information for users, administrators and developers" class="active" href="docs.html">Documentation</a>
              <ul class="l1"><li>
                  <div>
                    <a title="How to compile libvirt" class="inactive" href="compiling.html">Compiling</a>
                  </div>
                </li><li>
                  <div>
                    <a title="Information about deploying and using libvirt" class="inactive" href="deployment.html">Deployment</a>
                  </div>
                </li><li>
                  <div>
                    <a title="Overview of the logical subsystems in the libvirt API" class="inactive" href="intro.html">Architecture</a>
                  </div>
                </li><li>
                  <div>
                    <a title="Description of the XML formats used in libvirt" class="inactive" href="format.html">XML format</a>
                  </div>
                </li><li>
                  <div>
                    <a title="Hypervisor specific driver information" class="inactive" href="drivers.html">Drivers</a>
                  </div>
                </li><li>
                  <div>
                    <a title="Reference manual for the C public API" class="inactive" href="html/index.html">API reference</a>
                  </div>
                </li><li>
                  <div>
                    <a title="Bindings of the libvirt API for other languages" class="inactive" href="bindings.html">Language bindings</a>
                  </div>
                </li><li>
                  <div>
                    <span class="active">Internals</span>
                    <ul class="l2"><li>
                        <div>
                          <a title="General hacking guidelines for contributors" class="inactive" href="hacking.html">Contributor guidelines</a>
                        </div>
                      </li><li>
                        <div>
                          <a title="Adding new public libvirt APIs" class="inactive" href="api_extension.html">API extensions</a>
                        </div>
                      </li><li>
                        <div>
                          <a title="Spawning commands from libvirt driver code" class="inactive" href="internals/command.html">Spawning commands</a>
                        </div>
                      </li><li>
                        <div>
                          <a title="RPC protocol information and API / dispatch guide" class="inactive" href="internals/rpc.html">RPC protocol &amp; APIs</a>
                        </div>
                      </li><li>
                        <div>
                          <a title="Use lock managers to protect disk content" class="inactive" href="internals/locking.html">Lock managers</a>
                        </div>
                      </li></ul>
                  </div>
                </li><li>
                  <div>
                    <a title="A guide and reference for developing with libvirt" class="inactive" href="devguide.html">Development Guide</a>
                  </div>
                </li><li>
                  <div>
                    <a title="Command reference for virsh" class="inactive" href="virshcmdref.html">Virsh Commands</a>
                  </div>
                </li></ul>
            </div>
          </li><li>
            <div>
              <a title="User contributed content" class="inactive" href="http://wiki.libvirt.org">Wiki</a>
            </div>
          </li><li>
            <div>
              <a title="Frequently asked questions" class="inactive" href="http://wiki.libvirt.org/page/FAQ">FAQ</a>
            </div>
          </li><li>
            <div>
              <a title="How and where to report bugs and request features" class="inactive" href="bugs.html">Bug reports</a>
            </div>
          </li><li>
            <div>
              <a title="How to contact the developers via email and IRC" class="inactive" href="contact.html">Contact</a>
            </div>
          </li><li>
            <div>
              <a title="Available test suites for libvirt" class="inactive" href="testsuites.html">Test suites</a>
            </div>
          </li><li>
            <div>
              <a title="Miscellaneous links of interest related to libvirt" class="inactive" href="relatedlinks.html">Related Links</a>
            </div>
          </li><li>
            <div>
              <a title="Overview of all content on the website" class="inactive" href="sitemap.html">Sitemap</a>
            </div>
          </li></ul>
      </div>
      <div id="content">
        <h1>libvirt internals</h1>
        <p>
      This section provides documents useful to those working on the libvirt
      internals, adding new public APIs, new hypervisor drivers or extending
      the libvirtd daemon code.
    </p>
        <ul><li>Introduction to basic rules and guidelines for
      <a href="hacking.html" shape="rect">hacking</a> on libvirt code</li><li>Guide to adding <a href="api_extension.html" shape="rect">public APIs</a></li><li>Approach for <a href="internals/command.html" shape="rect">spawning commands</a>
      from libvirt driver code</li><li>The libvirt <a href="internals/rpc.html" shape="rect">RPC infrastructure</a></li><li>The <a href="internals/locking.html" shape="rect">Resource Lock Manager</a></li></ul>
        <p>Before adding new code it will be important to get a basic understanding
    of the many elements involved with making any call or change to the libvirt
    code. The architecture <a href="goals.html" shape="rect">goals</a> must be adhered to
    when submitting new code. Understanding the many places that need to be
    touched and the interactions between various subsystems within libvirt
    will directly correlate to the ability to be successful in getting new
    code accepted.</p>
        <p>The following diagram depicts code flow from a client application, in
    this case the libvirt provided <code>virsh</code> command through the
    various layers to elicit a response from some chosen hypervisor.
    </p>
        <p class="image">
      <img alt="virConnectOpen calling sequence" src="libvirt-virConnect-example.png" />
    </p>
        <ul><li>"virsh -c qemu:///system list --all"
        <p>After the virsh code processes the input arguments, it eventually
        will make a call to open the connection using a default set of
        authentication credentials (virConnectAuthDefault). </p></li><li>virConnectOpenAuth()
        <p>Each of the virConnectOpen APIs will first call virInitialize() and
        then revector through the local "do_open():" call.</p>
          <ul><li>virInitialize()
            <p>Calls the registration API for each of the drivers with
            client-side only capabilities and then call the remoteRegister()
            API last. This ensures the virDriverTab[] tries local drivers
            first before using the remote driver.</p></li><li>Loop through virDriverTab[] entries trying to call their
            respective "open" entry point (in our case remoteOpen())</li><li>After successful return from the virDriverTab[] open()
            API, attempt to find and open other drivers (network, interface,
            storage, etc.)</li></ul>
        </li><li>remoteOpen()
        <p>After a couple of URI checks, a call to doRemoteOpen() is made</p>
          <ul><li>Determine network transport and host/port to use from URI
            <p>The transport will be either tls, unix, ssh, libssh2, ext,
            or tcp with the default of tls. Decode the host/port if provided
            or default to "localhost".</p></li><li>virNetClientRegisterAsyncIO()
            <p>Register an I/O callback mechanism to get returned data via
            virNetClientIncomingEvent()</p></li><li>"call(...REMOTE_PROC_OPEN...)"
            <p>Eventually routes into virNetClientProgramCall() which will
            call virNetClientSendWithReply() and eventually uses
            virNetClientIO()to send the message to libvirtd and
            then waits for a response using virNetClientIOEventLoop()</p></li><li>virNetClientIncomingEvent()
            <p>Receives the returned packet and processes through
            virNetClientIOUpdateCallback()</p></li></ul>
        </li><li>libvirtd Daemon
        <p></p>
          <ul><li>Daemon Startup
              <p>The daemon initialization processing will declare itself
              as a server via a virNetServerNew() call, then use
              virDriverLoadModule() to find/load all known drivers,
              set up an RPC server program using the <code>remoteProcs[]</code>
              table via a virNetServerProgramNew() call. The table is the
              corollary to the <code>remote_procedure</code> enum list in
              the client. It lists all the functions to be called in
              the same order. Once RPC is set up, networking server sockets
              are opened, the various driver state initialization routines
              are run from the <code>virStateDriverTab[]</code>, the network
              links are enabled, and the daemon waits for work.</p></li><li>RPC
              <p>When a message is received, the <code>remoteProcs[]</code>
              table is referenced for the 'REMOTE_PROC_OPEN' call entry.
              This results in remoteDispatchOpen() being called via the
              virNetServerProgramDispatchCall().</p></li><li>remoteDispatchOpen()
              <p>The API will read the argument passed picking out the
              <code>name</code> of the driver to be opened. The code
              will then call virConnectOpen() or virConnectOpenReadOnly()
              depending on the argument <code>flags</code>.</p></li><li>virConnectOpen() or virConnectOpenReadOnly()
              <p>Just like the client except that upon entry the URI
              is what was passed from the client and will be found
              and opened to process the data.</p>
              <p>The returned structure data is returned via the
              virNetServer interfaces to the remote driver which then
              returns it to the client application.</p></li></ul>
        </li></ul>
      </div>
    </div>
    <div id="footer">
      <p id="sponsor">
	    Sponsored by:<br /><a href="http://et.redhat.com/"><img src="et.png" alt="Project sponsored by Red Hat Emerging Technology" /></a></p>
    </div>
  </body>
</html>