Received: from eggs.gnu.org ([2001:4830:134:3::10]:36383) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ad06o-0002Bj-Dg for qemu-devel@nongnu.org; Mon, 07 Mar 2016 13:42:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ad06l-0002hK-6R for qemu-devel@nongnu.org; Mon, 07 Mar 2016 13:42:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40839) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ad06l-0002gJ-1A for qemu-devel@nongnu.org; Mon, 07 Mar 2016 13:42:19 -0500 From: Markus Armbruster References: <1456771254-17511-1-git-send-email-armbru@redhat.com> <1456771254-17511-39-git-send-email-armbru@redhat.com> Date: Mon, 07 Mar 2016 19:42:15 +0100 In-Reply-To: (=?utf-8?Q?=22Marc-Andr=C3=A9?= Lureau"'s message of "Thu, 3 Mar 2016 15:15:21 +0100") Message-ID: <87bn6qp1tk.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 38/38] contrib/ivshmem-server: Print "not for production" warning 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, Feb 29, 2016 at 7:40 PM, Markus Armbruster wr= ote: >> The code is okay for illustrating how things work and for testing, but >> its error handling make it unfit for production use. Print a warning >> to protect the innocent. >> >> Signed-off-by: Markus Armbruster >> --- > > I guess David would do something about the problems you report. Tbh, I That would be nice. > don't think ivshmem-server is so bad wrt error handling. ivshmem_server_send_one_msg() returns -1 on error with errno set. Okay. ivshmem_server_send_initial_info() fails in turn. ivshmem_server_handle_new_conn() handles this by closing the connection. Okay, except for EAGAIN and EINTR. All other callers ignore ivshmem_server_send_one_msg() failures. Not okay. Here's an example of how things could go haywire: * The server handles connections one after the other. It makes the file descriptors non-blocking. * When a client connects, ivshmem-server sends 3 + N*V messages to the new client, and V messages to each existing client, where N is the number of existing clients, and V is the number of vectors. Of these, only the 3 to the new client are checked for errors. The unchecked messages transmit eventfds for interrupts in groups of V messages. * With a sufficiently large N*V and a sluggish client, the server can conceivably hit EAGAIN. When it happens, the server drops messages silently. * InterVM interrupts corresponding to dropped eventfds will be silently dropped. * If out a group of V messages any non-trailing messages get dropped, the trailing ones get silently miswired to the wrong vector. Good luck debugging this in the field! A thorough review of error handling is called for. Since I can't do that now, I'm adding the warning. > Meanwhile: > Reviewed-by: Marc-Andr=C3=A9 Lureau Thanks!