Received: from eggs.gnu.org ([2001:4830:134:3::10]:33979) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brS8V-0005H6-SG for qemu-devel@nongnu.org; Tue, 04 Oct 2016 12:00:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brS8Q-0000hA-BU for qemu-devel@nongnu.org; Tue, 04 Oct 2016 12:00:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45804) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brS8Q-0000gD-2E for qemu-devel@nongnu.org; Tue, 04 Oct 2016 12:00:02 -0400 Date: Tue, 4 Oct 2016 16:59:57 +0100 From: Stefan Hajnoczi Message-ID: <20161004155957.GD28028@stefanha-x1.localdomain> References: <147524835229.953.16853431367911587573.stgit@bahia> <147524842061.953.1383418396572489697.stgit@bahia> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ylS2wUBXLOxYXZFQ" Content-Disposition: inline In-Reply-To: <147524842061.953.1383418396572489697.stgit@bahia> Subject: Re: [Qemu-devel] [PATCH v4 8/9] virtio-scsi: convert virtio_scsi_bad_req() to use virtio_error() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Greg Kurz Cc: qemu-devel@nongnu.org, Kevin Wolf , "Michael S. Tsirkin" , Jason Wang , Max Reitz , "Aneesh Kumar K.V" , Cornelia Huck , Paolo Bonzini --ylS2wUBXLOxYXZFQ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Sep 30, 2016 at 05:13:40PM +0200, Greg Kurz wrote: > The virtio_scsi_bad_req() function is called when a guest sends a > request with missing or ill-sized headers. This generally happens > when the virtio_scsi_parse_req() function returns an error. >=20 > With this patch, virtio_scsi_bad_req() will mark the device as broken, > detach the request from the virtqueue and free it, instead of forcing > QEMU to exit. >=20 > In nearly all locations where virtio_scsi_bad_req() is called, the only > thing to do next is to return to the caller. >=20 > The virtio_scsi_handle_cmd_req_prepare() function is an exception though. >=20 > It is called in a loop by virtio_scsi_handle_cmd_vq() and passed requests > freshly popped from a cmd virtqueue; virtio_scsi_handle_cmd_req_prepare() > does some sanity checks on the request and returns a boolean flag to > indicate whether the request should be queued or not. In the latter case, > virtio_scsi_handle_cmd_req_prepare() has detected a non-fatal error and > sent a response back to the guest. >=20 > We have now a new condition to take into account: the device is broken > and should stop all processing. >=20 > The return value of virtio_scsi_handle_cmd_req_prepare() is hence changed > to an int. A return value of zero means that the request should be queued. > Other non-fatal error cases where the request shoudn't be queued return > a negative errno (values are vaguely inspired by the error condition, but > the only goal here is to discriminate the case we're interested in). >=20 > And finally, if virtio_scsi_bad_req() was called, -EINVAL is returned. In > this case, virtio_scsi_handle_cmd_vq() detaches and frees already queued > requests, instead of submitting them. >=20 > Signed-off-by: Greg Kurz > --- > v4: - fixed success return value in virtio_scsi_handle_cmd_req_prepare() > - fixed typo in changelog > --- > hw/scsi/virtio-scsi.c | 46 ++++++++++++++++++++++++++++++++-----------= --- > 1 file changed, 32 insertions(+), 14 deletions(-) Reviewed-by: Stefan Hajnoczi --ylS2wUBXLOxYXZFQ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJX89H9AAoJEJykq7OBq3PIUBoH/j6WrfYlZ/ciWW/ayXuF7L9T e0563Oe4v15x+QADolnj7W4wwyqJJ802JAf1UX0W1wOaehLE2s598tNlaxK+kMHn 3PlIFHvaTontOeFgrzRhKa2NeFRZgsfmE2aBoQ8/Ekv4MZOu17vEkfccidd66YYu orWE/K99qTE12bg6yE4T5ab4/pfKadFcV/Wg1z/K8G0qBf3qq5fi3K1h2fKUSAJE 0oGxO+x4PfNKP/BbdAfKptZnVmqcdKrRcjbQqUFIHwvyno/rhaXGaDa6uASWCk2O OnrmyylWJiZrwupeidsuP7hVisOtIfYM6z9NfwRS+GdrpkWIoD9/Ma4IPy/lEcQ= =f1TM -----END PGP SIGNATURE----- --ylS2wUBXLOxYXZFQ--