]> git.proxmox.com Git - qemu-server.git/commitdiff
PVE::QemuServer::create_disks - run code inside eval
authorDietmar Maurer <dietmar@proxmox.com>
Sat, 6 May 2017 15:00:20 +0000 (17:00 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Sat, 6 May 2017 15:00:20 +0000 (17:00 +0200)
So that we can free allocated volumes ins something fails.

Thi bug was introduced with commit ae57f6b352242fed69da851f15f976095d290833

PVE/API2/Qemu.pm

index f5ffb9bdad6e662333b72628d1b7fe876bd6cb43..db1de34c57a5948df4d548a4157de7791f199482 100644 (file)
@@ -119,7 +119,8 @@ my $create_disks = sub {
     my $vollist = [];
 
     my $res = {};
-    PVE::QemuServer::foreach_drive($settings, sub {
+
+    my $code = sub {
        my ($ds, $disk) = @_;
 
        my $volid = $disk->{file};
@@ -190,7 +191,9 @@ my $create_disks = sub {
 
            $res->{$ds} = PVE::QemuServer::print_drive($vmid, $disk);
        }
-    });
+    };
+
+    eval { PVE::QemuServer::foreach_drive($settings, $code); };
 
     # free allocated images on error
     if (my $err = $@) {