[pve-devel] [PATCH_V2] Insert capability for restore LXC- and OpenVZ- dumpfiles

Wolfgang Bumiller w.bumiller at proxmox.com
Wed Jul 29 08:09:34 CEST 2015


> +    my $pid = open (TMP, "tar tf '$archive'|") ||
> +	die "unable to open file '$archive'\n";
> +    my $firstfile = <TMP>;
> +    kill 15, $pid;
> +    close TMP;

Newer perl code should use:
my $pid = open(my $handle, '-|', 'tar', 'tf', $archive) or die ...

After killing you should:
waitpid $pid, 0;

Then check $? for an error status to know if tar actually succeeded.
Then the checks you do later aren't really necessary anymore.
Specifically this one in recover_config():

> +	if ( $archive =~ m/.*(tar|tar.gz|tar.lzo)$/ ) {

At this point tar_archive_read_firstfile() would have already failed.
I also find it unnecessary as tar knows what it supports ;-)
(Also those dots need to be escaped, and a \. in front of the opening
paren.)

> +
> +	    PVE::Tools::run_command(['tar', '-xp', '-C', $tmpdir, '-f', $archive, './etc/vzdump/', '--occurrence']);
> +
> +	} else {
> +	    die "unknown archive format :$archive\n";
> +	}




More information about the pve-devel mailing list