[pve-devel] r4909 - qemu-server/trunk

svn-commits at proxmox.com svn-commits at proxmox.com
Mon Jul 19 09:02:19 CEST 2010


Author: dietmar
Date: 2010-07-19 07:02:19 +0000 (Mon, 19 Jul 2010)
New Revision: 4909

Modified:
   qemu-server/trunk/ChangeLog
   qemu-server/trunk/Makefile
   qemu-server/trunk/QemuServer.pm
   qemu-server/trunk/changelog.Debian
Log:
* carefully catch write errors



Modified: qemu-server/trunk/ChangeLog
===================================================================
--- qemu-server/trunk/ChangeLog	2010-07-16 15:47:53 UTC (rev 4908)
+++ qemu-server/trunk/ChangeLog	2010-07-19 07:02:19 UTC (rev 4909)
@@ -1,3 +1,8 @@
+2010-07-19  Proxmox Support Team  <support at proxmox.com>
+
+	* QemuServer.pm (change_config_nolock): carefully catch write
+	errors - avoid zero length config files when filesystem is full.
+
 2010-06-29  Proxmox Support Team  <support at proxmox.com>
 
 	* QemuServer.pm (parse_drive): add rerror/werror options (patch

Modified: qemu-server/trunk/Makefile
===================================================================
--- qemu-server/trunk/Makefile	2010-07-16 15:47:53 UTC (rev 4908)
+++ qemu-server/trunk/Makefile	2010-07-19 07:02:19 UTC (rev 4909)
@@ -2,7 +2,7 @@
 
 VERSION=1.1
 PACKAGE=qemu-server
-PKGREL=16
+PKGREL=17
 
 DESTDIR=
 PREFIX=/usr

Modified: qemu-server/trunk/QemuServer.pm
===================================================================
--- qemu-server/trunk/QemuServer.pm	2010-07-16 15:47:53 UTC (rev 4908)
+++ qemu-server/trunk/QemuServer.pm	2010-07-19 07:02:19 UTC (rev 4909)
@@ -1023,9 +1023,10 @@
     my $fh = new IO::File ($filename, "r") ||
 	die "unable to read config for VM $vmid\n";
 
-    my $out = new IO::File ($tmpfn, "w") ||
-	die "unable to write config for VM $vmid\n";
+    my $werror = "unable to write config for VM $vmid\n";
 
+    my $out = new IO::File ($tmpfn, "w") || die $werror;
+
     eval {
 
 	my $done;
@@ -1033,7 +1034,7 @@
 	while (my $line = <$fh>) {
 	
 	    if (($line =~ m/^\#/) || ($line =~ m/^\s*$/)) {
-		print $out $line;
+		die $werror unless print $out $line;
 		next;
 	    }
 
@@ -1050,7 +1051,9 @@
 		    $value = $res->{$key};
 		    delete $res->{$key};
 		}
-		print $out "$key: $value\n" if !defined ($unset->{$key});
+		if (!defined ($unset->{$key})) {
+		    die $werror unless print $out "$key: $value\n";
+		} 
 		$done->{$key} = 1;
 		next;
 	    }
@@ -1060,21 +1063,29 @@
 
 	foreach my $key (keys %$res) {
 
-	    print $out "$key: $res->{$key}\n" if !defined ($unset->{$key});	    
+	    if (!defined ($unset->{$key})) {
+		die $werror unless print $out "$key: $res->{$key}\n";
+	    }
 	}
     };
 
     my $err = $@;
 
-    $out->close();
     $fh->close();
 
     if ($err) {
+	$out->close();
 	unlink $tmpfn;
 	die $err;
-    } else {
-	rename $tmpfn, $filename;
     }
+
+    if (!$out->close()) {
+	$err = "close failed - $!\n";
+	unlink $tmpfn;
+	die $err;	
+    }
+
+    rename $tmpfn, $filename || die "rename failed - $!\n";
 }
 
 sub load_defaults { 

Modified: qemu-server/trunk/changelog.Debian
===================================================================
--- qemu-server/trunk/changelog.Debian	2010-07-16 15:47:53 UTC (rev 4908)
+++ qemu-server/trunk/changelog.Debian	2010-07-19 07:02:19 UTC (rev 4909)
@@ -1,3 +1,9 @@
+qemu-server (1.1-17) unstable; urgency=low
+
+  * carefully catch write errors
+
+ -- Proxmox Support Team <support at proxmox.com>  Mon, 19 Jul 2010 09:00:48 +0200
+
 qemu-server (1.1-16) unstable; urgency=low
 
   * add rerror/werror options (patch from l.mierzwa)



More information about the pve-devel mailing list