}
sub activate_volume {
- my ($class, $storeid, $scfg, $volname, $cache) = @_;
+ my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
return 1 if !$scfg->{krbd};
my $pool = $scfg->{pool} ? $scfg->{pool} : 'rbd';
my $path = "/dev/rbd/$pool/$name";
+ $path .= '@'.$snapname if $snapname;
return if -b $path;
+ $name .= '@'.$snapname if $snapname;
my $cmd = &$rbd_cmd($scfg, $storeid, 'map', $name);
run_rbd_command($cmd, errmsg => "can't mount rbd volume $name");
}
sub deactivate_volume {
- my ($class, $storeid, $scfg, $volname, $cache) = @_;
+ my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
return 1 if !$scfg->{krbd};
my $pool = $scfg->{pool} ? $scfg->{pool} : 'rbd';
my $path = "/dev/rbd/$pool/$name";
+ $path .= '@'.$snapname if $snapname;
return if ! -b $path;
my $cmd = &$rbd_cmd($scfg, $storeid, 'unmap', $path);
- run_rbd_command($cmd, errmsg => "can't unmount rbd volume $name");
+ run_rbd_command($cmd, errmsg => "can't unmap rbd volume $name");
return 1;
}
return 1 if $running;
+ $class->deactivate_volume($storeid, $scfg, $volname, $snap, {});
+
my ($vtype, $name, $vmid) = $class->parse_volname($volname);
my (undef, undef, undef, $protected) = rbd_volume_info($scfg, $storeid, $name, $snap);
clone => { base => 1, snap => 1},
template => { current => 1},
copy => { base => 1, current => 1, snap => 1},
+ sparseinit => { base => 1, current => 1},
};
my ($vtype, $name, $vmid, $basename, $basevmid, $isBase) =