]> git.proxmox.com Git - qemu-server.git/blobdiff - PVE/QemuServer.pm
set template flag earlier
[qemu-server.git] / PVE / QemuServer.pm
index 7c20f555a58ad85d2bfa9500b9d173fb8d33339a..194b678d12f1edfa5ceb5f64a319c3b6b57889d7 100644 (file)
@@ -3628,7 +3628,13 @@ sub rescan {
            
        check_lock($conf);
 
-       my $changes = update_disksize($vmid, $conf, $volid_hash);
+       my $vm_volids = {};
+       foreach my $volid (keys %$volid_hash) {
+           my $info = $volid_hash->{$volid};
+           $vm_volids->{$volid} = $info if $info->{vmid} && $info->{vmid} == $vmid;
+       }
+
+       my $changes = update_disksize($vmid, $conf, $vm_volids);
 
        update_config_nolock($vmid, $conf, 1) if $changes;
     };
@@ -4439,7 +4445,6 @@ sub template_create {
     die "you can't convert a vm to template if vm is running vm\n" if $running;
 
     my $storecfg = PVE::Storage::config();
-    my $i = 0;
 
     foreach_drive($conf, sub {
        my ($ds, $drive) = @_;
@@ -4448,29 +4453,13 @@ sub template_create {
        return if $disk && $ds ne $disk;
 
        my $volid = $drive->{file};
-       die "volume '$volid' does not support template/clone\n" 
-           if !PVE::Storage::volume_has_feature($storecfg, 'template', $volid);
-    });
+       return if !PVE::Storage::volume_has_feature($storecfg, 'template', $volid);
 
-    foreach_drive($conf, sub {
-       my ($ds, $drive) = @_;
-
-       return if drive_is_cdrom($drive);
-       return if $disk && $ds ne $disk;
-
-       my $volid = $drive->{file};
        my $voliddst = PVE::Storage::vdisk_create_base($storecfg, $volid);
        $drive->{file} = $voliddst;
        $conf->{$ds} = PVE::QemuServer::print_drive($vmid, $drive);
        PVE::QemuServer::update_config_nolock($vmid, $conf, 1);
-
     });
-    if($conf->{snapshots}){
-       delete $conf->{parent};
-       delete $conf->{snapshots};
-       PVE::QemuServer::update_config_nolock($vmid, $conf, 1);
-       #fixme : do we need to delete disks snapshots ?
-    }
 }
 
 sub is_template {