qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2] linux-user: make binfmt flag O require P


From: Joakim Tjernlund
Subject: Re: [Qemu-devel] [PATCH v2] linux-user: make binfmt flag O require P
Date: Tue, 15 Jul 2014 00:14:11 +0200

Joakim Tjernlund/Transmode wrote on 2014/07/14 23:37:02:

> From: Joakim Tjernlund/Transmode
> To: 
> Cc: Andreas Färber <address@hidden>, Alexander Graf <address@hidden>, 
address@hidden, Riku Voipio <address@hidden>
> Date: 2014/07/14 23:37
> Subject: Re: [Qemu-devel] [PATCH v2] linux-user: make binfmt flag O 
require P
> 
> Joakim Tjernlund/Transmode wrote on 2014/07/14 23:04:51:
> > > Why do we need to modify argv[] here when we are building a
> > > target_argv[] further down anyway?

> > Because parse_opts() will not do it for me and I cannot figure out how 
to modify
> > parse_opts() whithout breaking it.
> 
> I took another look and now I came up with:
> 
> From 886985747369947e3b28d7a5fb807abd4beae10c Mon Sep 17 00:00:00 2001
> From: Joakim Tjernlund <address@hidden>
> Date: Mon, 14 Jul 2014 20:17:28 +0200
> Subject: [PATCH] linux-user: make binfmt flag O require P
> 
> QEMU can autodetect if it is started from Linux binfmt loader
> when binfmt flag O is on.
> Use that and require binfmt flag P as well which will enable QEMU
> to pass in correct argv0 to the application.
> 
> Signed-off-by: Joakim Tjernlund <address@hidden>
> ---
>  linux-user/main.c           | 16 +++++++++++++---
>  scripts/qemu-binfmt-conf.sh | 36 ++++++++++++++++++------------------
>  2 files changed, 31 insertions(+), 21 deletions(-)
> 
> diff --git a/linux-user/main.c b/linux-user/main.c
> index 71a33c7..845d4e3 100644
> --- a/linux-user/main.c
> +++ b/linux-user/main.c
> @@ -3750,7 +3750,7 @@ static void usage(void)
>      exit(1);
>  }
> 
> -static int parse_args(int argc, char **argv)
> +static int parse_args(int argc, char **argv, int assume_P_flag)
>  {
>      const char *r;
>      int optind;
> @@ -3768,6 +3768,16 @@ static int parse_args(int argc, char **argv)
>      }
> 
>      optind = 1;
> +    if (assume_P_flag) {
> +        /* Assume binfmt P flag is set */
> +        if (argc < 3) {
> +            fprintf(stderr, "%s: Please use me through binfmt with P 
flag\n",
> +                    argv[0]);
> +            exit(1);
> +        }
> +        argv0 = strdup(argv[2]);
> +        optind++;
> +    }

Well, that broke as soon as logged into my LXC. This works though:
 if (assume_P_flag) {
        /* Assume binfmt P flag is set */
        if (argc < 3) {
            fprintf(stderr, "%s: Please use me through binfmt with P 
flag\n",
                    argv[0]);
            exit(1);
        }
        filename = argv[optind];
        exec_path = argv[optind];
        optind++;
        argv0 = strdup(argv[2]);
        return optind;
    }
Are you happy with that?

 Jocke



reply via email to

[Prev in Thread] Current Thread [Next in Thread]