Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Glauber Costa <glommer@redhat.com>
To: kvm@vger.kernel.org
Cc: avi@redhat.com
Subject: [PATCH 05/10] Use kvm_run inside CPUState.
Date: Fri,  9 Oct 2009 15:03:13 -0300	[thread overview]
Message-ID: <1255111398-15251-6-git-send-email-glommer@redhat.com> (raw)
In-Reply-To: <1255111398-15251-5-git-send-email-glommer@redhat.com>

There is no need to replicate kvm_run inside vcpu context, since there is
already a field dedicated to that in CPUState. For now, keep both on, so
function can be converted slowly, since a lot of function headers will
be changed to take an env parameter, instead of a vcpu one.

This patch also converts functions that are static to this file as a first step.

Signed-off-by: Glauber Costa <glommer@redhat.com>
---
 qemu-kvm.c |   27 +++++++++++++++------------
 qemu-kvm.h |    1 -
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/qemu-kvm.c b/qemu-kvm.c
index 5c7376d..a7eda2d 100644
--- a/qemu-kvm.c
+++ b/qemu-kvm.c
@@ -459,13 +459,16 @@ kvm_vcpu_context_t kvm_create_vcpu(CPUState *env, int id)
         fprintf(stderr, "get vcpu mmap size: %m\n");
         goto err_fd;
     }
-    vcpu_ctx->run =
+    env->kvm_run =
         mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED, vcpu_ctx->fd,
              0);
-    if (vcpu_ctx->run == MAP_FAILED) {
+    if (env->kvm_run == MAP_FAILED) {
         fprintf(stderr, "mmap vcpu area: %m\n");
         goto err_fd;
     }
+
+    vcpu_ctx->run = env->kvm_run;
+
     return vcpu_ctx;
   err_fd:
     close(vcpu_ctx->fd);
@@ -757,9 +760,9 @@ int kvm_set_irqchip(kvm_context_t kvm, struct kvm_irqchip *chip)
 
 #endif
 
-static int handle_io(kvm_vcpu_context_t vcpu)
+static int handle_io(CPUState *env)
 {
-    struct kvm_run *run = vcpu->run;
+    struct kvm_run *run = env->kvm_run;
     uint16_t addr = run->io.port;
     int i;
     void *p = (void *) run + run->io.data_offset;
@@ -809,10 +812,10 @@ static int handle_io(kvm_vcpu_context_t vcpu)
     return 0;
 }
 
-int handle_debug(kvm_vcpu_context_t vcpu, void *env)
+static int handle_debug(CPUState *env)
 {
 #ifdef KVM_CAP_SET_GUEST_DEBUG
-    struct kvm_run *run = vcpu->run;
+    struct kvm_run *run = env->kvm_run;
 
     return kvm_debug(env, &run->debug.arch);
 #else
@@ -872,10 +875,10 @@ int kvm_set_mpstate(kvm_vcpu_context_t vcpu, struct kvm_mp_state *mp_state)
 }
 #endif
 
-static int handle_mmio(kvm_vcpu_context_t vcpu)
+static int handle_mmio(CPUState *env)
 {
-    unsigned long addr = vcpu->run->mmio.phys_addr;
-    struct kvm_run *kvm_run = vcpu->run;
+    unsigned long addr = env->kvm_run->mmio.phys_addr;
+    struct kvm_run *kvm_run = env->kvm_run;
     void *data = kvm_run->mmio.data;
 
     /* hack: Red Hat 7.1 generates these weird accesses. */
@@ -1001,13 +1004,13 @@ int kvm_run(kvm_vcpu_context_t vcpu, void *env)
             abort();
             break;
         case KVM_EXIT_IO:
-            r = handle_io(vcpu);
+            r = handle_io(env);
             break;
         case KVM_EXIT_DEBUG:
-            r = handle_debug(vcpu, env);
+            r = handle_debug(env);
             break;
         case KVM_EXIT_MMIO:
-            r = handle_mmio(vcpu);
+            r = handle_mmio(env);
             break;
         case KVM_EXIT_HLT:
             r = kvm_arch_halt(vcpu);
diff --git a/qemu-kvm.h b/qemu-kvm.h
index 4dfd5ea..3bc483e 100644
--- a/qemu-kvm.h
+++ b/qemu-kvm.h
@@ -106,7 +106,6 @@ int handle_shutdown(kvm_context_t kvm, CPUState *env);
 void post_kvm_run(kvm_context_t kvm, CPUState *env);
 int pre_kvm_run(kvm_context_t kvm, CPUState *env);
 int handle_io_window(kvm_context_t kvm);
-int handle_debug(kvm_vcpu_context_t vcpu, void *env);
 int try_push_interrupts(kvm_context_t kvm);
 
 #if defined(__x86_64__) || defined(__i386__)
-- 
1.6.2.5


  reply	other threads:[~2009-10-09 18:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-09 18:03 [PATCH 00/10] Clean up vcpu context structure Glauber Costa
2009-10-09 18:03 ` [PATCH 01/10] use a more upstream friendly version of irqchip-in-kernel test Glauber Costa
2009-10-09 18:03   ` [PATCH 02/10] drop kvm_mmio_read and write Glauber Costa
2009-10-09 18:03     ` [PATCH 03/10] remove unneded opaque Glauber Costa
2009-10-09 18:03       ` [PATCH 04/10] remove kvm_context from vpcu structure Glauber Costa
2009-10-09 18:03         ` Glauber Costa [this message]
2009-10-09 18:03           ` [PATCH 06/10] make some functions static Glauber Costa
2009-10-09 18:03             ` [PATCH 07/10] use env as parameter for functions that access kvm_run Glauber Costa
2009-10-09 18:03               ` [PATCH 08/10] use env in kvm_arch_run Glauber Costa
2009-10-09 18:03                 ` [PATCH 09/10] remove kvm_run from vcpu_context Glauber Costa
2009-10-09 18:03                   ` [PATCH 10/10] remove id field from vcpu context structure Glauber Costa
2009-10-12  9:24 ` [PATCH 00/10] Clean up " Avi Kivity
2009-10-13 17:04 ` Marcelo Tosatti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1255111398-15251-6-git-send-email-glommer@redhat.com \
    --to=glommer@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox