Hi -
The attached patch implements virConnectDiscoverStoragePools mostly as
specified by Daniel Berrange in:
http://www.redhat.com/archives/libvir-list/2008-February/msg00107.html
Daniel wasn't happy with the interface for this function because it
wasn't sufficiently general, so it currently doesn't exist. I've
attempted to generalize his proposed interface by changing the
"hostname" argument to a "srcSpec" argument, which is intended to be
a
XML storage pool <source> element. Note that srcSpec is not necessary
for some (local) pool types.
For example, to discover existing LVM volume groups, there's no need
to specify a source:
virsh # pool-discover logical
While discovering nfs shares requires a <source> document to specify
the host to query:
virsh # pool-discover netfs "<source><host name='share'
/></source>"
Currently (i.e., in this patch) I've implemented discovery support
only for the "logical" and "netfs" pools. I plan on covering the
other
types once we've agreed upon the API. While this patch is rather large,
the vast majority of it is "generic" (not specific to any particular
type of storage pool) code, which I mostly took from Daniel's
submission. I could easily break the storage-pool-type-specific pieces
into separate patches, but those changes are already segregated into the
appropriate storage_backend_ files.
* Known Issues *
I made the virsh interface take a XML string rather than a filename.
I found it convenient, but AFAIK the rest of the commands that take XML
take it from a file, so perhaps that should be changed (just let me know
what you'd prefer).
I realize the description of srcSpec is kind of fuzzy. For instance,
for netfs discovery, the <source> must have a <host> element (to specify
the host to query), but shouldn't have a <dir> element since the
exported dirs are exactly what we're trying to discover in this case.
So this really needs to be documented accurately for each storage pool
type. (Where?)
Finally, there's an underspecification issue. The XML pool
descriptions returned are supposed to be usable as valid input to
virStoragePoolDefineXML. But these descriptions include some data (pool
name, target path) that isn't specified by the discover input or the
discovered resources. For now, I'm making up a somewhat arbitrary pool
name (logical: VolGroup name, netfs: last component of export path).
And I don't even specify <target><path> in the "netfs" discovery
output
(which means it's not valid input to virStoragePoolDefineXML until a
target path is added).
Dave