From patchwork Sun Dec 2 04:50:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 203185 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7A1312C007D for ; Sun, 2 Dec 2012 15:51:18 +1100 (EST) Received: from localhost ([::1]:42306 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tf1WO-0005XC-6o for incoming@patchwork.ozlabs.org; Sat, 01 Dec 2012 23:51:16 -0500 Received: from eggs.gnu.org ([208.118.235.92]:44423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tf1WE-0005X4-2H for qemu-devel@nongnu.org; Sat, 01 Dec 2012 23:51:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tf1WC-00068k-NF for qemu-devel@nongnu.org; Sat, 01 Dec 2012 23:51:05 -0500 Received: from cantor2.suse.de ([195.135.220.15]:39266 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tf1WC-00068Y-Cv for qemu-devel@nongnu.org; Sat, 01 Dec 2012 23:51:04 -0500 Received: from relay2.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 86DB5A398E; Sun, 2 Dec 2012 05:51:03 +0100 (CET) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Sun, 2 Dec 2012 05:50:41 +0100 Message-Id: <1354423851-24818-2-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1354423851-24818-1-git-send-email-afaerber@suse.de> References: <1354423851-24818-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: Avi Kivity , mtosatti@redhat.com, kvm@vger.kernel.org, anthony@codemonkey.ws, =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [PATCH qom-cpu 01/11] cpu: Move kvm_fd into CPUState 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 Signed-off-by: Andreas Färber --- cpu-defs.h | 1 - include/qemu/cpu.h | 4 ++++ kvm-all.c | 8 +++++--- 3 Dateien geändert, 9 Zeilen hinzugefügt(+), 4 Zeilen entfernt(-) diff --git a/cpu-defs.h b/cpu-defs.h index 3669241..6373a80 100644 --- a/cpu-defs.h +++ b/cpu-defs.h @@ -207,7 +207,6 @@ typedef struct CPUWatchpoint { const char *cpu_model_str; \ struct KVMState *kvm_state; \ struct kvm_run *kvm_run; \ - int kvm_fd; \ int kvm_vcpu_dirty; #endif diff --git a/include/qemu/cpu.h b/include/qemu/cpu.h index 61b7698..6c66fc0 100644 --- a/include/qemu/cpu.h +++ b/include/qemu/cpu.h @@ -77,6 +77,10 @@ struct CPUState { bool stop; bool stopped; +#if !defined(CONFIG_USER_ONLY) + int kvm_fd; +#endif + /* TODO Move common fields from CPUArchState here. */ }; diff --git a/kvm-all.c b/kvm-all.c index 8e9a8d8..8a00df7 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -216,6 +216,7 @@ static void kvm_reset_vcpu(void *opaque) int kvm_init_vcpu(CPUArchState *env) { + CPUState *cpu = ENV_GET_CPU(env); KVMState *s = kvm_state; long mmap_size; int ret; @@ -228,7 +229,7 @@ int kvm_init_vcpu(CPUArchState *env) goto err; } - env->kvm_fd = ret; + cpu->kvm_fd = ret; env->kvm_state = s; env->kvm_vcpu_dirty = 1; @@ -240,7 +241,7 @@ int kvm_init_vcpu(CPUArchState *env) } env->kvm_run = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED, - env->kvm_fd, 0); + cpu->kvm_fd, 0); if (env->kvm_run == MAP_FAILED) { ret = -errno; DPRINTF("mmap'ing vcpu state failed\n"); @@ -1652,6 +1653,7 @@ int kvm_vm_ioctl(KVMState *s, int type, ...) int kvm_vcpu_ioctl(CPUArchState *env, int type, ...) { + CPUState *cpu = ENV_GET_CPU(env); int ret; void *arg; va_list ap; @@ -1660,7 +1662,7 @@ int kvm_vcpu_ioctl(CPUArchState *env, int type, ...) arg = va_arg(ap, void *); va_end(ap); - ret = ioctl(env->kvm_fd, type, arg); + ret = ioctl(cpu->kvm_fd, type, arg); if (ret == -1) { ret = -errno; }