From: Stefan Hajnoczi Subject: Re: [PATCH v5 3/3] ivshmem: add check on protocol version in QEMU Date: Mon, 8 Sep 2014 09:30:17 +0100 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" Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, pbonzini@redhat.com, claudio.fontana@huawei.com, jani.kokkonen@huawei.com, eblake@redhat.com, cam@cs.ualberta.ca, armbru@redhat.com, arei.gonglei@huawei.com, mkletzan@redhat.com To: David Marchand Return-path: Received: from mail-we0-f174.google.com ([74.125.82.174]:49251 "EHLO mail-we0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753236AbaIHIaW (ORCPT ); Mon, 8 Sep 2014 04:30:22 -0400 Received: by mail-we0-f174.google.com with SMTP id t60so723529wes.19 for ; Mon, 08 Sep 2014 01:30:21 -0700 (PDT) Content-Disposition: inline In-Reply-To: <5409ABA1.3070900@6wind.com> Sender: kvm-owner@vger.kernel.org List-ID: --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--