]> git.proxmox.com Git - qemu-server.git/commitdiff
copy_vm : add optional storage parameter
authorAlexandre Derumier <aderumier@odiso.com>
Tue, 30 Apr 2013 05:08:27 +0000 (07:08 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 30 Apr 2013 05:16:54 +0000 (07:16 +0200)
Optionnal target storage for full copy

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
PVE/API2/Qemu.pm

index 8a15abcca655be18dfbda1a567e4ab03665f6695..0fe0045b8fea874c579f266986da0a8ff6a5a674 100644 (file)
@@ -60,7 +60,7 @@ my $check_storage_access = sub {
 };
 
 my $check_storage_access_copy = sub {
-   my ($rpcenv, $authuser, $storecfg, $conf) = @_;
+   my ($rpcenv, $authuser, $storecfg, $conf, $storage) = @_;
 
    PVE::QemuServer::foreach_drive($conf, sub {
        my ($ds, $drive) = @_;
@@ -80,6 +80,7 @@ my $check_storage_access_copy = sub {
        } else {
            my ($sid, $volname) = PVE::Storage::parse_volume_id($volid, 1);
            die "unable to copy arbitrary files\n" if !$sid;
+           $sid = $storage if $storage;
            $rpcenv->check($authuser, "/storage/$sid", ['Datastore.AllocateSpace']);
        }
     });
@@ -1806,6 +1807,10 @@ __PACKAGE__->register_method({
                type => 'string', format => 'pve-poolid',
                description => "Add the new VM to the specified pool.",
            },
+           storage => get_standard_option('pve-storage-id', {
+               description => "Target storage for full copy.",
+               optional => 1,
+           }),
            full => {
                optional => 1,
                type => 'boolean',
@@ -1838,6 +1843,8 @@ __PACKAGE__->register_method({
            $rpcenv->check_pool_exist($pool);
        }
 
+       my $storage = extract_param($param, 'storage');
+
        my $storecfg = PVE::Storage::config();
 
        PVE::Cluster::check_cfs_quorum();
@@ -1857,7 +1864,7 @@ __PACKAGE__->register_method({
 
            die "Copy running VM $vmid not implemented\n" if $running;
 
-           &$check_storage_access_copy($rpcenv, $authuser, $storecfg, $conf);
+           &$check_storage_access_copy($rpcenv, $authuser, $storecfg, $conf, $storage);
 
            # fixme: snapshots??
 
@@ -1917,6 +1924,7 @@ __PACKAGE__->register_method({
                                $newvolid = PVE::Storage::vdisk_clone($storecfg,  $drive->{file}, $newid);
                            } 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;