import/export: new formats: raw, tar, qcow2, vmdk

All of them have a `+size` prefix to show that they're not
"pure raw" or "pure tar" streams, because some storage may
need to know in advance how much storage to allocate.
The formats are explained in comments.

PVE::Storage::Plugin now has default implementations for
these for non-incremental streams exporting the current
(rather than a snapshot state).
To use qcow2 or vmdk formats $with_snapshots must be true,
otherwise raw/tar will be used where $with_snapshots must
be false.
This commit is contained in:
Wolfgang Bumiller
2017-06-21 14:59:36 +02:00
committed by Dietmar Maurer
parent ae36189d26
commit 9559a62a3d
2 changed files with 148 additions and 7 deletions

View File

@ -3,6 +3,7 @@ package PVE::CLI::pvesm;
use strict;
use warnings;
use POSIX qw(O_RDONLY O_WRONLY O_CREAT O_TRUNC);
use Fcntl ':flock';
use File::Path;
@ -21,7 +22,7 @@ use PVE::CLIHandler;
use base qw(PVE::CLIHandler);
my $KNOWN_EXPORT_FORMATS = ['zfs'];
my $KNOWN_EXPORT_FORMATS = ['raw+size', 'tar+size', 'qcow2+size', 'vmdk+size', 'zfs'];
my $nodename = PVE::INotify::nodename();
@ -202,7 +203,7 @@ __PACKAGE__->register_method ({
if ($filename eq '-') {
$outfh = \*STDOUT;
} else {
open($outfh, '>', $filename)
sysopen($outfh, $filename, O_CREAT|O_WRONLY|O_TRUNC)
or die "open($filename): $!\n";
}
@ -277,7 +278,7 @@ __PACKAGE__->register_method ({
if ($filename eq '-') {
$infh = \*STDIN;
} else {
open($infh, '<', $filename)
sysopen($infh, $filename, O_RDONLY)
or die "open($filename): $!\n";
}