]> git.proxmox.com Git - qemu-server.git/commitdiff
remove legacy sparsecp
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 14 Jun 2017 13:52:19 +0000 (15:52 +0200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 23 Aug 2017 08:03:37 +0000 (10:03 +0200)
sparsecp gets only used in qmextract, which is part of the old backup
method (pre PVE 2.3).
Do not remove qmextract for now people could still have backups from
< PVE 2.3 around.
They could be restored manually, but we shouldn't make restoring
complicated. Thus replace sparsecp with `cp sparse=always`.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Makefile
qmextract
sparsecp.c [deleted file]
utils.c [deleted file]

index a11b6577ed3a1e191afc6740b29809f0c6a9fed6..25eb34fffd5b6f56b6ea149249e3150d83bd3054 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -36,9 +36,6 @@ all:
 dinstall: deb
        dpkg -i ${DEB}
 
-sparsecp: sparsecp.c utils.c
-       gcc ${CFLAGS} -o sparsecp sparsecp.c
-
 qm.bash-completion:
        PVE_GENERATING_DOCS=1 perl -I. -T -e "use PVE::CLI::qm; PVE::CLI::qm->generate_bash_completions();" >$@.tmp
        mv $@.tmp $@
@@ -47,7 +44,7 @@ qmrestore.bash-completion:
        PVE_GENERATING_DOCS=1 perl -I. -T -e "use PVE::CLI::qmrestore; PVE::CLI::qmrestore->generate_bash_completions();" >$@.tmp
        mv $@.tmp $@
 
-PKGSOURCES=qm qm.1 qmrestore qmrestore.1 qmextract sparsecp qm.conf.5 qm.bash-completion qmrestore.bash-completion
+PKGSOURCES=qm qm.1 qmrestore qmrestore.1 qmextract qm.conf.5 qm.bash-completion qmrestore.bash-completion
 
 .PHONY: install
 install: ${PKGSOURCES}
@@ -69,7 +66,6 @@ install: ${PKGSOURCES}
        install -m 0755 pve-bridge ${DESTDIR}${VARLIBDIR}/pve-bridge
        install -m 0755 pve-bridge-hotplug ${DESTDIR}${VARLIBDIR}/pve-bridge-hotplug
        install -m 0755 pve-bridgedown ${DESTDIR}${VARLIBDIR}/pve-bridgedown
-       install -s -m 0755 sparsecp ${DESTDIR}${LIBDIR}
        install -D -m 0644 modules-load.conf ${DESTDIR}/etc/modules-load.d/qemu-server.conf
        install -m 0755 qmextract ${DESTDIR}${LIBDIR}
        install -m 0644 qm.1 ${DESTDIR}/${MAN1DIR}
index b660b9155c580bcecc9f3418ce8473d223d27ffb..1466a586d9163ec31c3f7976a07a6046f3f64f7e 100755 (executable)
--- a/qmextract
+++ b/qmextract
@@ -191,8 +191,8 @@ sub extract_archive {
        exec 'dd', 'ibs=256K', 'obs=256K', "of=$path";
        die "couldn't exec dd: $!\n";
     } else {
-       exec '/usr/lib/qemu-server/sparsecp', $path;
-       die "couldn't exec sparsecp: $!\n";
+       exec '/bin/cp', '--sparse=always', '/dev/stdin', $path;
+       die "couldn't exec cp: $!\n";
     }
 }
 
diff --git a/sparsecp.c b/sparsecp.c
deleted file mode 100644 (file)
index 950a27c..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
-    Copyright (C) 2007-2009 Proxmox Server Solutions GmbH
-
-    Copyright: vzdump is under GNU GPL, the GNU General Public License.
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; version 2 dated June, 1991.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the
-    Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
-    MA 02110-1301, USA.
-
-    Author: Dietmar Maurer <dietmar@proxmox.com>
-
-*/
-
-#define _GNU_SOURCE
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <time.h>
-#include <stdint.h>
-#include <getopt.h>
-#include <signal.h>
-
-#include "utils.c"
-
-#define BLOCKSIZE 512*8
-
-static char *outname;
-
-static void 
-cleanup (void)
-{
-  if (outname) 
-    unlink (outname);
-}
-
-void term_handler()
-{
-  fprintf (stderr, "received signal - terminate process\n");
-  exit(-1);
-}
-
-size_t
-sparse_cp (int infd, int outfd) 
-{
-  size_t total = 0;
-  size_t count;
-  char buffer[BLOCKSIZE];
-  int last_write_made_hole = 0;
-
-  while ((count = safe_read (infd, buffer, sizeof (buffer))) > 0) {
-    if (block_is_zero (buffer, count)) {
-
-      if (lseek (outfd, count, SEEK_CUR) < 0) {
-       perror ("cannot lseek\n");
-       exit (-1);
-      }
-      last_write_made_hole = 1;
-    } else {
-      full_write (outfd, buffer, count);
-      last_write_made_hole = 0;
-    }
-    total += count;
-  }
-
-  if (last_write_made_hole) {
-    if (ftruncate (outfd, total) < 0) {
-      perror ("cannot ftruncate\n");
-      exit (-1);
-    }
-  }
-
-  return total;
-}
-
-int
-main (int argc, char **argv)
-{
-  struct sigaction sa;
-
-  if (argc != 2) {
-    fprintf (stderr, "wrong number of arguments\n");
-    exit (-1);
-  }
-
-  time_t starttime = time(NULL);
-
-  outname = argv[1];
-
-  int outfd;
-
-  if ((outfd = open(outname, O_WRONLY|O_CREAT|O_TRUNC, 0644)) == -1) {
-    fprintf (stderr, "unable to open file '%s' - %s\n", 
-            outname, strerror (errno));
-    exit (-1);
-  }
-  atexit(cleanup);
-
-  setsig(&sa, SIGINT, term_handler, SA_RESTART);
-  setsig(&sa, SIGQUIT, term_handler, SA_RESTART);
-  setsig(&sa, SIGTERM, term_handler, SA_RESTART);
-  setsig(&sa, SIGPIPE, term_handler, SA_RESTART);
-
-  size_t total = sparse_cp (0, outfd);
-
-  close (outfd);
-
-  time_t delay = time(NULL) - starttime;
-  if (delay <= 0) delay = 1;
-
-  fprintf (stderr, "%zu bytes copied, %zd s, %.2f MiB/s\n", total, delay,
-          (total/(1024*1024))/(float)delay);
-
-  outname = NULL;
-
-  exit (0);
-}
diff --git a/utils.c b/utils.c
deleted file mode 100644 (file)
index c69e0ef..0000000
--- a/utils.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
-    Copyright (C) 2007-2009 Proxmox Server Solutions GmbH
-
-    Copyright: vzdump is under GNU GPL, the GNU General Public License.
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; version 2 dated June, 1991.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the
-    Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
-    MA 02110-1301, USA.
-
-    Author: Dietmar Maurer <dietmar@proxmox.com>
-
-*/
-
-#define _GNU_SOURCE
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-#include <string.h>
-#include <signal.h>
-
-/* Set a signal handler */
-static void 
-setsig (struct sigaction *sa, int sig, void (*fun)(int), int flags)
-{
-  sa->sa_handler = fun;
-  sa->sa_flags = flags;
-  sigemptyset(&sa->sa_mask);
-  sigaction(sig, sa, NULL);
-}
-
-int
-block_is_zero (char const *buffer, size_t size)
-{
-  while (size--)
-    if (*buffer++)
-      return 0;
-
-  return 1;
-}
-
-ssize_t 
-safe_read(int fd, char *buf, size_t count)
-{
-  ssize_t n;
-
-  do {
-    n = read(fd, buf, count);
-  } while (n < 0 && errno == EINTR);
-
-  return n;
-}
-
-int 
-full_read(int fd, char *buf, size_t len)
-{
-  ssize_t n;
-  size_t total;
-
-  total = 0;
-
-  while (len > 0) {
-    n = safe_read(fd, buf, len);
-
-    if (n == 0)
-           return total;
-
-    if (n < 0)
-           break;
-
-    buf += n;
-    total += n;
-    len -= n;
-  }
-
-  if (len) {
-         fprintf (stderr, "ERROR: incomplete read detected\n");
-         exit (-1);
-  }
-
-  return total;
-}
-
-ssize_t 
-safe_write(int fd, char *buf, size_t count)
-{
-  ssize_t n;
-
-  do {
-    n = write(fd, buf, count);
-  } while (n < 0 && errno == EINTR);
-
-  return n;
-}
-
-int 
-full_write(int fd, char *buf, size_t len)
-{
-  ssize_t n;
-  size_t total;
-
-  total = 0;
-
-  while (len > 0) {
-    n = safe_write(fd, buf, len);
-
-    if (n < 0)
-      break;
-
-    buf += n;
-    total += n;
-    len -= n;
-  }
-
-  if (len) {
-    fprintf (stderr, "ERROR: incomplete write detected\n");
-    exit (-1);
-  }
-
-  return total;
-}