From patchwork Tue Feb 14 15:13:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 141130 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 508701007D1 for ; Wed, 15 Feb 2012 03:21:00 +1100 (EST) Received: from localhost ([::1]:48548 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxK5W-0001N8-Or for incoming@patchwork.ozlabs.org; Tue, 14 Feb 2012 10:14:38 -0500 Received: from eggs.gnu.org ([140.186.70.92]:33405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxK4d-0000GT-CY for qemu-devel@nongnu.org; Tue, 14 Feb 2012 10:13:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RxK4L-0004b5-2T for qemu-devel@nongnu.org; Tue, 14 Feb 2012 10:13:43 -0500 Received: from goliath.siemens.de ([192.35.17.28]:31090) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RxK4K-0004ZR-Q5 for qemu-devel@nongnu.org; Tue, 14 Feb 2012 10:13:25 -0500 Received: from mail1.siemens.de (localhost [127.0.0.1]) by goliath.siemens.de (8.13.6/8.13.6) with ESMTP id q1EFDGU1014694; Tue, 14 Feb 2012 16:13:17 +0100 Received: from mchn199C.mchp.siemens.de ([139.25.109.49]) by mail1.siemens.de (8.13.6/8.13.6) with ESMTP id q1EFDFPX014538; Tue, 14 Feb 2012 16:13:16 +0100 From: Jan Kiszka To: Avi Kivity , Marcelo Tosatti Date: Tue, 14 Feb 2012 16:13:09 +0100 Message-Id: <2a142f1155027e1fa6e15b0ec58febf70bf7b8a0.1329232393.git.jan.kiszka@siemens.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 192.35.17.28 Cc: Anthony Liguori , Gleb Natapov , kvm@vger.kernel.org, qemu-devel , Blue Swirl , Paolo Bonzini Subject: [Qemu-devel] [PATCH v3 3/9] Allow to use pause_all_vcpus from VCPU context X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org In order to perform critical manipulations on the VM state in the context of a VCPU, specifically code patching, stopping and resuming of all VCPUs may be necessary. resume_all_vcpus is already compatible, now enable pause_all_vcpus for this use case by stopping the calling context before starting to wait for the whole gang. CC: Paolo Bonzini Signed-off-by: Jan Kiszka --- cpus.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/cpus.c b/cpus.c index 4e65894..290daa8 100644 --- a/cpus.c +++ b/cpus.c @@ -870,6 +870,18 @@ void pause_all_vcpus(void) penv = penv->next_cpu; } + if (!qemu_thread_is_self(&io_thread)) { + cpu_stop_current(); + if (!kvm_enabled()) { + while (penv) { + penv->stop = 0; + penv->stopped = 1; + penv = penv->next_cpu; + } + return; + } + } + while (!all_vcpus_paused()) { qemu_cond_wait(&qemu_pause_cond, &qemu_global_mutex); penv = first_cpu;