[libvirt] [PATCH] Improve logging of shutdown inhibitor

Daniel P. Berrange posted 1 patch 6 years, 10 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20170623152239.17730-1-berrange@redhat.com
src/rpc/virnetdaemon.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
[libvirt] [PATCH] Improve logging of shutdown inhibitor
Posted by Daniel P. Berrange 6 years, 10 months ago
The log category for virnetdaemon.c was mistakenly set
to rpc.netserver. Some useful info about the inhibitor
file descriptor was also never logged.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 src/rpc/virnetdaemon.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c
index 782417e..905cecc 100644
--- a/src/rpc/virnetdaemon.c
+++ b/src/rpc/virnetdaemon.c
@@ -47,7 +47,7 @@
 
 #define VIR_FROM_THIS VIR_FROM_RPC
 
-VIR_LOG_INIT("rpc.netserver");
+VIR_LOG_INIT("rpc.netdaemon");
 
 typedef struct _virNetDaemonSignal virNetDaemonSignal;
 typedef virNetDaemonSignal *virNetDaemonSignalPtr;
@@ -460,9 +460,11 @@ virNetDaemonGotInhibitReply(DBusPendingCall *pending,
                               DBUS_TYPE_INVALID)) {
         if (dmn->autoShutdownInhibitions) {
             dmn->autoShutdownInhibitFd = fd;
+            VIR_DEBUG("Got inhibit FD %d", fd);
         } else {
             /* We stopped the last VM since we made the inhibit call */
             VIR_FORCE_CLOSE(fd);
+            VIR_DEBUG("Closing inhibit FD %d", fd);
         }
     }
     virDBusMessageUnref(reply);
@@ -550,8 +552,10 @@ virNetDaemonRemoveShutdownInhibition(virNetDaemonPtr dmn)
 
     VIR_DEBUG("dmn=%p inhibitions=%zu", dmn, dmn->autoShutdownInhibitions);
 
-    if (dmn->autoShutdownInhibitions == 0)
+    if (dmn->autoShutdownInhibitions == 0) {
+        VIR_DEBUG("Closing inhibit FD %d", dmn->autoShutdownInhibitFd);
         VIR_FORCE_CLOSE(dmn->autoShutdownInhibitFd);
+    }
 
     virObjectUnlock(dmn);
 }
-- 
2.9.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Improve logging of shutdown inhibitor
Posted by Michal Privoznik 6 years, 10 months ago
On 06/23/2017 05:22 PM, Daniel P. Berrange wrote:
> The log category for virnetdaemon.c was mistakenly set
> to rpc.netserver. Some useful info about the inhibitor
> file descriptor was also never logged.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  src/rpc/virnetdaemon.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/src/rpc/virnetdaemon.c b/src/rpc/virnetdaemon.c
> index 782417e..905cecc 100644
> --- a/src/rpc/virnetdaemon.c
> +++ b/src/rpc/virnetdaemon.c
> @@ -47,7 +47,7 @@
>  
>  #define VIR_FROM_THIS VIR_FROM_RPC
>  
> -VIR_LOG_INIT("rpc.netserver");
> +VIR_LOG_INIT("rpc.netdaemon");
>  
>  typedef struct _virNetDaemonSignal virNetDaemonSignal;
>  typedef virNetDaemonSignal *virNetDaemonSignalPtr;
> @@ -460,9 +460,11 @@ virNetDaemonGotInhibitReply(DBusPendingCall *pending,
>                                DBUS_TYPE_INVALID)) {
>          if (dmn->autoShutdownInhibitions) {
>              dmn->autoShutdownInhibitFd = fd;
> +            VIR_DEBUG("Got inhibit FD %d", fd);
>          } else {
>              /* We stopped the last VM since we made the inhibit call */
>              VIR_FORCE_CLOSE(fd);
> +            VIR_DEBUG("Closing inhibit FD %d", fd);

You want to call VIR_DEBUG() before VIR_FORCE_CLOSE as the latter resets
fd to -1.

>          }
>      }
>      virDBusMessageUnref(reply);
> @@ -550,8 +552,10 @@ virNetDaemonRemoveShutdownInhibition(virNetDaemonPtr dmn)
>  
>      VIR_DEBUG("dmn=%p inhibitions=%zu", dmn, dmn->autoShutdownInhibitions);
>  
> -    if (dmn->autoShutdownInhibitions == 0)
> +    if (dmn->autoShutdownInhibitions == 0) {
> +        VIR_DEBUG("Closing inhibit FD %d", dmn->autoShutdownInhibitFd);
>          VIR_FORCE_CLOSE(dmn->autoShutdownInhibitFd);
> +    }
>  
>      virObjectUnlock(dmn);
>  }
> 

ACK

Michal

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