[libvirt] [PATCH] lxc: report error message raised by the failing function

Prafull posted 1 patch 6 years ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/1521729275-31177-1-git-send-email-talep158@gmail.com
Test syntax-check passed
src/lxc/lxc_driver.c | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
[libvirt] [PATCH] lxc: report error message raised by the failing function
Posted by Prafull 6 years ago
The code that calls VIR_WARN after a function fails, doesn't
report the error message raised by the failing function.
Such error messages are now reported in lxc/lxc_driver.c

Signed-off-by: Prafullkumar T <talep158@gmail.com>
---
 src/lxc/lxc_driver.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 4f6b93b..4f600f3 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -3915,8 +3915,8 @@ lxcDomainAttachDeviceDiskLive(virLXCDriverPtr driver,
                                 major(sb.st_rdev),
                                 minor(sb.st_rdev),
                                 perms) < 0)
-            VIR_WARN("cannot deny device %s for domain %s",
-                     src, vm->def->name);
+            VIR_WARN("cannot deny device %s for domain %s: %s",
+                     src, vm->def->name, virGetLastErrorMessage());
         goto cleanup;
     }
 
@@ -4011,8 +4011,8 @@ lxcDomainAttachDeviceNetLive(virConnectPtr conn,
                 goto cleanup;
         } else {
             VIR_WARN("setting bandwidth on interfaces of "
-                     "type '%s' is not implemented yet",
-                     virDomainNetTypeToString(actualType));
+                     "type '%s' is not implemented yet: %s",
+                     virDomainNetTypeToString(actualType), virGetLastErrorMessage());
         }
     }
 
@@ -4116,8 +4116,8 @@ lxcDomainAttachDeviceHostdevSubsysUSBLive(virLXCDriverPtr driver,
         if (virUSBDeviceFileIterate(usb,
                                     virLXCTeardownHostUSBDeviceCgroup,
                                     priv->cgroup) < 0)
-            VIR_WARN("cannot deny device %s for domain %s",
-                     src, vm->def->name);
+            VIR_WARN("cannot deny device %s for domain %s: %s",
+                     src, vm->def->name, virGetLastErrorMessage());
         goto cleanup;
     }
 
@@ -4190,8 +4190,8 @@ lxcDomainAttachDeviceHostdevStorageLive(virLXCDriverPtr driver,
                                 major(sb.st_rdev),
                                 minor(sb.st_rdev),
                                 VIR_CGROUP_DEVICE_RWM) < 0)
-            VIR_WARN("cannot deny device %s for domain %s",
-                     def->source.caps.u.storage.block, vm->def->name);
+            VIR_WARN("cannot deny device %s for domain %s: %s",
+                     def->source.caps.u.storage.block, vm->def->name, virGetLastErrorMessage());
         goto cleanup;
     }
 
@@ -4262,8 +4262,8 @@ lxcDomainAttachDeviceHostdevMiscLive(virLXCDriverPtr driver,
                                 major(sb.st_rdev),
                                 minor(sb.st_rdev),
                                 VIR_CGROUP_DEVICE_RWM) < 0)
-            VIR_WARN("cannot deny device %s for domain %s",
-                     def->source.caps.u.storage.block, vm->def->name);
+            VIR_WARN("cannot deny device %s for domain %s: %s",
+                     def->source.caps.u.storage.block, vm->def->name, virGetLastErrorMessage());
         goto cleanup;
     }
 
@@ -4434,8 +4434,8 @@ lxcDomainDetachDeviceDiskLive(virDomainObjPtr vm,
 
     if (virCgroupDenyDevicePath(priv->cgroup, src,
                                 VIR_CGROUP_DEVICE_RWM, false) != 0)
-        VIR_WARN("cannot deny device %s for domain %s",
-                 src, vm->def->name);
+        VIR_WARN("cannot deny device %s for domain %s: %s",
+                 src, vm->def->name, virGetLastErrorMessage());
 
     virDomainDiskRemove(vm->def, idx);
     virDomainDiskDefFree(def);
@@ -4567,8 +4567,8 @@ lxcDomainDetachDeviceHostdevUSBLive(virLXCDriverPtr driver,
     if (virUSBDeviceFileIterate(usb,
                                 virLXCTeardownHostUSBDeviceCgroup,
                                 priv->cgroup) < 0)
-        VIR_WARN("cannot deny device %s for domain %s",
-                 dst, vm->def->name);
+        VIR_WARN("cannot deny device %s for domain %s: %s",
+                 dst, vm->def->name, virGetLastErrorMessage());
 
     virObjectLock(hostdev_mgr->activeUSBHostdevs);
     virUSBDeviceListDel(hostdev_mgr->activeUSBHostdevs, usb);
@@ -4623,8 +4623,8 @@ lxcDomainDetachDeviceHostdevStorageLive(virDomainObjPtr vm,
 
     if (virCgroupDenyDevicePath(priv->cgroup, def->source.caps.u.storage.block,
                                 VIR_CGROUP_DEVICE_RWM, false) != 0)
-        VIR_WARN("cannot deny device %s for domain %s",
-                 def->source.caps.u.storage.block, vm->def->name);
+        VIR_WARN("cannot deny device %s for domain %s: %s",
+                 def->source.caps.u.storage.block, vm->def->name, virGetLastErrorMessage());
 
     virDomainHostdevRemove(vm->def, idx);
     virDomainHostdevDefFree(def);
@@ -4673,8 +4673,8 @@ lxcDomainDetachDeviceHostdevMiscLive(virDomainObjPtr vm,
 
     if (virCgroupDenyDevicePath(priv->cgroup, def->source.caps.u.misc.chardev,
                                 VIR_CGROUP_DEVICE_RWM, false) != 0)
-        VIR_WARN("cannot deny device %s for domain %s",
-                 def->source.caps.u.misc.chardev, vm->def->name);
+        VIR_WARN("cannot deny device %s for domain %s: %s",
+                 def->source.caps.u.misc.chardev, vm->def->name, virGetLastErrorMessage());
 
     virDomainHostdevRemove(vm->def, idx);
     virDomainHostdevDefFree(def);
-- 
2.1.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] lxc: report error message raised by the failing function
Posted by Cedric Bosdonnat 6 years ago
Hello Prafull,

On Thu, 2018-03-22 at 20:04 +0530, Prafull wrote:
> The code that calls VIR_WARN after a function fails, doesn't
> report the error message raised by the failing function.
> Such error messages are now reported in lxc/lxc_driver.c
> 
> Signed-off-by: Prafullkumar T <talep158@gmail.com>

Sorry for asking a potentially dumb question, but I know nothing of the
Indian culture. Is 'Prafullkumar T' your firstname and lastname? Just make
sure your first and last names are used for signing off and committing.

For this, set the user.name in your git repo (or globally). You can also
change the author of an existing commit with:

    git commit --amend --author 'fullname <email>'

Other than that, your commit looks fine to me. Note that you haven't used
your full name as commit author. I'll wait for a v2 with updated names to push.

Regards,
--
Cedric

> ---
>  src/lxc/lxc_driver.c | 36 ++++++++++++++++++------------------
>  1 file changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
> index 4f6b93b..4f600f3 100644
> --- a/src/lxc/lxc_driver.c
> +++ b/src/lxc/lxc_driver.c
> @@ -3915,8 +3915,8 @@ lxcDomainAttachDeviceDiskLive(virLXCDriverPtr driver,
>                                  major(sb.st_rdev),
>                                  minor(sb.st_rdev),
>                                  perms) < 0)
> -            VIR_WARN("cannot deny device %s for domain %s",
> -                     src, vm->def->name);
> +            VIR_WARN("cannot deny device %s for domain %s: %s",
> +                     src, vm->def->name, virGetLastErrorMessage());
>          goto cleanup;
>      }
>  
> @@ -4011,8 +4011,8 @@ lxcDomainAttachDeviceNetLive(virConnectPtr conn,
>                  goto cleanup;
>          } else {
>              VIR_WARN("setting bandwidth on interfaces of "
> -                     "type '%s' is not implemented yet",
> -                     virDomainNetTypeToString(actualType));
> +                     "type '%s' is not implemented yet: %s",
> +                     virDomainNetTypeToString(actualType), virGetLastErrorMessage());
>          }
>      }
>  
> @@ -4116,8 +4116,8 @@ lxcDomainAttachDeviceHostdevSubsysUSBLive(virLXCDriverPtr driver,
>          if (virUSBDeviceFileIterate(usb,
>                                      virLXCTeardownHostUSBDeviceCgroup,
>                                      priv->cgroup) < 0)
> -            VIR_WARN("cannot deny device %s for domain %s",
> -                     src, vm->def->name);
> +            VIR_WARN("cannot deny device %s for domain %s: %s",
> +                     src, vm->def->name, virGetLastErrorMessage());
>          goto cleanup;
>      }
>  
> @@ -4190,8 +4190,8 @@ lxcDomainAttachDeviceHostdevStorageLive(virLXCDriverPtr driver,
>                                  major(sb.st_rdev),
>                                  minor(sb.st_rdev),
>                                  VIR_CGROUP_DEVICE_RWM) < 0)
> -            VIR_WARN("cannot deny device %s for domain %s",
> -                     def->source.caps.u.storage.block, vm->def->name);
> +            VIR_WARN("cannot deny device %s for domain %s: %s",
> +                     def->source.caps.u.storage.block, vm->def->name, virGetLastErrorMessage());
>          goto cleanup;
>      }
>  
> @@ -4262,8 +4262,8 @@ lxcDomainAttachDeviceHostdevMiscLive(virLXCDriverPtr driver,
>                                  major(sb.st_rdev),
>                                  minor(sb.st_rdev),
>                                  VIR_CGROUP_DEVICE_RWM) < 0)
> -            VIR_WARN("cannot deny device %s for domain %s",
> -                     def->source.caps.u.storage.block, vm->def->name);
> +            VIR_WARN("cannot deny device %s for domain %s: %s",
> +                     def->source.caps.u.storage.block, vm->def->name, virGetLastErrorMessage());
>          goto cleanup;
>      }
>  
> @@ -4434,8 +4434,8 @@ lxcDomainDetachDeviceDiskLive(virDomainObjPtr vm,
>  
>      if (virCgroupDenyDevicePath(priv->cgroup, src,
>                                  VIR_CGROUP_DEVICE_RWM, false) != 0)
> -        VIR_WARN("cannot deny device %s for domain %s",
> -                 src, vm->def->name);
> +        VIR_WARN("cannot deny device %s for domain %s: %s",
> +                 src, vm->def->name, virGetLastErrorMessage());
>  
>      virDomainDiskRemove(vm->def, idx);
>      virDomainDiskDefFree(def);
> @@ -4567,8 +4567,8 @@ lxcDomainDetachDeviceHostdevUSBLive(virLXCDriverPtr driver,
>      if (virUSBDeviceFileIterate(usb,
>                                  virLXCTeardownHostUSBDeviceCgroup,
>                                  priv->cgroup) < 0)
> -        VIR_WARN("cannot deny device %s for domain %s",
> -                 dst, vm->def->name);
> +        VIR_WARN("cannot deny device %s for domain %s: %s",
> +                 dst, vm->def->name, virGetLastErrorMessage());
>  
>      virObjectLock(hostdev_mgr->activeUSBHostdevs);
>      virUSBDeviceListDel(hostdev_mgr->activeUSBHostdevs, usb);
> @@ -4623,8 +4623,8 @@ lxcDomainDetachDeviceHostdevStorageLive(virDomainObjPtr vm,
>  
>      if (virCgroupDenyDevicePath(priv->cgroup, def->source.caps.u.storage.block,
>                                  VIR_CGROUP_DEVICE_RWM, false) != 0)
> -        VIR_WARN("cannot deny device %s for domain %s",
> -                 def->source.caps.u.storage.block, vm->def->name);
> +        VIR_WARN("cannot deny device %s for domain %s: %s",
> +                 def->source.caps.u.storage.block, vm->def->name, virGetLastErrorMessage());
>  
>      virDomainHostdevRemove(vm->def, idx);
>      virDomainHostdevDefFree(def);
> @@ -4673,8 +4673,8 @@ lxcDomainDetachDeviceHostdevMiscLive(virDomainObjPtr vm,
>  
>      if (virCgroupDenyDevicePath(priv->cgroup, def->source.caps.u.misc.chardev,
>                                  VIR_CGROUP_DEVICE_RWM, false) != 0)
> -        VIR_WARN("cannot deny device %s for domain %s",
> -                 def->source.caps.u.misc.chardev, vm->def->name);
> +        VIR_WARN("cannot deny device %s for domain %s: %s",
> +                 def->source.caps.u.misc.chardev, vm->def->name, virGetLastErrorMessage());
>  
>      virDomainHostdevRemove(vm->def, idx);
>      virDomainHostdevDefFree(def);

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] lxc: report error message raised by the failing function
Posted by Daniel P. Berrangé 6 years ago
On Fri, Mar 23, 2018 at 01:30:22PM +0100, Cedric Bosdonnat wrote:
> Hello Prafull,
> 
> On Thu, 2018-03-22 at 20:04 +0530, Prafull wrote:
> > The code that calls VIR_WARN after a function fails, doesn't
> > report the error message raised by the failing function.
> > Such error messages are now reported in lxc/lxc_driver.c
> > 
> > Signed-off-by: Prafullkumar T <talep158@gmail.com>
> 
> Sorry for asking a potentially dumb question, but I know nothing of the
> Indian culture. Is 'Prafullkumar T' your firstname and lastname? Just make
> sure your first and last names are used for signing off and committing.
> 
> For this, set the user.name in your git repo (or globally). You can also
> change the author of an existing commit with:
> 
>     git commit --amend --author 'fullname <email>'
> 
> Other than that, your commit looks fine to me. Note that you haven't used
> your full name as commit author. I'll wait for a v2 with updated names to push.

We already dealt with that on IRC - i'll push with the full name
shortly.


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list