[pve-devel] r4841 - qemu-server/trunk

svn-commits at proxmox.com svn-commits at proxmox.com
Fri Jun 25 12:21:00 CEST 2010


Author: dietmar
Date: 2010-06-25 10:21:00 +0000 (Fri, 25 Jun 2010)
New Revision: 4841

Modified:
   qemu-server/trunk/ChangeLog
   qemu-server/trunk/utils.c
   qemu-server/trunk/vmtar.c
Log:


Modified: qemu-server/trunk/ChangeLog
===================================================================
--- qemu-server/trunk/ChangeLog	2010-06-24 12:51:56 UTC (rev 4840)
+++ qemu-server/trunk/ChangeLog	2010-06-25 10:21:00 UTC (rev 4841)
@@ -1,3 +1,11 @@
+2010-06-25  Proxmox Support Team  <support at proxmox.com>
+
+	* utils.c (full_read): always try to read full blocks (fix vmtar
+	bug - endless growing archive)
+
+	* vmtar.c (scan_sparse_file): use full_read()
+	(dump_sparse_file): use full_read()
+
 2010-04-28  Proxmox Support Team  <support at proxmox.com>
 
 	* QemuServer.pm (config_to_command): correct order of config option (use sort).

Modified: qemu-server/trunk/utils.c
===================================================================
--- qemu-server/trunk/utils.c	2010-06-24 12:51:56 UTC (rev 4840)
+++ qemu-server/trunk/utils.c	2010-06-25 10:21:00 UTC (rev 4841)
@@ -65,6 +65,36 @@
   return n;
 }
 
+int 
+full_read(int fd, char *buf, size_t len)
+{
+  size_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)
 {

Modified: qemu-server/trunk/vmtar.c
===================================================================
--- qemu-server/trunk/vmtar.c	2010-06-24 12:51:56 UTC (rev 4840)
+++ qemu-server/trunk/vmtar.c	2010-06-25 10:21:00 UTC (rev 4841)
@@ -359,7 +359,7 @@
   if (lseek (fd, 0, SEEK_SET) < 0)
     return 0;
 
-  while ((count = safe_read (fd, buffer, sizeof (buffer))) > 0) {
+  while ((count = full_read (fd, buffer, sizeof (buffer))) > 0) {
     if (block_is_zero (buffer, count)) {
       if (sp_bytes) {
 	sparray_add (ma, sp_offset, sp_bytes);
@@ -405,7 +405,7 @@
       size_t bytes_read;
 
       char *blkbuf = buffer_block (wbuf);
-      if ((bytes_read = safe_read (fd, blkbuf, bufsize)) < 0) {
+      if ((bytes_read = full_read (fd, blkbuf, bufsize)) < 0) {
 	return 0;
       }
 



More information about the pve-devel mailing list