]> git.proxmox.com Git - qemu.git/commitdiff
cpu: Move kvm_fd into CPUState
authorAndreas Färber <afaerber@suse.de>
Wed, 31 Oct 2012 04:29:00 +0000 (05:29 +0100)
committerAndreas Färber <afaerber@suse.de>
Wed, 19 Dec 2012 13:09:31 +0000 (14:09 +0100)
Signed-off-by: Andreas Färber <afaerber@suse.de>
cpu-defs.h
include/qemu/cpu.h
kvm-all.c

index 3669241fafb956987046f633ae4d29a588cde47b..6373a808f99a566ea6c8a4cf376f339bfab5f4a7 100644 (file)
@@ -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
index 61b76982f1442771e338d22ed43b17b4060b5415..6049a20a4ddff1699b54beb69cb1f1944760d47b 100644 (file)
@@ -57,6 +57,7 @@ typedef struct CPUClass {
  * @created: Indicates whether the CPU thread has been successfully created.
  * @stop: Indicates a pending stop request.
  * @stopped: Indicates the CPU has been artificially stopped.
+ * @kvm_fd: vCPU file descriptor for KVM.
  *
  * State of one CPU core or thread.
  */
@@ -77,6 +78,10 @@ struct CPUState {
     bool stop;
     bool stopped;
 
+#if !defined(CONFIG_USER_ONLY)
+    int kvm_fd;
+#endif
+
     /* TODO Move common fields from CPUArchState here. */
 };
 
index 8e9a8d8fd2ce148b64588753de993aac6468b309..8a00df72c3d2ccc90e820dbbb5f351c8e7496c2b 100644 (file)
--- 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;
     }