From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57093) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X6mdt-0004jy-QU for qemu-devel@nongnu.org; Mon, 14 Jul 2014 16:14:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X6mdo-0006vn-8U for qemu-devel@nongnu.org; Mon, 14 Jul 2014 16:14:33 -0400 Received: from cantor2.suse.de ([195.135.220.15]:48624 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X6mdo-0006vY-2v for qemu-devel@nongnu.org; Mon, 14 Jul 2014 16:14:28 -0400 Message-ID: <53C43A21.1090907@suse.de> Date: Mon, 14 Jul 2014 22:14:25 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1405363942-6865-1-git-send-email-Joakim.Tjernlund@transmode.se> In-Reply-To: <1405363942-6865-1-git-send-email-Joakim.Tjernlund@transmode.se> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2] linux-user: make binfmt flag O require P List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Joakim Tjernlund , qemu-devel@nongnu.org, Alexander Graf Cc: Riku Voipio Am 14.07.2014 20:52, schrieb Joakim Tjernlund: > Qemu can autodetect if it is started from Linux binfmt loader "QEMU" > 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. >=20 > Signed-off-by: Joakim Tjernlund > --- > linux-user/main.c | 13 ++++++++++++- > scripts/qemu-binfmt-conf.sh | 36 ++++++++++++++++++------------------ > 2 files changed, 30 insertions(+), 19 deletions(-) >=20 > diff --git a/linux-user/main.c b/linux-user/main.c > index 71a33c7..9736768 100644 > --- a/linux-user/main.c > +++ b/linux-user/main.c > @@ -3829,6 +3829,18 @@ int main(int argc, char **argv, char **envp) > int ret; > int execfd; > =20 > + execfd =3D qemu_getauxval(AT_EXECFD); > + if (execfd > 0 ) { Still one superfluous trailing space. > + if (argc < 3) { > + fprintf(stderr, "%s: Please use me through binfmt with P f= lag\n", > + argv[0]); > + exit(1); > + } > + handle_arg_argv0(argv[2]); /* binfmt wrapper */ We might as well inline this for clarity, to distinguish from -0 / QEMU_ARGV0 handling: argv0 =3D strdup(argv[2]); Also, what is the "binfmt wrapper" comment supposed to say here? Either extend it, move it or drop it. > + memmove(&argv[2], &argv[3], (argc-2)*sizeof(argv)); Still missing spaces around * and - operators. Why do we need to modify argv[] here when we are building a target_argv[] further down anyway? > + argc--; > + } > + > module_call_init(MODULE_INIT_QOM); > =20 > if ((envlist =3D envlist_create()) =3D=3D NULL) { > @@ -4003,7 +4015,6 @@ int main(int argc, char **argv, char **envp) > cpu->opaque =3D ts; > task_settid(ts); > =20 > - execfd =3D qemu_getauxval(AT_EXECFD); > if (execfd =3D=3D 0) { > execfd =3D open(filename, O_RDONLY); > if (execfd < 0) { [snip] Regards, Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg