]> git.proxmox.com Git - qemu-server.git/blobdiff - PVE/QemuServer.pm
cleanup: drop superfluous condition in assignment
[qemu-server.git] / PVE / QemuServer.pm
index 0b866cdda406a48ebdbe46a7de5bced74ebdd662..bc26da2d08fd5e7cac3d7d708eecfdc71b020b66 100644 (file)
@@ -999,6 +999,13 @@ EODESCR
        optional => 1,
        default => 1,
     },
+    romfile => {
+        type => 'string',
+        pattern => '[^,;]+',
+        format_description => 'string',
+        description => "Custom pci device rom filename (must be located in /usr/share/kvm/).",
+        optional => 1,
+    },
     pcie => {
        type => 'boolean',
         description =>  "Choose the PCI-express bus (needs the 'q35' machine model).",
@@ -2908,6 +2915,8 @@ sub config_to_command {
        }
 
        my $rombar = defined($d->{rombar}) && !$d->{rombar} ? ',rombar=0' : '';
+       my $romfile = $d->{romfile};
+
        my $xvga = '';
        if ($d->{'x-vga'}) {
            $xvga = ',x-vga=on';
@@ -2934,6 +2943,7 @@ sub config_to_command {
            if($j == 0){
                $devicestr .= "$rombar$xvga";
                $devicestr .= ",multifunction=on" if $multifunction;
+               $devicestr .= ",romfile=/usr/share/kvm/$romfile" if $romfile;
            }
 
            push @$devices, '-device', $devicestr;
@@ -5919,24 +5929,23 @@ sub qemu_drive_mirror {
        $format = "nbd";
        my $unixsocket = "/run/qemu-server/$vmid.mirror-drive-$drive";
        $qemu_target = "nbd+unix:///$exportname?socket=$unixsocket";
-       my $cmd = ['socat', "UNIX-LISTEN:$unixsocket,fork", "TCP:$server:$2,connect-timeout=1"];
+       my $cmd = ['socat', '-T30', "UNIX-LISTEN:$unixsocket,fork", "TCP:$server:$2,connect-timeout=5"];
 
        my $pid = fork();
        if (!defined($pid)) {
-           die "forking socat tunnel failed";
+           die "forking socat tunnel failed\n";
        } elsif ($pid == 0) {
            exec(@$cmd);
-           exit(-1);
-       } else {
-           $jobs->{"drive-$drive"}->{pid} = $pid;
+           warn "exec failed: $!\n";
+           POSIX::_exit(-1);
+       }
+       $jobs->{"drive-$drive"}->{pid} = $pid;
 
-           my $timeout = 0;
-           while (1) {
-               last if -S $unixsocket; 
-               die if $timeout > 5;
-               $timeout++;
-               sleep 1;
-           }
+       my $timeout = 0;
+       while (!-S $unixsocket) {
+           die "nbd connection helper timed out\n"
+               if $timeout++ > 5;
+           sleep 1;
        }
     } else {
        my $storecfg = PVE::Storage::config();
@@ -5993,7 +6002,7 @@ sub qemu_drive_mirror_monitor {
                    next;
                }
 
-               die "$job: mirroring has been cancelled. Maybe do you have bad sectors?" if !defined($running_mirror_jobs->{$job});
+               die "$job: mirroring has been cancelled\n" if !defined($running_mirror_jobs->{$job});
 
                my $busy = $running_mirror_jobs->{$job}->{busy};
                my $ready = $running_mirror_jobs->{$job}->{ready};
@@ -6039,14 +6048,14 @@ sub qemu_drive_mirror_monitor {
 
                    foreach my $job (keys %$jobs) {
                        # try to switch the disk if source and destination are on the same guest
-                       print "$job : Try to complete block job\n";
+                       print "$job: Completing block job...\n";
 
                        eval { vm_mon_cmd($vmid, "block-job-complete", device => $job) };
                        if ($@ =~ m/cannot be completed/) {
-                           print "$job : block job cannot be complete. Try again \n";
+                           print "$job: Block job cannot be completed, try again.\n";
                            $err_complete++;
                        }else {
-                           print "$job : complete ok : flushing pending writes\n";
+                           print "$job: Completed successfully.\n";
                            $jobs->{$job}->{complete} = 1;
                            eval { qemu_blockjobs_finish_tunnel($vmid, $job, $jobs->{$job}->{pid}) } ;
                        }
@@ -6069,7 +6078,7 @@ sub qemu_blockjobs_cancel {
     my ($vmid, $jobs) = @_;
 
     foreach my $job (keys %$jobs) {
-       print "$job: try to cancel block job\n";
+       print "$job: Cancelling block job\n";
        eval { vm_mon_cmd($vmid, "block-job-cancel", device => $job); };
        $jobs->{$job}->{cancel} = 1;
     }
@@ -6084,8 +6093,8 @@ sub qemu_blockjobs_cancel {
 
        foreach my $job (keys %$jobs) {
 
-           if(defined($jobs->{$job}->{cancel}) && !defined($running_jobs->{$job})) {
-               print "$job : finished\n";
+           if (defined($jobs->{$job}->{cancel}) && !defined($running_jobs->{$job})) {
+               print "$job: Done.\n";
                eval { qemu_blockjobs_finish_tunnel($vmid, $job, $jobs->{$job}->{pid}) } ;
                delete $jobs->{$job};
            }