From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: How to get to know vcpu status from outside Date: Tue, 17 Dec 2013 12:21:31 +0100 Message-ID: <52B033BB.6070401@redhat.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: kvm To: Arthur Chunqi Li Return-path: Received: from mail-ea0-f170.google.com ([209.85.215.170]:60213 "EHLO mail-ea0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750972Ab3LQLVf (ORCPT ); Tue, 17 Dec 2013 06:21:35 -0500 Received: by mail-ea0-f170.google.com with SMTP id k10so2796361eaj.15 for ; Tue, 17 Dec 2013 03:21:34 -0800 (PST) In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: Il 17/12/2013 07:11, Arthur Chunqi Li ha scritto: > Hi Paolo, > > Since VCPU is managed the same as a process in kernel, how can I know > the status (running, sleeping etc.) of a vcpu in kernel? Is there a > variant in struct kvm_vcpu or something else indicate this? waitqueue_active(&vcpu->wq) means that the VCPU is sleeping in the kernel (i.e. in a halted state). vcpu->mode == IN_GUEST_MODE means that the VCPU is running. Anything else means that the host is running some kind of "glue" code (either kernel or userspace). > Besides, if vcpu1 is running on pcpu1, and a kernel thread running on > pcpu0. Can the kernel thread send a message to force vcpu1 trap to > VMM? How can I do this? Yes, with kvm_vcpu_kick. KVM tracks internally which pcpu will run the vcpu in vcpu->cpu, and kvm_vcpu_kick sends either a wakeup (if the vcpu is sleeping) or an IPI (if it is running). Paolo