[pve-devel] r5332 - vzdump/trunk

svn-commits at proxmox.com svn-commits at proxmox.com
Mon Dec 6 07:27:03 CET 2010


Author: dietmar
Date: 2010-12-06 07:27:03 +0100 (Mon, 06 Dec 2010)
New Revision: 5332

Modified:
   vzdump/trunk/ChangeLog
   vzdump/trunk/VZDump.pm
   vzdump/trunk/vzdump
Log:


Modified: vzdump/trunk/ChangeLog
===================================================================
--- vzdump/trunk/ChangeLog	2010-12-06 06:02:02 UTC (rev 5331)
+++ vzdump/trunk/ChangeLog	2010-12-06 06:27:03 UTC (rev 5332)
@@ -1,6 +1,7 @@
 2010-12-06  Proxmox Support Team  <support at proxmox.com>
 
 	* VZDump.pm (debugmsg): never print to STDOUT (use STDERR instead)
+	(run_command): allow to pass GLOB/IO:File references for $input
 
 	* vzdump (print_usage): add new --stdout option (make sure that
 	nobody writes STDOUT by redirectind STDOUT to STDERR (saving old

Modified: vzdump/trunk/VZDump.pm
===================================================================
--- vzdump/trunk/VZDump.pm	2010-12-06 06:02:02 UTC (rev 5331)
+++ vzdump/trunk/VZDump.pm	2010-12-06 06:27:03 UTC (rev 5332)
@@ -84,8 +84,10 @@
 sub run_command {
     my ($logfd, $cmdstr, $input, $timeout) = @_;
 
+    $input = '' if !defined($input);
+
     my $reader = IO::File->new();
-    my $writer = IO::File->new();
+    my $writer = ref($input) ? $input : IO::File->new();
     my $error  = IO::File->new();
 
     my $orig_pid = $$;
@@ -109,8 +111,10 @@
 
     die $err if $err;
 
-    print $writer $input if defined $input;
-    close $writer;
+    if (!ref($input)) {
+	print $writer $input if defined $input;
+	close $writer;
+    }
 
     my $select = new IO::Select;
     $select->add ($reader);

Modified: vzdump/trunk/vzdump
===================================================================
--- vzdump/trunk/vzdump	2010-12-06 06:02:02 UTC (rev 5331)
+++ vzdump/trunk/vzdump	2010-12-06 06:27:03 UTC (rev 5332)
@@ -131,7 +131,7 @@
 }
 
 open STDOUT, '>/dev/null' if $opts->{quiet} && !$opts->{stdout};
-open STDERR, '>/dev/null' if ($opts->{quiet};
+open STDERR, '>/dev/null' if $opts->{quiet};
 
 if ($opts->{stdout}) {
 
@@ -142,6 +142,9 @@
 	die "unable to redirect STDOUT: $!\n";
 
     $opts->{stdout} = $saved_stdout;
+
+    die "you can only backup a single VM with option --stdout\n"
+	if scalar(@ARGV) != 1;
 }
 
 $opts->{vmids} = PVE::VZDump::check_vmids (@ARGV) if !$opts->{all};



More information about the pve-devel mailing list