[pve-devel] [PATCH] add $preparecopy argument to alloc_image
Alexandre Derumier
aderumier at odiso.com
Fri Oct 26 14:33:58 CEST 2012
qemu-img convert need that target volume doesn't exist,
so we only return the target volume name.
exception is lvm and nexenta device, we need to create the volume and return the volumename
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/Storage.pm | 4 ++--
PVE/Storage/ISCSIDirectPlugin.pm | 2 +-
PVE/Storage/ISCSIPlugin.pm | 2 +-
PVE/Storage/LVMPlugin.pm | 2 +-
PVE/Storage/NexentaPlugin.pm | 2 +-
PVE/Storage/Plugin.pm | 4 ++--
PVE/Storage/RBDPlugin.pm | 4 ++--
PVE/Storage/SheepdogPlugin.pm | 4 ++--
8 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/PVE/Storage.pm b/PVE/Storage.pm
index 271b3f9..0604f2a 100755
--- a/PVE/Storage.pm
+++ b/PVE/Storage.pm
@@ -404,7 +404,7 @@ sub storage_migrate {
}
sub vdisk_alloc {
- my ($cfg, $storeid, $vmid, $fmt, $name, $size) = @_;
+ my ($cfg, $storeid, $vmid, $fmt, $name, $size, $preparecopy) = @_;
die "no storage id specified\n" if !$storeid;
@@ -426,7 +426,7 @@ sub vdisk_alloc {
# lock shared storage
return $plugin->cluster_lock_storage($storeid, $scfg->{shared}, undef, sub {
- my $volname = $plugin->alloc_image($storeid, $scfg, $vmid, $fmt, $name, $size);
+ my $volname = $plugin->alloc_image($storeid, $scfg, $vmid, $fmt, $name, $size, $preparecopy);
return "$storeid:$volname";
});
}
diff --git a/PVE/Storage/ISCSIDirectPlugin.pm b/PVE/Storage/ISCSIDirectPlugin.pm
index e2490e8..11149f2 100644
--- a/PVE/Storage/ISCSIDirectPlugin.pm
+++ b/PVE/Storage/ISCSIDirectPlugin.pm
@@ -99,7 +99,7 @@ sub path {
sub alloc_image {
- my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size) = @_;
+ my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size, $preparecopy) = @_;
die "can't allocate space in iscsi storage\n";
}
diff --git a/PVE/Storage/ISCSIPlugin.pm b/PVE/Storage/ISCSIPlugin.pm
index 173ca1d..6ee5bfa 100644
--- a/PVE/Storage/ISCSIPlugin.pm
+++ b/PVE/Storage/ISCSIPlugin.pm
@@ -284,7 +284,7 @@ sub path {
}
sub alloc_image {
- my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size) = @_;
+ my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size, $preparecopy) = @_;
die "can't allocate space in iscsi storage\n";
}
diff --git a/PVE/Storage/LVMPlugin.pm b/PVE/Storage/LVMPlugin.pm
index 9199db1..2efc820 100644
--- a/PVE/Storage/LVMPlugin.pm
+++ b/PVE/Storage/LVMPlugin.pm
@@ -235,7 +235,7 @@ sub path {
}
sub alloc_image {
- my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size) = @_;
+ my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size, $preparecopy) = @_;
die "unsupported format '$fmt'" if $fmt ne 'raw';
diff --git a/PVE/Storage/NexentaPlugin.pm b/PVE/Storage/NexentaPlugin.pm
index a5b6fe2..b5eb415 100644
--- a/PVE/Storage/NexentaPlugin.pm
+++ b/PVE/Storage/NexentaPlugin.pm
@@ -197,7 +197,7 @@ sub path {
sub alloc_image {
- my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size) = @_;
+ my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size, $preparecopy) = @_;
die "unsupported format '$fmt'" if $fmt ne 'raw';
diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
index 08e505e..9de5bb6 100644
--- a/PVE/Storage/Plugin.pm
+++ b/PVE/Storage/Plugin.pm
@@ -398,7 +398,7 @@ sub path {
}
sub alloc_image {
- my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size) = @_;
+ my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size, $preparecopy) = @_;
my $imagedir = $class->get_subdir($scfg, 'images');
$imagedir .= "/$vmid";
@@ -433,7 +433,7 @@ sub alloc_image {
push @$cmd, '-f', $fmt, $path, "${size}K";
- run_command($cmd, errmsg => "unable to create image");
+ run_command($cmd, errmsg => "unable to create image") if !$preparecopy;
return "$vmid/$name";
}
diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
index 33ae853..8290167 100644
--- a/PVE/Storage/RBDPlugin.pm
+++ b/PVE/Storage/RBDPlugin.pm
@@ -184,7 +184,7 @@ sub path {
}
sub alloc_image {
- my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size) = @_;
+ my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size, $preparecopy) = @_;
die "illegal name '$name' - sould be 'vm-$vmid-*'\n"
@@ -206,7 +206,7 @@ sub alloc_image {
if !$name;
my $cmd = &$rbd_cmd($scfg, $storeid, 'create', '--size', ($size/1024), $name);
- run_command($cmd, errmsg => "rbd create $name' error", errfunc => sub {});
+ run_command($cmd, errmsg => "rbd create $name' error", errfunc => sub {}) if !$preparecopy;
return $name;
}
diff --git a/PVE/Storage/SheepdogPlugin.pm b/PVE/Storage/SheepdogPlugin.pm
index 346a2f2..712046e 100644
--- a/PVE/Storage/SheepdogPlugin.pm
+++ b/PVE/Storage/SheepdogPlugin.pm
@@ -98,7 +98,7 @@ sub path {
}
sub alloc_image {
- my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size) = @_;
+ my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size, $preparecopy) = @_;
die "illegal name '$name' - sould be 'vm-$vmid-*'\n"
@@ -121,7 +121,7 @@ sub alloc_image {
my $cmd = &$collie_cmd($scfg, 'vdi', 'create', $name , "${size}KB");
- run_command($cmd, errmsg => "sheepdog create $name' error");
+ run_command($cmd, errmsg => "sheepdog create $name' error") if !$preparecopy;
return $name;
}
--
1.7.10.4
More information about the pve-devel
mailing list