From nobody Fri May 17 06:49:22 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1712225180; cv=none; d=zohomail.com; s=zohoarc; b=kasynCzpqBZJM52OBrIGkNOK9w41YhfWejCU1oNiWtHDdiS0F0rP2Ad7V2/s156MuN67gbLgAnjEPDvmMlbgH9F/k7BpViF8jXvmqdrA22BqHtD3DBw4D3PJfwwRRtAq+kv/wvkur5yPd9HfP4AGAZU3CGMYKvibVSLp/1C4D2A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1712225180; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CaVI9tJmeNZCvl+ZMK0SswCKD2ypIpxfLloCEEdyjzg=; b=oBoz3234VZI4hMrRquYQupBrZWE60ioI+mQ5EYrLcERMoE8BS83CYAu9N/PNExSFJ9BzeSMBoTGo7FPT3eRyvmKgUCPqJAebQXSpDsfGh+beJhHGqo1BlhB5U3qEF+rWvvYdWsTSZg/q5XmzMZPirOLbun4Optw8DhYS6ADpKXg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1712225180418342.9135425136741; Thu, 4 Apr 2024 03:06:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rsJys-0007ai-4V; Thu, 04 Apr 2024 06:06:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rsJyq-0007aW-AE for qemu-devel@nongnu.org; Thu, 04 Apr 2024 06:06:00 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rsJym-00020k-QS for qemu-devel@nongnu.org; Thu, 04 Apr 2024 06:06:00 -0400 Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Apr 2024 03:05:53 -0700 Received: from tdx-lm.sh.intel.com ([10.239.53.27]) by orviesa010.jf.intel.com with ESMTP; 04 Apr 2024 03:05:53 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712225156; x=1743761156; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=qPJHs5IRDK5Kl7oXD7X7+rUG9w8UCl78b969bFHQ7Xc=; b=iIou6jotFC0Xh1wnaSUyG0lEAv8vlj2ASSYmt4AbwjwhYyRzo5caADy2 kvuMLb/dmD78vDeDT4Cp4OqL9AcRbiDFOmRf0oKjOjCf8JoZIWGtN0aw+ 0B2dHkgS01NSPBubrBYmOsAqA8P5gBZaVpZRXcEb3oYIUscXMNwyd8yy7 ZZO6QschxWmj2NbVfCLfOceGwN7Fu3PYl6XnjbHOm8b4UiJgGMncHB/46 WcrZ8OVV0PDUciOwDqY8POCN1lXaPAbEI4awzfiBsjroXqGE9CJKl3wga 6CFnT8ZUo37kRYmOJO7IDgXz7GEdfz4VX35HEUQ8EJ+/5JjHjA4rc+OU1 w==; X-CSE-ConnectionGUID: RrT+JhT8SkSu6hI7MeBfxg== X-CSE-MsgGUID: LvAcjFnNSmW7X2OMvlm59g== X-IronPort-AV: E=McAfee;i="6600,9927,11033"; a="7681737" X-IronPort-AV: E=Sophos;i="6.07,179,1708416000"; d="scan'208";a="7681737" X-CSE-ConnectionGUID: Lra+MaHMSVO98gFrPc/3Og== X-CSE-MsgGUID: t93ka3axST2S4TBlLLdhyQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,179,1708416000"; d="scan'208";a="18579623" From: Wei Wang To: peterx@redhat.com, lei4.wang@intel.com, farosas@suse.de Cc: qemu-devel@nongnu.org, Wei Wang Subject: [PATCH v1] migration/postcopy: ensure preempt channel is ready before loading states Date: Thu, 4 Apr 2024 18:05:50 +0800 Message-Id: <20240404100550.17777-1-wei.w.wang@intel.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=192.198.163.15; envelope-from=wei.w.wang@intel.com; helo=mgamail.intel.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1712225181505100003 Content-Type: text/plain; charset="utf-8" Before loading the guest states, ensure that the preempt channel has been ready to use, as some of the states (e.g. via virtio_load) might trigger page faults that will be handled through the preempt channel. So yield to the main thread in the case that the channel create event has been dispatched. Originally-by: Lei Wang Link: https://lore.kernel.org/all/9aa5d1be-7801-40dd-83fd-f7e041ced249@inte= l.com/T/ Suggested-by: Peter Xu Signed-off-by: Lei Wang Signed-off-by: Wei Wang --- migration/savevm.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/migration/savevm.c b/migration/savevm.c index 388d7af7cd..fbc9f2bdd4 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2342,6 +2342,23 @@ static int loadvm_handle_cmd_packaged(MigrationIncom= ingState *mis) =20 QEMUFile *packf =3D qemu_file_new_input(QIO_CHANNEL(bioc)); =20 + /* + * Before loading the guest states, ensure that the preempt channel has + * been ready to use, as some of the states (e.g. via virtio_load) mig= ht + * trigger page faults that will be handled through the preempt channe= l. + * So yield to the main thread in the case that the channel create eve= nt + * has been dispatched. + */ + do { + if (!migrate_postcopy_preempt() || !qemu_in_coroutine() || + mis->postcopy_qemufile_dst) { + break; + } + + aio_co_schedule(qemu_get_current_aio_context(), qemu_coroutine_sel= f()); + qemu_coroutine_yield(); + } while (!qemu_sem_timedwait(&mis->postcopy_qemufile_dst_done, 1)); + ret =3D qemu_loadvm_state_main(packf, mis); trace_loadvm_handle_cmd_packaged_main(ret); qemu_fclose(packf); --=20 2.27.0