]> xenbits.xensource.com Git - libvirt.git/commitdiff
Log an error when we fail to set the COW attribute
authorJán Tomko <jtomko@redhat.com>
Thu, 17 Jul 2014 10:18:56 +0000 (12:18 +0200)
committerJán Tomko <jtomko@redhat.com>
Thu, 17 Jul 2014 12:32:29 +0000 (14:32 +0200)
Coverity complains about the return value of ioctl not being checked.

Even though we carry on when this fails (just like qemu-img does),
we can log an error.

src/storage/storage_backend.c

index 5e7aa3ca813dae5c00abd98656323219882c52ed..27b02cb410f8e9cc24a286478319273c07ee8041 100644 (file)
@@ -462,11 +462,16 @@ virStorageBackendCreateRaw(virConnectPtr conn ATTRIBUTE_UNUSED,
 
         /* Set NOCOW flag. This is an optimisation for btrfs.
          * The FS_IOC_SETFLAGS ioctl return value will be ignored since any
-         * failure of this operation should not block the left work.
+         * failure of this operation should not block the volume creation.
          */
-        if (ioctl(fd, FS_IOC_GETFLAGS, &attr) == 0) {
+        if (ioctl(fd, FS_IOC_GETFLAGS, &attr) < 0) {
+            virReportSystemError(errno, "%s", _("Failed to get fs flags"));
+        } else {
             attr |= FS_NOCOW_FL;
-            ioctl(fd, FS_IOC_SETFLAGS, &attr);
+            if (ioctl(fd, FS_IOC_SETFLAGS, &attr) < 0) {
+                virReportSystemError(errno, "%s",
+                                     _("Failed to set NOCOW flag"));
+            }
         }
 #endif
     }