Received: from eggs.gnu.org ([2001:4830:134:3::10]:43677) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1GxQ-0002hu-HI for qemu-devel@nongnu.org; Mon, 31 Oct 2016 14:05:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1GxL-0003BV-LC for qemu-devel@nongnu.org; Mon, 31 Oct 2016 14:05:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39482) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c1GxL-0003BK-DH for qemu-devel@nongnu.org; Mon, 31 Oct 2016 14:05:11 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B0915C04B92A for ; Mon, 31 Oct 2016 18:05:10 +0000 (UTC) References: <1477924663-30950-1-git-send-email-pbonzini@redhat.com> <1477924663-30950-23-git-send-email-pbonzini@redhat.com> From: Eric Blake Message-ID: <37f8e25d-31f8-a7e6-68f7-1d3dcaa32c31@redhat.com> Date: Mon, 31 Oct 2016 13:05:09 -0500 MIME-Version: 1.0 In-Reply-To: <1477924663-30950-23-git-send-email-pbonzini@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="4XvWIisBP386bHlHtsIAW6u1oTqTf06Ok" Subject: Re: [Qemu-devel] [PULL 22/27] nbd: Improve server handling of shutdown requests List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --4XvWIisBP386bHlHtsIAW6u1oTqTf06Ok From: Eric Blake To: Paolo Bonzini , qemu-devel@nongnu.org Message-ID: <37f8e25d-31f8-a7e6-68f7-1d3dcaa32c31@redhat.com> Subject: Re: [PULL 22/27] nbd: Improve server handling of shutdown requests References: <1477924663-30950-1-git-send-email-pbonzini@redhat.com> <1477924663-30950-23-git-send-email-pbonzini@redhat.com> In-Reply-To: <1477924663-30950-23-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 10/31/2016 09:37 AM, Paolo Bonzini wrote: > From: Eric Blake >=20 > NBD commit 6d34500b clarified how clients and servers are supposed > to behave before closing a connection. It added NBD_REP_ERR_SHUTDOWN > (for the server to announce it is about to go away during option > haggling, so the client should quit sending NBD_OPT_* other than > NBD_OPT_ABORT) and ESHUTDOWN (for the server to announce it is about > to go away during transmission, so the client should quit sending > NBD_CMD_* other than NBD_CMD_DISC). It also clarified that > NBD_OPT_ABORT gets a reply, while NBD_CMD_DISC does not. >=20 > This patch merely adds the missing reply to NBD_OPT_ABORT and teaches > the client to recognize server errors. Actually teaching the server > to send NBD_REP_ERR_SHUTDOWN or ESHUTDOWN would require knowing that > the server has been requested to shut down soon (maybe we could do > that by installing a SIGINT handler in qemu-nbd, which transitions > from RUNNING to a new state that waits for the client to react, > rather than just out-right quitting - but that's a bigger task for > another day). >=20 > Signed-off-by: Eric Blake > Message-Id: <1476469998-28592-15-git-send-email-eblake@redhat.com> > [Move dummy ESHUTDOWN to include/qemu/osdep.h. - Paolo] > Signed-off-by: Paolo Bonzini > --- > +++ b/include/qemu/osdep.h > @@ -128,6 +128,9 @@ extern int daemon(int, int); > #if !defined(EMEDIUMTYPE) > #define EMEDIUMTYPE 4098 > #endif > +#if !defined(ESHUTDOWN) > +#define ESHUTDOWN 4099 > +#endif Technically, with this code in place... > +++ b/nbd/server.c > @@ -39,6 +39,10 @@ static int system_errno_to_nbd_errno(int err) > case EFBIG: > case ENOSPC: > return NBD_ENOSPC; > +#ifdef ESHUTDOWN > + case ESHUTDOWN: > + return NBD_ESHUTDOWN; > +#endif =2E..the #ifdef here is pointless. Can be cleaned up in a followup, so should not stop the pull request. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --4XvWIisBP386bHlHtsIAW6u1oTqTf06Ok Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJYF4fVAAoJEKeha0olJ0Nqg7QIAI9D860EJN0R7XYI2diJOqad vM0IZ+Pti6NwS1cq11finHWDyu8U71YCj7Pyj0NBUZFMLDth8+h5RQ+BkmO+fzO4 8jZmXLGl8CC2Fqmkdph9tr88nvHjzpU9CJvauutDb32uUcci8P1kzS1t9RyVKRto 5ni9q8qFOEpYIbB//DyykbEmj6lqWwAGvoXXkljDBGPZUMmS+tun7GRZGfW+6+PF srnqXmOpTMW1Jt9mO7IJy2UVcUMTOTTGT4WnxSBBDz71S42wdmfiJQ/DfPUkuL2O y1zKnaVl2mPjb5LUxsk6vDVW5rQBLGbN5n0O12ECpSxo4c8Hkp8EYkHFLCnQf48= =mbmx -----END PGP SIGNATURE----- --4XvWIisBP386bHlHtsIAW6u1oTqTf06Ok--