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=cKlR+N2K; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 6A6DB5A061A for ; Mon, 10 Feb 2025 10:18:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202502; t=1739179087; bh=buQKDN6CaW+0vd+Ff/on0Z0rzcp2BoXpCKdTNDDL6K4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cKlR+N2Kr9iIy7ST8sF/QJA80lBU2wrQpbBWi4knQH/5KUbHQrx4YVOXfZDVHS7+3 fI1pnlU9vNcu/wzR7HEtleBJ7mRFXN6+gf35PjxJwNB7ESm9IUtr9pktnAyAt64zcx zkfK+wroHsWDRFBpWmk3fDXaRpg5TQqPVkFEmVVuoZTN9QKvmIabFPmMtBpfEVddxm pmna8AzU+QVANse2vfhcyTJm+Vvha6v99Ehd2KNh3C/P186qmHXfo9h9LB5lqO8nPI Ezl8z0k65ZlPqHiYLfTDK6CyKgCGK7RUMe//q8sEq4+rKIwEg24sOVwrn/7N7r0H9r rPueRDWb8BS1g== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4YrzWg5D65z4wyr; Mon, 10 Feb 2025 20:18:07 +1100 (AEDT) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v14 09/14] vhost_user: Make source quit after reporting migration state Date: Mon, 10 Feb 2025 20:18:00 +1100 Message-ID: <20250210091805.2261228-10-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250210091805.2261228-1-david@gibson.dropbear.id.au> References: <20250210091805.2261228-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: AMGIGR2XZSBVIGALDZMV4QDYYW6FEXAO X-Message-ID-Hash: AMGIGR2XZSBVIGALDZMV4QDYYW6FEXAO 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: David Gibson 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: From: Stefano Brivio This will close all the sockets we currently have open in repair mode, and completes our migration tasks as source. If the hypervisor wants to have us back at this point, somebody needs to restart us. Signed-off-by: Stefano Brivio Message-ID: <20250209222005.1640077-5-sbrivio@redhat.com> Signed-off-by: David Gibson --- vhost_user.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/vhost_user.c b/vhost_user.c index 256c8ab6..9115fb50 100644 --- a/vhost_user.c +++ b/vhost_user.c @@ -998,6 +998,9 @@ static bool vu_send_rarp_exec(struct vu_dev *vdev, return false; } +/* If set, quit when we get a VHOST_USER_CHECK_DEVICE_STATE, after replying */ +static bool quit_on_device_state = false; + /** * vu_set_device_state_fd_exec() - Set the device state migration channel * @vdev: vhost-user device @@ -1025,6 +1028,9 @@ static bool vu_set_device_state_fd_exec(struct vu_dev *vdev, migrate_request(vdev->context, msg->fds[0], direction == VHOST_USER_TRANSFER_STATE_DIRECTION_LOAD); + if (direction == VHOST_USER_TRANSFER_STATE_DIRECTION_SAVE) + quit_on_device_state = true; + /* We don't provide a new fd for the data transfer */ vmsg_set_reply_u64(msg, VHOST_USER_VRING_NOFD_MASK); @@ -1203,4 +1209,10 @@ void vu_control_handler(struct vu_dev *vdev, int fd, uint32_t events) if (reply_requested) vu_send_reply(fd, &msg); + + if (quit_on_device_state && + msg.hdr.request == VHOST_USER_CHECK_DEVICE_STATE) { + info("Migration complete, exiting"); + _exit(EXIT_SUCCESS); + } } -- 2.48.1