Received: from eggs.gnu.org ([2001:4830:134:3::10]:51949) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLae4-0006JC-2S for qemu-devel@nongnu.org; Thu, 06 Mar 2014 10:55:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WLadw-0005lv-PA for qemu-devel@nongnu.org; Thu, 06 Mar 2014 10:55:39 -0500 Received: from indigo.cs.bgu.ac.il ([132.72.42.23]:49042) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLadw-0005lT-An for qemu-devel@nongnu.org; Thu, 06 Mar 2014 10:55:32 -0500 Date: Thu, 6 Mar 2014 17:54:15 +0200 (IST) Message-Id: <201403061554.s26FsFnB017186@indigo.cs.bgu.ac.il> From: Alexander Binun MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 In-Reply-To: <53185BE2.4080101@redhat.com> Subject: Re: [Qemu-devel] kill /destroy a VM - still hangs! List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: kahilm@post.bgu.ac.il, Stefan Hajnoczi , markbl@post.bgu.ac.il, qemu-devel@nongnu.org, boaz.menuhin@gmail.com Hello Friends, Thanks to your help I have found the task structure of the target process (denote it as TASK) and its group leader (TASK->tgid) Now I did the following: struct siginfo info; .. info.si_signo = SIGTERM; info.si_code = SI_QUEUE; info.si_errno = 0; /* no recovery */ status = send_sig_info(SIGTERM, &info, task); The result: both the host and the guest hang! Can I use the kill function directly : kill (TASK->tgid, SIGTERM) ? This function is a user-space one... Best Regards, the team On Thu 06 Mar 13:28 2014 Paolo Bonzini wrote: > Il 06/03/2014 11:31, Alexander Binun ha scritto: > > Then - more questions : > > 1. How can I access the Qemu process (relevant to a given VM) from within in the kernel context (being in a kernel module) ? > > The struct pid for the VCPU is in the "pid" field of struct kvm_vcpu. > > From there if needed you can get the task (with pid_task) and the > task's thread group leader (the task's group_leader), and send a signal > to it. > > > 2. Should I uninitialize some internal structures for the VM being killed ? > > No, it will happen automatically. When QEMU is terminated, the VM's > file descriptor is closed and this frees all internal structures. > > > 3. My module detects malicious activities at a VCPU. How can one get the VM owning this VCPU ? > > Field "kvm" in struct kvm_vcpu points to the struct kvm for the VM. > > Paolo >