]> git.proxmox.com Git - qemu-server.git/blobdiff - PVE/API2/Qemu.pm
use ReuseAddr for vncproxy
[qemu-server.git] / PVE / API2 / Qemu.pm
index f5ffb9bdad6e662333b72628d1b7fe876bd6cb43..c566c4d8d2a153c3371d1031ea89e3f6480dfad4 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};
@@ -127,7 +128,7 @@ my $create_disks = sub {
        if (!$volid || $volid eq 'none' || $volid eq 'cdrom') {
            delete $disk->{size};
            $res->{$ds} = PVE::QemuServer::print_drive($vmid, $disk);
-       } elsif ($volid =~ m/^(([^:\s]+):)?(\d+(\.\d+)?)$/) {
+       } elsif ($volid =~ m!^(([^/:\s]+):)?(\d+(\.\d+)?)$!) {
            my ($storeid, $size) = ($2 || $default_storage, $3);
            die "no storage ID specified (and no default storage)\n" if !$storeid;
            my $defformat = PVE::Storage::storage_default_format($storecfg, $storeid);
@@ -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 = $@) {
@@ -1052,7 +1055,7 @@ my $update_vm_api  = sub {
                    &$create_disks($rpcenv, $authuser, $conf->{pending}, $storecfg, $vmid, undef, {$opt => $param->{$opt}});
                } elsif ($opt eq "replicate") {
                    # check if all volumes have replicate feature
-                   PVE::QemuServer::get_replicatable_volumes($storecfg, $conf);
+                   PVE::QemuConfig->get_replicatable_volumes($storecfg, $conf);
                    my $repl = PVE::JSONSchema::check_format('pve-replicate', $param->{opt});
                    PVE::Cluster::check_node_exists($repl->{target});
                    $conf->{$opt} = $param->{$opt};
@@ -1430,6 +1433,7 @@ __PACKAGE__->register_method({
                $cmd = [@$remcmd, "/usr/sbin/qm", 'vncproxy', $vmid];
 
                my $sock = IO::Socket::IP->new(
+                   ReuseAddr => 1,
                    Listen => 1,
                    LocalPort => $port,
                    Proto => 'tcp',