From: Ján Tomko Date: Thu, 17 Jul 2014 10:18:56 +0000 (+0200) Subject: Log an error when we fail to set the COW attribute X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=490bf29d508fbba197dad2c4570345a227f61411;p=libvirt.git Log an error when we fail to set the COW attribute 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. --- diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index 5e7aa3ca81..27b02cb410 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -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 }