[Qemu-devel] [PATCH 1/5] pr-helper: fix --socket-path default in help

Paolo Bonzini posted 5 patches 7 years, 4 months ago
There is a newer version of this series
[Qemu-devel] [PATCH 1/5] pr-helper: fix --socket-path default in help
Posted by Paolo Bonzini 7 years, 4 months ago
Currently --help shows "(default '(null)')" for the -k/--socket-path
option.  Fix it by getting the default path in /var/run.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scsi/qemu-pr-helper.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c
index d0f83176e1..4057cf355c 100644
--- a/scsi/qemu-pr-helper.c
+++ b/scsi/qemu-pr-helper.c
@@ -74,8 +74,16 @@ static int uid = -1;
 static int gid = -1;
 #endif
 
+static void compute_default_paths(void)
+{
+    if (!socket_path) {
+        socket_path = qemu_get_local_state_pathname("run/qemu-pr-helper.sock");
+    }
+}
+
 static void usage(const char *name)
 {
+    compute_default_paths();
     (printf) (
 "Usage: %s [OPTIONS] FILE\n"
 "Persistent Reservation helper program for QEMU\n"
@@ -845,13 +853,6 @@ static const char *socket_activation_validate_opts(void)
     return NULL;
 }
 
-static void compute_default_paths(void)
-{
-    if (!socket_path) {
-        socket_path = qemu_get_local_state_pathname("run/qemu-pr-helper.sock");
-    }
-}
-
 static void termsig_handler(int signum)
 {
     atomic_cmpxchg(&state, RUNNING, TERMINATE);
-- 
2.17.1



Re: [Qemu-devel] [PATCH 1/5] pr-helper: fix --socket-path default in help
Posted by Philippe Mathieu-Daudé 7 years, 4 months ago
On 06/26/2018 12:40 PM, Paolo Bonzini wrote:
> Currently --help shows "(default '(null)')" for the -k/--socket-path
> option.  Fix it by getting the default path in /var/run.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>  scsi/qemu-pr-helper.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c
> index d0f83176e1..4057cf355c 100644
> --- a/scsi/qemu-pr-helper.c
> +++ b/scsi/qemu-pr-helper.c
> @@ -74,8 +74,16 @@ static int uid = -1;
>  static int gid = -1;
>  #endif
>  
> +static void compute_default_paths(void)
> +{
> +    if (!socket_path) {
> +        socket_path = qemu_get_local_state_pathname("run/qemu-pr-helper.sock");
> +    }
> +}
> +
>  static void usage(const char *name)
>  {
> +    compute_default_paths();
>      (printf) (
>  "Usage: %s [OPTIONS] FILE\n"
>  "Persistent Reservation helper program for QEMU\n"
> @@ -845,13 +853,6 @@ static const char *socket_activation_validate_opts(void)
>      return NULL;
>  }
>  
> -static void compute_default_paths(void)
> -{
> -    if (!socket_path) {
> -        socket_path = qemu_get_local_state_pathname("run/qemu-pr-helper.sock");
> -    }
> -}
> -
>  static void termsig_handler(int signum)
>  {
>      atomic_cmpxchg(&state, RUNNING, TERMINATE);
> 

Re: [Qemu-devel] [PATCH 1/5] pr-helper: fix --socket-path default in help
Posted by Michal Privoznik 7 years, 4 months ago
On 06/26/2018 05:40 PM, Paolo Bonzini wrote:
> Currently --help shows "(default '(null)')" for the -k/--socket-path
> option.  Fix it by getting the default path in /var/run.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  scsi/qemu-pr-helper.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c
> index d0f83176e1..4057cf355c 100644
> --- a/scsi/qemu-pr-helper.c
> +++ b/scsi/qemu-pr-helper.c
> @@ -74,8 +74,16 @@ static int uid = -1;
>  static int gid = -1;
>  #endif
>  
> +static void compute_default_paths(void)
> +{
> +    if (!socket_path) {
> +        socket_path = qemu_get_local_state_pathname("run/qemu-pr-helper.sock");
> +    }
> +}
> +

Pre-existing, but pidfile path is computed elsewhere. I'll post a patch
that cleans things up. Not a show stopper for this one though.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

Michal