cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-virtiofsd-convert-more-fprintf-and-perror-to-use-fus.patch

ddf19c
From e00543b0384fba61a9c7274c73e11a25e7ab2946 Mon Sep 17 00:00:00 2001
ddf19c
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
ddf19c
Date: Mon, 27 Jan 2020 19:02:13 +0100
ddf19c
Subject: [PATCH 102/116] virtiofsd: convert more fprintf and perror to use
ddf19c
 fuse log infra
ddf19c
MIME-Version: 1.0
ddf19c
Content-Type: text/plain; charset=UTF-8
ddf19c
Content-Transfer-Encoding: 8bit
ddf19c
ddf19c
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
ddf19c
Message-id: <20200127190227.40942-99-dgilbert@redhat.com>
ddf19c
Patchwork-id: 93552
ddf19c
O-Subject: [RHEL-AV-8.2 qemu-kvm PATCH 098/112] virtiofsd: convert more fprintf and perror to use fuse log infra
ddf19c
Bugzilla: 1694164
ddf19c
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
ddf19c
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
ddf19c
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
ddf19c
ddf19c
From: Eryu Guan <eguan@linux.alibaba.com>
ddf19c
ddf19c
Signed-off-by: Eryu Guan <eguan@linux.alibaba.com>
ddf19c
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
ddf19c
Reviewed-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
ddf19c
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
ddf19c
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
ddf19c
(cherry picked from commit fc1aed0bf96259d0b46b1cfea7497b7762c4ee3d)
ddf19c
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
ddf19c
---
ddf19c
 tools/virtiofsd/fuse_signals.c | 7 +++++--
ddf19c
 tools/virtiofsd/helper.c       | 9 ++++++---
ddf19c
 2 files changed, 11 insertions(+), 5 deletions(-)
ddf19c
ddf19c
diff --git a/tools/virtiofsd/fuse_signals.c b/tools/virtiofsd/fuse_signals.c
ddf19c
index dc7c8ac..f18625b 100644
ddf19c
--- a/tools/virtiofsd/fuse_signals.c
ddf19c
+++ b/tools/virtiofsd/fuse_signals.c
ddf19c
@@ -12,6 +12,7 @@
ddf19c
 #include "fuse_i.h"
ddf19c
 #include "fuse_lowlevel.h"
ddf19c
 
ddf19c
+#include <errno.h>
ddf19c
 #include <signal.h>
ddf19c
 #include <stdio.h>
ddf19c
 #include <stdlib.h>
ddf19c
@@ -47,13 +48,15 @@ static int set_one_signal_handler(int sig, void (*handler)(int), int remove)
ddf19c
     sa.sa_flags = 0;
ddf19c
 
ddf19c
     if (sigaction(sig, NULL, &old_sa) == -1) {
ddf19c
-        perror("fuse: cannot get old signal handler");
ddf19c
+        fuse_log(FUSE_LOG_ERR, "fuse: cannot get old signal handler: %s\n",
ddf19c
+                 strerror(errno));
ddf19c
         return -1;
ddf19c
     }
ddf19c
 
ddf19c
     if (old_sa.sa_handler == (remove ? handler : SIG_DFL) &&
ddf19c
         sigaction(sig, &sa, NULL) == -1) {
ddf19c
-        perror("fuse: cannot set signal handler");
ddf19c
+        fuse_log(FUSE_LOG_ERR, "fuse: cannot set signal handler: %s\n",
ddf19c
+                 strerror(errno));
ddf19c
         return -1;
ddf19c
     }
ddf19c
     return 0;
ddf19c
diff --git a/tools/virtiofsd/helper.c b/tools/virtiofsd/helper.c
ddf19c
index 33749bf..f98d8f2 100644
ddf19c
--- a/tools/virtiofsd/helper.c
ddf19c
+++ b/tools/virtiofsd/helper.c
ddf19c
@@ -208,7 +208,8 @@ int fuse_daemonize(int foreground)
ddf19c
         char completed;
ddf19c
 
ddf19c
         if (pipe(waiter)) {
ddf19c
-            perror("fuse_daemonize: pipe");
ddf19c
+            fuse_log(FUSE_LOG_ERR, "fuse_daemonize: pipe: %s\n",
ddf19c
+                     strerror(errno));
ddf19c
             return -1;
ddf19c
         }
ddf19c
 
ddf19c
@@ -218,7 +219,8 @@ int fuse_daemonize(int foreground)
ddf19c
          */
ddf19c
         switch (fork()) {
ddf19c
         case -1:
ddf19c
-            perror("fuse_daemonize: fork");
ddf19c
+            fuse_log(FUSE_LOG_ERR, "fuse_daemonize: fork: %s\n",
ddf19c
+                     strerror(errno));
ddf19c
             return -1;
ddf19c
         case 0:
ddf19c
             break;
ddf19c
@@ -228,7 +230,8 @@ int fuse_daemonize(int foreground)
ddf19c
         }
ddf19c
 
ddf19c
         if (setsid() == -1) {
ddf19c
-            perror("fuse_daemonize: setsid");
ddf19c
+            fuse_log(FUSE_LOG_ERR, "fuse_daemonize: setsid: %s\n",
ddf19c
+                     strerror(errno));
ddf19c
             return -1;
ddf19c
         }
ddf19c
 
ddf19c
-- 
ddf19c
1.8.3.1
ddf19c