]> xenbits.xensource.com Git - libvirt.git/commitdiff
virFileSetXAttr: Report error on failure
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 22 Mar 2019 14:34:59 +0000 (15:34 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 3 Jul 2019 06:36:03 +0000 (08:36 +0200)
It's better to have the function report errors, because none of
the callers does.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
src/util/virfile.c

index 00f69dce69bfa5b1ce9a37f3a69814b23a2cd68a..75ec9e0bd8056f8985b346279717fde191f94d8c 100644 (file)
@@ -4421,14 +4421,21 @@ virFileGetXAttrQuiet(const char *path,
  * Sets xattr of @name and @value on @path.
  *
  * Returns: 0 on success,
- *         -1 otherwise (with errno set).
+ *         -1 otherwise (with errno set AND error reported).
  */
 int
 virFileSetXAttr(const char *path,
                 const char *name,
                 const char *value)
 {
-    return setxattr(path, name, value, strlen(value), 0);
+    if (setxattr(path, name, value, strlen(value), 0) < 0) {
+        virReportSystemError(errno,
+                             _("Unable to set XATTR %s on %s"),
+                             name, path);
+        return -1;
+    }
+
+    return 0;
 }
 
 /**
@@ -4460,11 +4467,14 @@ virFileGetXAttrQuiet(const char *path ATTRIBUTE_UNUSED,
 }
 
 int
-virFileSetXAttr(const char *path ATTRIBUTE_UNUSED,
-                const char *name ATTRIBUTE_UNUSED,
+virFileSetXAttr(const char *path,
+                const char *name,
                 const char *value ATTRIBUTE_UNUSED)
 {
     errno = ENOSYS;
+    virReportSystemError(errno,
+                         _("Unable to set XATTR %s on %s"),
+                         name, path);
     return -1;
 }