sub plugindata {
return {
- content => [ {images => 1}, { images => 1 }],
+ content => [ {images => 1, rootdir => 1}, { images => 1 }],
};
}
description => "Authsupported.",
type => 'string',
},
+ krbd => {
+ description => "Access rbd through krbd kernel module.",
+ type => 'boolean',
+ },
};
}
pool => { optional => 1 },
username => { optional => 1 },
content => { optional => 1 },
+ krbd => { optional => 1 },
};
}
my ($class, $volname) = @_;
if ($volname =~ m/^((base-(\d+)-\S+)\/)?((base)?(vm)?-(\d+)-\S+)$/) {
- return ('images', $4, $7, $2, $3, $5);
+ return ('images', $4, $7, $2, $3, $5, 'raw');
}
die "unable to parse rbd volume name '$volname'\n";
$path .= ":auth_supported=none";
}
+ $path = "/dev/rbd/$pool/$name" if $scfg->{krbd};
+
return ($path, $vmid, $vtype);
}
}
}
+ $class->deactivate_volume($storeid, $scfg, $volname);
+
my $cmd = &$rbd_cmd($scfg, $storeid, 'snap', 'purge', $name);
run_rbd_command($cmd, errmsg => "rbd snap purge '$volname' error");
}
sub activate_volume {
- my ($class, $storeid, $scfg, $volname, $exclusive, $cache) = @_;
+ my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
+
+ return 1 if !$scfg->{krbd};
+
+ my ($vtype, $name, $vmid) = $class->parse_volname($volname);
+ 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");
+
return 1;
}
sub deactivate_volume {
- my ($class, $storeid, $scfg, $volname, $exclusive, $cache) = @_;
+ my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
+
+ return 1 if !$scfg->{krbd};
+
+ my ($vtype, $name, $vmid) = $class->parse_volname($volname);
+ 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 unmap rbd volume $name");
+
return 1;
}
}
sub volume_snapshot {
- my ($class, $scfg, $storeid, $volname, $snap, $running) = @_;
-
- return 1 if $running;
+ my ($class, $scfg, $storeid, $volname, $snap) = @_;
my ($vtype, $name, $vmid) = $class->parse_volname($volname);
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) =