[PATCH 1/6] qemuDomainCreateDeviceRecursive: Report error if mkdir() fails

Michal Privoznik posted 6 patches 9 weeks ago

[PATCH 1/6] qemuDomainCreateDeviceRecursive: Report error if mkdir() fails

Posted by Michal Privoznik 9 weeks ago
The virFileMakePathWithMode() which is our recursive version of
mkdir() fails, it simply just returns a negative value with errno
set. No error is reported (as compared to virFileTouch() for
instance).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/qemu/qemu_domain.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 0e2252f6cf..48bf5ae559 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -14643,8 +14643,12 @@ qemuDomainCreateDeviceRecursive(const char *device,
          * proper owner and mode. Bind mount only after that. */
     } else if (isDir) {
         if (create &&
-            virFileMakePathWithMode(devicePath, sb.st_mode) < 0)
+            virFileMakePathWithMode(devicePath, sb.st_mode) < 0) {
+            virReportSystemError(errno,
+                                 _("Unable to make dir %s"),
+                                 devicePath);
             goto cleanup;
+        }
     } else {
         virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
                        _("unsupported device type %s 0%o"),
-- 
2.24.1

Re: [PATCH 1/6] qemuDomainCreateDeviceRecursive: Report error if mkdir() fails

Posted by Pavel Mores 9 weeks ago
On Wed, Mar 18, 2020 at 06:32:11PM +0100, Michal Privoznik wrote:
> The virFileMakePathWithMode() which is our recursive version of
> mkdir() fails, it simply just returns a negative value with errno
> set. No error is reported (as compared to virFileTouch() for
> instance).
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/qemu/qemu_domain.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index 0e2252f6cf..48bf5ae559 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -14643,8 +14643,12 @@ qemuDomainCreateDeviceRecursive(const char *device,
>           * proper owner and mode. Bind mount only after that. */
>      } else if (isDir) {
>          if (create &&
> -            virFileMakePathWithMode(devicePath, sb.st_mode) < 0)
> +            virFileMakePathWithMode(devicePath, sb.st_mode) < 0) {
> +            virReportSystemError(errno,
> +                                 _("Unable to make dir %s"),
> +                                 devicePath);
>              goto cleanup;
> +        }
>      } else {
>          virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
>                         _("unsupported device type %s 0%o"),
> -- 
> 2.24.1
> 

Reviewed-by: Pavel Mores <pmores@redhat.com>