mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-04-30 23:11:25 +00:00
only use sparse file scan for files
This commit is contained in:
parent
6e5c4da7ef
commit
a9a94d59f3
@ -382,8 +382,15 @@ sub archive {
|
|||||||
|
|
||||||
my $fh;
|
my $fh;
|
||||||
|
|
||||||
|
my $sparse = '';
|
||||||
|
|
||||||
|
# no sparse file scan for block devices
|
||||||
|
# no sparse file scan when we use compression
|
||||||
|
# but we enable it for files
|
||||||
|
|
||||||
my @filea = ($conffile, 'qemu-server.conf'); # always first file in tar
|
my @filea = ($conffile, 'qemu-server.conf'); # always first file in tar
|
||||||
foreach my $di (@{$task->{disks}}) {
|
foreach my $di (@{$task->{disks}}) {
|
||||||
|
$sparse = '-s' if !$comp && $di->{type} eq 'file';
|
||||||
if ($di->{type} eq 'block' || $di->{type} eq 'file') {
|
if ($di->{type} eq 'block' || $di->{type} eq 'file') {
|
||||||
push @filea, $di->{snappath}, $di->{filename};
|
push @filea, $di->{snappath}, $di->{filename};
|
||||||
} else {
|
} else {
|
||||||
@ -393,7 +400,7 @@ sub archive {
|
|||||||
|
|
||||||
my $files = join (' ', map { "'$_'" } @filea);
|
my $files = join (' ', map { "'$_'" } @filea);
|
||||||
|
|
||||||
my $cmd = "/usr/lib/qemu-server/vmtar $files";
|
my $cmd = "/usr/lib/qemu-server/vmtar $sparse $files";
|
||||||
my $bwl = $opts->{bwlimit}*1024; # bandwidth limit for cstream
|
my $bwl = $opts->{bwlimit}*1024; # bandwidth limit for cstream
|
||||||
$cmd .= "|cstream -t $bwl" if $opts->{bwlimit};
|
$cmd .= "|cstream -t $bwl" if $opts->{bwlimit};
|
||||||
$cmd .= "|$comp" if $comp;
|
$cmd .= "|$comp" if $comp;
|
||||||
|
22
vmtar.c
22
vmtar.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (C) 2007-2009 Proxmox Server Solutions GmbH
|
Copyright (C) 2007-2012 Proxmox Server Solutions GmbH
|
||||||
|
|
||||||
Copyright: vzdump is under GNU GPL, the GNU General Public License.
|
Copyright: vzdump is under GNU GPL, the GNU General Public License.
|
||||||
|
|
||||||
@ -429,19 +429,24 @@ int
|
|||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
|
int sparse = 0;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
|
{"sparse", 0, 0, 's'},
|
||||||
{"output", 1, 0, 'o'},
|
{"output", 1, 0, 'o'},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
char c = getopt_long (argc, argv, "o:", long_options, &option_index);
|
char c = getopt_long (argc, argv, "so:", long_options, &option_index);
|
||||||
if (c == -1)
|
if (c == -1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
case 's':
|
||||||
|
sparse = 1;
|
||||||
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
outname = optarg;
|
outname = optarg;
|
||||||
break;
|
break;
|
||||||
@ -525,9 +530,16 @@ main (int argc, char **argv)
|
|||||||
time_t ctime = fs.st_mtime;
|
time_t ctime = fs.st_mtime;
|
||||||
|
|
||||||
struct sp_array *ma = sparray_new();
|
struct sp_array *ma = sparray_new();
|
||||||
if (!scan_sparse_file (fd, ma)) {
|
if (sparse) {
|
||||||
fprintf (stderr, "scanning '%s' failed\n", source);
|
if (!scan_sparse_file (fd, ma)) {
|
||||||
exit (-1);
|
fprintf (stderr, "scanning '%s' failed\n", source);
|
||||||
|
exit (-1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
off_t file_size = fs.st_size;
|
||||||
|
sparray_add (ma, 0, file_size);
|
||||||
|
ma->real_size = file_size;
|
||||||
|
ma->effective_size = file_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
dump_header (wbuf, archivename, ctime, ma);
|
dump_header (wbuf, archivename, ctime, ma);
|
||||||
|
Loading…
Reference in New Issue
Block a user