From 490bf29d508fbba197dad2c4570345a227f61411 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A1n=20Tomko?= Date: Thu, 17 Jul 2014 12:18:56 +0200 Subject: [PATCH] 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. --- src/storage/storage_backend.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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 } -- 2.39.5