implement vdisk_clone and vdisk_create_base
This is an iplementation for file base storage types. changes compared to patches from Alexandre: * use correct locking * private find_free_diskname() with bug fixes * changed names of new methods * always refer to base volumes in volume names Example volume names: local:6000/base-6000-disk-9.raw local:6000/base-6000-disk-9.raw/7000/vm-7000-disk-9.qcow2 local:6000/base-6000-disk-9.raw/7000/base-7000-disk-10.qcow2
This commit is contained in:
@ -417,6 +417,42 @@ sub storage_migrate {
|
||||
}
|
||||
}
|
||||
|
||||
sub vdisk_clone {
|
||||
my ($cfg, $volid, $vmid) = @_;
|
||||
|
||||
my ($storeid, $volname) = parse_volume_id($volid);
|
||||
|
||||
my $scfg = storage_config($cfg, $storeid);
|
||||
|
||||
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
|
||||
|
||||
activate_storage($cfg, $storeid);
|
||||
|
||||
# lock shared storage
|
||||
return $plugin->cluster_lock_storage($storeid, $scfg->{shared}, undef, sub {
|
||||
my $volname = $plugin->clone_image($scfg, $storeid, $volname, $vmid);
|
||||
return "$storeid:$volname";
|
||||
});
|
||||
}
|
||||
|
||||
sub vdisk_create_base {
|
||||
my ($cfg, $volid) = @_;
|
||||
|
||||
my ($storeid, $volname) = parse_volume_id($volid);
|
||||
|
||||
my $scfg = storage_config($cfg, $storeid);
|
||||
|
||||
my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
|
||||
|
||||
activate_storage($cfg, $storeid);
|
||||
|
||||
# lock shared storage
|
||||
return $plugin->cluster_lock_storage($storeid, $scfg->{shared}, undef, sub {
|
||||
my $volname = $plugin->create_base($storeid, $scfg, $volname);
|
||||
return "$storeid:$volname";
|
||||
});
|
||||
}
|
||||
|
||||
sub vdisk_alloc {
|
||||
my ($cfg, $storeid, $vmid, $fmt, $name, $size) = @_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user