
On 10/02/16 17:28, Michal Privoznik wrote:
It is highly unlikely that a backend will know how to create a volume from a different volume (buildVolFrom) and not know how to create an empty volume (createVol). But: 1) we call the function without any prior check so if that's the case we would SIGSEGV immediatelly 2) it's better to be safe than sorry.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/storage/storage_driver.c | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index e0ded01..81b1584 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -2037,6 +2037,13 @@ storageVolCreateXMLFrom(virStoragePoolPtr obj, if (newvol->target.capacity < origvol->target.capacity) newvol->target.capacity = origvol->target.capacity;
+ if (!backend->createVol) { + virReportError(VIR_ERR_NO_SUPPORT, + "%s", _("storage pool does not support volume " + "creation")); + goto cleanup; + } + if (!backend->buildVolFrom) { virReportError(VIR_ERR_NO_SUPPORT, "%s", _("storage pool does not support"
Although I'm still not 100% convinced, how would one attempt to implement volBuild which takes a freshly created volume in that pool without actually supporting volume creation. And if one's aware of this, in my mind, this would effectively end up a deadcode. But the logic is correct and being a little paranoid never hurts, so it's an ACK, unless someone would like to oppose, in which case, feel free to speak. Erik