[pve-devel] [PATCH] vm_copy : add optional format parameter

Alexandre Derumier aderumier at odiso.com
Tue Apr 30 10:34:08 CEST 2013


can be qcow2,raw,vmdk

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/API2/Qemu.pm |   19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index fc9b502..f1fc2b5 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -1815,6 +1815,13 @@ __PACKAGE__->register_method({
 		requires => 'full',
 		optional => 1,
 	    }),
+	    format => {
+		description => "Target format for file storage.",
+		requires => 'full',
+		type => 'string',
+		optional => 1,
+		enum => [ 'raw', 'qcow2', 'vmdk'],
+	    },
 	    full => {
 		optional => 1,
 		type => 'boolean',
@@ -1851,6 +1858,8 @@ __PACKAGE__->register_method({
 
 	my $storage = extract_param($param, 'storage');
 
+	my $format = extract_param($param, 'format');
+
 	my $storecfg = PVE::Storage::config();
 
 	PVE::Cluster::check_cfs_quorum();
@@ -1944,8 +1953,14 @@ __PACKAGE__->register_method({
 			    } else {
 				my ($storeid, $volname) = PVE::Storage::parse_volume_id($drive->{file});
 				$storeid = $storage if $storage;
-				my $defformat = PVE::Storage::storage_default_format($storecfg, $storeid);
-				my $fmt = $drive->{format} || $defformat;
+
+				my $fmt = undef;
+				if($format){
+				    $fmt = $format;
+				}else{
+				    my $defformat = PVE::Storage::storage_default_format($storecfg, $storeid);
+				    $fmt = $drive->{format} || $defformat;
+				}
 
 				my ($size) = PVE::Storage::volume_size_info($storecfg, $drive->{file}, 3);
 
-- 
1.7.10.4



More information about the pve-devel mailing list