]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Don't use virFileReadLimFD in qemuDomainRestore.
authorChris Lalancette <clalance@redhat.com>
Tue, 23 Mar 2010 13:11:29 +0000 (09:11 -0400)
committerChris Lalancette <clalance@redhat.com>
Fri, 2 Apr 2010 13:23:41 +0000 (09:23 -0400)
virFileReadLimFD is a poor fit for reading the header
of the restore file.  The problem is that virFileReadLimFD
returns an error when there is more data after the amount
you ask to read, but that is *expected* in this case.

This patch is essentially a revert of
1a4d5c9543641c444dccd682f6256ee3faf22a80, but I don't think
that commit does what it says anyway.  It purports to prevent
an unwarranted OOM error, but since virFileReadLimFD will
allocate memory up to the maximum anyway, the upper limit
on the total amount of memory allocated is the same for either
the old version or the new version.  Since the old saferead
actually works and virFileReadLimFD does not, revert to
using saferead.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
src/qemu/qemu_driver.c

index 4291bc70a4b48543e7f0a226be7bd1f9d3b65510..70d2781ef7957cc83f0b6c432b979aab72c96130 100644 (file)
@@ -5547,7 +5547,12 @@ static int qemudDomainRestore(virConnectPtr conn,
         goto cleanup;
     }
 
-    if (virFileReadLimFD(fd, header.xml_len, &xml) != header.xml_len) {
+    if (VIR_ALLOC_N(xml, header.xml_len) < 0) {
+        virReportOOMError();
+        goto cleanup;
+    }
+
+    if (saferead(fd, xml, header.xml_len) != header.xml_len) {
         qemuReportError(VIR_ERR_OPERATION_FAILED,
                         "%s", _("failed to read XML"));
         goto cleanup;