From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35078) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XQuLH-0003m2-NS for qemu-devel@nongnu.org; Mon, 08 Sep 2014 04:30:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XQuL8-0006Dg-H0 for qemu-devel@nongnu.org; Mon, 08 Sep 2014 04:30:31 -0400 Received: from mail-we0-x229.google.com ([2a00:1450:400c:c03::229]:36686) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XQuL8-0006Dc-B9 for qemu-devel@nongnu.org; Mon, 08 Sep 2014 04:30:22 -0400 Received: by mail-we0-f169.google.com with SMTP id w61so302423wes.14 for ; Mon, 08 Sep 2014 01:30:21 -0700 (PDT) Date: Mon, 8 Sep 2014 09:30:17 +0100 From: Stefan Hajnoczi Message-ID: <20140908083017.GA7638@stefanha-thinkpad.redhat.com> References: <1409835061-19989-1-git-send-email-david.marchand@6wind.com> <1409835061-19989-4-git-send-email-david.marchand@6wind.com> <20140905102908.GA27649@stefanha-thinkpad.redhat.com> <5409ABA1.3070900@6wind.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="vkogqOf2sHV7VnPd" Content-Disposition: inline In-Reply-To: <5409ABA1.3070900@6wind.com> Subject: Re: [Qemu-devel] [PATCH v5 3/3] ivshmem: add check on protocol version in QEMU List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Marchand Cc: kvm@vger.kernel.org, claudio.fontana@huawei.com, qemu-devel@nongnu.org, armbru@redhat.com, arei.gonglei@huawei.com, mkletzan@redhat.com, pbonzini@redhat.com, jani.kokkonen@huawei.com, cam@cs.ualberta.ca --vkogqOf2sHV7VnPd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Sep 05, 2014 at 02:25:05PM +0200, David Marchand wrote: > Hello Stefan, >=20 > On 09/05/2014 12:29 PM, Stefan Hajnoczi wrote: > >On Thu, Sep 04, 2014 at 02:51:01PM +0200, David Marchand wrote: > >>+ "server using a different protocol please check your s= etup\n"); > >>+ qemu_chr_delete(s->server_chr); > >>+ s->server_chr =3D NULL; > >>+ return; > >>+ } > >>+ > >>+ IVSHMEM_DPRINTF("version check ok, finish init and switch to real = chardev " > >>+ "handler\n"); > >>+ > >>+ pci_register_bar(dev, 2, s->ivshmem_attr, &s->bar); > > > >Not sure if it is okay to delay PCI initialization to a fd hander > >callback. > > > >If the version message is too slow the guest could see the PCI adapter > >without the BAR! > > > >Did you move this code in order to prevent the guest from accessing the > >device before it has connected to the server? Perhaps the device needs > >a state field that tracks whether or not it is ready for operation. Any > >access before RUNNING state is reached will be ignored (?). >=20 > Yes, exactly. >=20 > There already is a synchronisation mechanism described in the documentati= on: > "When using the server, since the server is a separate process, the VM ID > will only be set when the device is ready (shared memory is received from > the server and accessible via the device). If the device is not ready, t= he > IVPosition will return -1. > Applications should ensure that they have a valid VM ID before accessing = the > shared memory." >=20 > So actually, this move is unneeded if ivshmem users comply to this. >=20 > I will let the init stuff (pci_register_bar + gmalloc) where it was befor= e, > ivshmem_check_version will only switch the chardev handler. >=20 > What do you think about this ? Sounds good. --vkogqOf2sHV7VnPd Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUDWkZAAoJEJykq7OBq3PIaiIIALhEprL4l9IasTySccJqljZv 8J1FI9w0LwIceTfWjV0mt/zZU1Vy88MI2TnamfCbkKYCVPlN+k9Ax7TXzFdG70e0 MR0z4pQfGxZLKdtX81diIm1UKwRR6e5r4XH7EBp8qJvIO/H4KtVlbwVICGIG6XR9 oUhoNQ1ZPtQ9Vh0ynVnrX9qpoFpmeu6WZevswsr/ZqSMXJSGI5bX9q3jwS7jDOeu b6AkYFhA5ChrCHtOuUBiuUjGJzoem21coAmHJphgzLOurhtHFBcKR4CvdKHwJAD1 1A7NTsgDdCu90I9qcE7vCdThVMorV0SS8mBfSLouwjm1bDWiBItvscgF/vnG8S4= =fwy5 -----END PGP SIGNATURE----- --vkogqOf2sHV7VnPd--