3

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

thegrind
  • 33
  • 6

1 Answers1

5

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.

DanielB
  • 1,802
  • 7
  • 11
  • Daniel, Thanks. Good to know objects from "create-as" option are transient. Is there also a distinction that either one of the options can piggy-back on existing storage components (like LVM) where as the other tried to create the underlying pieces (agian using LVM as an example). ? Also, is it legitimate to dump a transient object xml definition into /etc/libvirt and expect it to be persistent across reboots. Thanks. – thegrind Jan 05 '17 at 00:09
  • 1
    Neither pool-create-as or pool-define-as will affect the underlying storage. They'll both merely detect existing storage, ie they'll probe existing LVs in a LVM vol group. The 'pool-build' operation is the "dangerous" one in that it actually formats a new volume group from scratch. And of course vol-create/vol-delete which do what their names suggest. Yes, you can turn an existing transient pool into a persistent pool by just doing `virsh pool-dumpxml foo > foo.xml && virsh pool-define foo.xml` – DanielB Jan 05 '17 at 00:13
  • Also, it is my hope that one day all of these great information shared here and there can be accessed/oraganized/summarized from one place ( man page?). Imagine the wealth of authoritative info that can be centralized and the amount of time saved. Would have definitely saved me a day just on this one. I can only only dream because I am not a good coder :) – thegrind Jan 05 '17 at 00:17
  • Above was a generic comment from my experience with all the technolgies, not specific to libvirt. – thegrind Jan 05 '17 at 00:24
  • Daniel, Thanks again for the clarification. – thegrind Jan 05 '17 at 00:24