[pve-devel] [PATCH/RFC v2 qemu-server 2/3] restore_vma_archive: get rid of oldtimeout handling

Fabian Ebner f.ebner at proxmox.com
Wed Aug 12 12:01:26 CEST 2020


Assume that the function is called within a worker not restricted by
any timeout. This is true currently, because the only path leading to
restore_vma_archive is via restore_file_archive being called within a
worker by the create_vm API call.

Avoid generic timeout error message.

Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---

New in v2

 PVE/QemuServer.pm | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 7169006..794819b 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -6162,7 +6162,6 @@ sub restore_vma_archive {
 
     $add_pipe->(['vma', 'extract', '-v', '-r', $mapfifo, $readfrom, $tmpdir]);
 
-    my $oldtimeout;
     my $timeout = 5;
 
     my $devinfo = {};
@@ -6261,9 +6260,9 @@ sub restore_vma_archive {
 	    local $SIG{QUIT} =
 	    local $SIG{HUP} =
 	    local $SIG{PIPE} = sub { die "interrupted by signal\n"; };
-	local $SIG{ALRM} = sub { die "got timeout\n"; };
+	local $SIG{ALRM} = sub { die "got timeout reading device map\n"; };
 
-	$oldtimeout = alarm($timeout);
+	alarm($timeout);
 
 	my $parser = sub {
 	    my $line = shift;
@@ -6274,11 +6273,7 @@ sub restore_vma_archive {
 		my ($dev_id, $size, $devname) = ($1, $2, $3);
 		$devinfo->{$devname} = { size => $size, dev_id => $dev_id };
 	    } elsif ($line =~ m/^CTIME: /) {
-		# we correctly received the vma config, so restore old timeout
-		my $tmp = $oldtimeout || 0;
-		$oldtimeout = undef;
-		alarm($tmp);
-
+		alarm(0);
 		&$print_devmap();
 		print $fifofh "done\n";
 		close($fifofh);
@@ -6290,7 +6285,7 @@ sub restore_vma_archive {
     };
     my $err = $@;
 
-    alarm($oldtimeout) if $oldtimeout;
+    alarm(0);
 
     $restore_deactivate_volumes->($cfg, $devinfo);
 
-- 
2.20.1





More information about the pve-devel mailing list