[libvirt] "state" drivers?

Daniel P. Berrange berrange at redhat.com
Tue Apr 14 09:00:45 UTC 2009

On Mon, Apr 13, 2009 at 11:39:45AM -0400, Laine Stump wrote:
> I'm looking through the network driver, and see the "state" driver 
> registered. Several other drivers also register a state driver. What is 
> this used for? It looks like it's handling a startup/shutdown at a more 
> basic level than then open/close in the network (storage/qemu/etc) 
> driver itself. Is it the case that things that should happen only once 
> as libvirtd is loaded/unloaded should be put in the state driver's 
> Startup/shutdown?

The 'state' driver is for things which need to maintain global state
within the libvirtd daemon. The QEMU  and network drivers both
maintain state in the libvirtd daemon. The Xen driver does not since
its all delegated to XenD.

> It seems possible that these callouts may be unnecessary in my case, 
> since I'll be modifying the OS's own interface config, so the interfaces 
> will already be up and running by the time libvirtd starts, and should 
> remaining running after libvirtd is unloaded. (as for 
> initializing/shutting down netcf, this may be useful for shutting it 
> down before exit, but its init should probably only be called on demand 
> if someone actually calls a virInterface* function -otherwise we're 
> using up resources for nothing.

Your intuition is correct. There is no need for you to maintain a stateful
driver, since on each API call it'll simply directly read / write the
underlying host OS ifcfg-XXX files (or equiv). There's no real state
the needs to be kept in libvirtd for network interfaces

|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

More information about the libvir-list mailing list