[pve-devel] [PATCH v2 storage] map_volume: fall back to 'path'

Mira Limbeck m.limbeck at proxmox.com
Mon Apr 29 15:00:38 CEST 2019


Adds a fallback to 'Plugin::path' in the default implementation of
'map_volume' to simplify a common case of calling 'map_volume' followed
by a defined-check and a call to path if it is not. The path is now
always returned if the plugin in question does not override
'map_volume'.

Signed-off-by: Mira Limbeck <m.limbeck at proxmox.com>
---
v2:
 - added Thomas' suggestion to just return $path instead of the whole
   'wantarray' thing

 PVE/Storage/Plugin.pm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
index 7964441..cca0ed8 100644
--- a/PVE/Storage/Plugin.pm
+++ b/PVE/Storage/Plugin.pm
@@ -966,7 +966,8 @@ sub deactivate_storage {
 sub map_volume {
     my ($class, $storeid, $scfg, $volname, $snapname) = @_;
 
-    return undef;
+    my ($path) = $class->path($scfg, $volname, $storeid, $snapname);
+    return $path;
 }
 
 sub unmap_volume {
-- 
2.11.0





More information about the pve-devel mailing list