From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202502 header.b=SATC7N/v; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 5B37C5A0276 for ; Mon, 03 Feb 2025 03:17:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202502; t=1738549000; bh=zEOrJGIWMaKyrBzTdQC6AUjagKDhK+JFaPPK2NgfhJ8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SATC7N/vR7L2fdKPlVQrpLopjtvYTK81SL25jITkma87Bog5PR6a0798imEeHlRDd 8/zp5mIHT38PcQQwaAs/B52bGFl4rMy9q73yFpjzbwksBt0KpNj3UziAzt9v67UWBD yrJZyN3A8TdgrkMpiz6dxjzCUtGj3SkZmd7JoKoHQarQV2uyJZCANImH1dI6RouaV5 Nkj540UnwzXRI7t+h/ShEOQWT+NlQ3ign805rlKMio4eMXdjErUMLQrKjf/N/2WYjA s9u6uPLMG+mwhijs3aUcfDCqmGq/xXz8zEo4xJg1pzZcGibfWzpv2ULrjxyVHTDNZU 53kf7YVAXrQUQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4YmVVc4QGwz4wyV; Mon, 3 Feb 2025 13:16:40 +1100 (AEDT) Date: Mon, 3 Feb 2025 12:55:47 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH v3 17/20] vhost_user: Make source quit after reporting migration state Message-ID: References: <20250131193953.3034031-1-sbrivio@redhat.com> <20250131193953.3034031-18-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="geOVV54ASW0gEyqv" Content-Disposition: inline In-Reply-To: <20250131193953.3034031-18-sbrivio@redhat.com> Message-ID-Hash: IZ2RTPXAML2EDBCT6OHHN5CRUI4SH7TW X-Message-ID-Hash: IZ2RTPXAML2EDBCT6OHHN5CRUI4SH7TW X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, Laurent Vivier X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --geOVV54ASW0gEyqv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jan 31, 2025 at 08:39:50PM +0100, Stefano Brivio wrote: > On migration, the source process asks passt-helper to set TCP sockets > in repair mode, dumps the information we need to migrate connections, > and closes them. >=20 > At this point, we can't pass them back to passt-helper using > SCM_RIGHTS, because they are closed, from that perspective, and > sendmsg() will give us EBADF. But if we don't clear repair mode, the > port they are bound to will not be available for binding in the > target. >=20 > Terminate once we're done with the migration and we reported the > state. This is equivalent to clearing repair mode on the sockets we > just closed. As noted on the passt-repair patch, I think this is based on a misinterpreation of the situation. I think the problem is that the sockets aren't closed in passt-repair, so the additional handle copy is keeping the underlying socket open. This appears to work, because it is causing passt-repair to also terminate. That said, we probably want to terminate on the source side after a succesful migrate anyway. At the very least we need to close() all our sockets, and delete the corresponding flows, because we don't own them any more. Quitting is probably the simplest way to do that. Which also makes me realise, on a *failed* outbound migration, we _do_ need to turn repair mode off on everything again. Is that implemented yet? >=20 > Signed-off-by: Stefano Brivio > --- > vhost_user.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) >=20 > diff --git a/vhost_user.c b/vhost_user.c > index 1092387..19ede8a 100644 > --- a/vhost_user.c > +++ b/vhost_user.c > @@ -997,6 +997,8 @@ static bool vu_send_rarp_exec(struct vu_dev *vdev, > return false; > } > =20 > +static bool quit_on_device_state =3D false; > + > /** > * vu_set_device_state_fd_exec() - Set the device state migration channel > * @vdev: vhost-user device > @@ -1024,6 +1026,9 @@ static bool vu_set_device_state_fd_exec(struct vu_d= ev *vdev, > migrate_request(vdev->context, msg->fds[0], > direction =3D=3D VHOST_USER_TRANSFER_STATE_DIRECTION_LOAD); > =20 > + if (direction =3D=3D VHOST_USER_TRANSFER_STATE_DIRECTION_SAVE) > + quit_on_device_state =3D true; > + > /* We don't provide a new fd for the data transfer */ > vmsg_set_reply_u64(msg, VHOST_USER_VRING_NOFD_MASK); > =20 > @@ -1201,4 +1206,10 @@ void vu_control_handler(struct vu_dev *vdev, int f= d, uint32_t events) > =20 > if (reply_requested) > vu_send_reply(fd, &msg); > + > + if (quit_on_device_state && > + msg.hdr.request =3D=3D VHOST_USER_CHECK_DEVICE_STATE) { > + info("Migration complete, exiting"); > + exit(EXIT_SUCCESS); > + } > } --=20 David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson --geOVV54ASW0gEyqv Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmegIiIACgkQzQJF27ox 2GcbQw//cfq7vceLq20GWrwZ2734es1J+vbAC5+I6FROTtV9Qrzm3MENuKWLlUi1 SGYxBm3Mjf5aexw1lm0glPEtMhlyUd/S5GZ/bBtP+4eIjsSGds5zKKPbiSe+TgSv bMFG5VkVU+kzm9mX+NZmrM7MHRA89tMA5UwZUPdpCyMSkJsPgDV3twE/5fn9pCOQ 0KepMyauM4h8mGjpYGhU+xXW9eb60Mb73fRyDd2xPbJg9CeTEXpSKU5WaJ87X2zm XA+3frBN+BLe56yVzBIHEtSRnvb/cIOFqJuv01LTTo1PQ5c4awiJQ0TrlzYK9xy0 jhgiRQOr33lwPfcBErOEj80T8rHRL8H/eIHkdNFAr2EpahW9PuOom631jfbIYNxj FSs1E6eXVFMYGEF53DvmG5mNjCDLPWf76/io4JLiiamjYXM4r16A+rL+zpNLZVHE G0tcLFlKIuXswGT6Hna2GCxkIOfh9AdtqKuxMQRZ72BItPyytZhzgNYUM9munlmA WpAlo0Acr7hcqJXI9+3Dp6uOP9w8uzP1RsTxMiRE2CnE/7cHFQuMKka4ZlFCzXAU OtBK/ZMW+852kphjMWZ7OoKtRwR9Jp7bmH/Ou5i2kizGRd9zrCuGiQFsLoe4lj6M 2Pq6RZsoAZdHygUwhW2IXb/R7trkl+lJ36pg57+H5ZuIz7QNdFI= =5zHj -----END PGP SIGNATURE----- --geOVV54ASW0gEyqv--