Received: from eggs.gnu.org ([2001:4830:134:3::10]:37453) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adkUw-0008ME-SQ for qemu-devel@nongnu.org; Wed, 09 Mar 2016 15:14:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1adkUt-0006zJ-VS for qemu-devel@nongnu.org; Wed, 09 Mar 2016 15:14:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36572) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adkUt-0006z9-OJ for qemu-devel@nongnu.org; Wed, 09 Mar 2016 15:14:19 -0500 From: Markus Armbruster References: <1457378754-21649-1-git-send-email-armbru@redhat.com> <1457378754-21649-6-git-send-email-armbru@redhat.com> Date: Wed, 09 Mar 2016 21:14:16 +0100 In-Reply-To: (=?utf-8?Q?=22Marc-Andr=C3=A9?= Lureau"'s message of "Wed, 9 Mar 2016 13:44:54 +0100") Message-ID: <87h9gf2yuf.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 05/42] ivshmem-server: Don't overload POSIX shmem and file name List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Cc: Paolo Bonzini , cam , Claudio Fontana , QEMU , David Marchand Marc-Andr=C3=A9 Lureau writes: > Hi > > On Mon, Mar 7, 2016 at 8:25 PM, Markus Armbruster wro= te: >> Option -m NAME is interpreted as directory name if we can statfs() it >> and its on hugetlbfs. Else it's interpreted as POSIX shared memory >> object name. This is nuts. >> >> Always interpret -m as directory. Create new -M for POSIX shared >> memory. Last of -m or -M wins. >> >> Signed-off-by: Markus Armbruster >> --- > > I don't see why the last should win is a good idea, see attached patch Last one wins is pretty common behavior. In fact, it's what this program does for every single option with an argument. I didn't feel like making -m and -M special. > for a possible solution, also changing a few comments. Feel free to > squash it in this patch or include it in your series. I got a few comments inline. > Reviewed-by: Marc-Andr=C3=A9 Lureau Thanks! [...] > From e8112678496fd873ceaa34b3169e516130075ed4 Mon Sep 17 00:00:00 2001 > From: =3D?UTF-8?q?Marc-Andr=3DC3=3DA9=3D20Lureau?=3D > Date: Tue, 8 Mar 2016 20:31:09 +0100 > Subject: [PATCH] ivshmem-server: expect either -m or -M > MIME-Version: 1.0 > Content-Type: text/plain; charset=3DUTF-8 > Content-Transfer-Encoding: 8bit > > Signed-off-by: Marc-Andr=C3=A9 Lureau > --- > contrib/ivshmem-server/main.c | 21 ++++++++++++--------- > 1 file changed, 12 insertions(+), 9 deletions(-) > > diff --git a/contrib/ivshmem-server/main.c b/contrib/ivshmem-server/main.c > index 2795db5..368fc67 100644 > --- a/contrib/ivshmem-server/main.c > +++ b/contrib/ivshmem-server/main.c > @@ -77,7 +77,7 @@ ivshmem_server_parse_args(IvshmemServerArgs *args, int = argc, char *argv[]) > "F" /* foreground */ > "p:" /* pid_file */ > "S:" /* unix_socket_path */ > - "m:" /* shm_path */ > + "m:" /* dirname */ The existing comments all name the member of args set by the option. There is no member dirname. > "M:" /* shm_path */ > "l:" /* shm_size */ > "n:" /* n_vectors */ > @@ -106,13 +106,15 @@ ivshmem_server_parse_args(IvshmemServerArgs *args, = int argc, char *argv[]) > break; >=20=20 > case 'M': /* shm_path */ > - args->shm_path =3D optarg; > - args->use_shm_open =3D true; > - break; > + case 'm': /* dirname */ > + if (args->shm_path) { > + fprintf(stderr, "Please specify either -m or -M.\n"); > + ivshmem_server_help(argv[0]); > + exit(1); > + } >=20=20 > - case 'm': /* shm_path */ > args->shm_path =3D optarg; > - args->use_shm_open =3D false; > + args->use_shm_open =3D c =3D=3D 'M'; I think I'll steal this idea :) > break; >=20=20 > case 'l': /* shm_size */ > @@ -207,7 +209,7 @@ main(int argc, char *argv[]) > .foreground =3D IVSHMEM_SERVER_DEFAULT_FOREGROUND, > .pid_file =3D IVSHMEM_SERVER_DEFAULT_PID_FILE, > .unix_socket_path =3D IVSHMEM_SERVER_DEFAULT_UNIX_SOCK_PATH, > - .shm_path =3D IVSHMEM_SERVER_DEFAULT_SHM_PATH, > + .shm_path =3D NULL, > .use_shm_open =3D true, > .shm_size =3D IVSHMEM_SERVER_DEFAULT_SHM_SIZE, > .n_vectors =3D IVSHMEM_SERVER_DEFAULT_N_VECTORS, > @@ -237,8 +239,9 @@ main(int argc, char *argv[]) >=20=20 > /* init the ivshms structure */ > if (ivshmem_server_init(&server, args.unix_socket_path, > - args.shm_path, args.use_shm_open, > - args.shm_size, args.n_vectors, args.verbose)= < 0) { > + args.shm_path ?: IVSHMEM_SERVER_DEFAULT_SHM_= PATH, > + args.use_shm_open, args.shm_size, args.n_vec= tors, > + args.verbose) < 0) { > fprintf(stderr, "cannot init server\n"); > goto err; > }