Search code examples
libvirtvirsh

virsh - difference between pool-define-as and pool-create-as


Not sure if this is the right forum. libvirt page linked here. If this needs to be posted at a different place plaease let me know.

What is the difference between virsh pool-define-as and create-as? Reading the man page for virsh, it seems you avoid having to run pool build and pool start when using create-as. Is that the only difference? My testing indicates both picks up existing files ( in the case of pool type dir ) as volumes. Am I missing anything.

Thanks, Ashok


Solution

  • Objects in libvirt can be either transient or persistent. A transient object only exists for as long as it is running, while a persistent object exists all the time. Essentially with a persistent object the XML configuration is saved by libvirt in /etc/libvirt.

    So in the case of storage pools, if you use 'virsh pool-define-as' you'll be created a configuration file for a persistent storage pool. You can later start this storage pool using 'virsh pool-start', stop it with 'virsh pool-destroy' and start it again later, or even set it to auto-start on host boot.

    If you want a transient storage pool, you can use 'virsh pool-create-as' which will immediately start a storage pool, without saving its config on disk. This storage pool will totally disappear when you do 'virsh pool-destory' (though the actually storage will still exist, libvirt simply won't know about it). Witha transient storage pool, you obviously can't make it auto-start on boot, since libvirt doesn't know about its config.

    As a general rule, most people/apps will want to use persistent pools.