From: Glauber Costa <glommer@redhat.com>
To: kvm@vger.kernel.org
Cc: avi@redhat.com
Subject: [PATCH 6/8] provide env->kvm_fd
Date: Wed, 8 Jul 2009 09:09:00 -0400 [thread overview]
Message-ID: <1247058542-31211-7-git-send-email-glommer@redhat.com> (raw)
In-Reply-To: <1247058542-31211-6-git-send-email-glommer@redhat.com>
qemu upstream puts kvm information on env. Do that too, since it will
allow us to use CPUState in cpu-specific functions, instead of kvm-specific
types.
Signed-off-by: Glauber Costa <glommer@redhat.com>
---
kvm-all.c | 12 ++++++++----
libkvm-all.h | 12 ------------
2 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/kvm-all.c b/kvm-all.c
index 15bd429..b404f76 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1519,21 +1519,25 @@ void kvm_disable_pit_creation(kvm_context_t kvm)
kvm->no_pit_creation = 1;
}
-kvm_vcpu_context_t kvm_create_vcpu(kvm_context_t kvm, int id)
+static kvm_vcpu_context_t kvm_create_vcpu(kvm_context_t kvm, CPUState *env)
{
long mmap_size;
int r;
kvm_vcpu_context_t vcpu_ctx = qemu_malloc(sizeof(struct kvm_vcpu_context));
vcpu_ctx->kvm = kvm;
- vcpu_ctx->id = id;
+ vcpu_ctx->id = env->cpu_index;
- r = ioctl(kvm->vm_fd, KVM_CREATE_VCPU, id);
+ r = ioctl(kvm->vm_fd, KVM_CREATE_VCPU, env->cpu_index);
if (r == -1) {
fprintf(stderr, "kvm_create_vcpu: %m\n");
goto err;
}
vcpu_ctx->fd = r;
+
+ env->kvm_fd = r;
+ env->kvm_state = kvm_state;
+
mmap_size = ioctl(kvm->fd, KVM_GET_VCPU_MMAP_SIZE, 0);
if (mmap_size == -1) {
fprintf(stderr, "get vcpu mmap size: %m\n");
@@ -3029,7 +3033,7 @@ static void *ap_main_loop(void *_env)
env->thread_id = kvm_get_thread_id();
sigfillset(&signals);
sigprocmask(SIG_BLOCK, &signals, NULL);
- env->kvm_cpu_state.vcpu_ctx = kvm_create_vcpu(kvm_context, env->cpu_index);
+ env->kvm_cpu_state.vcpu_ctx = kvm_create_vcpu(kvm_context, env);
#ifdef USE_KVM_DEVICE_ASSIGNMENT
/* do ioperm for io ports of assigned devices */
diff --git a/libkvm-all.h b/libkvm-all.h
index 7857532..9c018eb 100644
--- a/libkvm-all.h
+++ b/libkvm-all.h
@@ -234,18 +234,6 @@ int kvm_check_extension(kvm_context_t kvm, int ext);
void kvm_create_irqchip(kvm_context_t kvm);
/*!
- * \brief Create a new virtual cpu
- *
- * This creates a new virtual cpu (the first vcpu is created by kvm_create()).
- * Should be called from a thread dedicated to the vcpu.
- *
- * \param kvm kvm context
- * \param slot vcpu number (> 0)
- * \return 0 on success, -errno on failure
- */
-kvm_vcpu_context_t kvm_create_vcpu(kvm_context_t kvm, int id);
-
-/*!
* \brief Start the VCPU
*
* This starts the VCPU and virtualization is started.\n
--
1.6.2.2
next prev parent reply other threads:[~2009-07-08 13:09 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-08 13:08 [PATCH 0/8] Move closer to upstream Glauber Costa
2009-07-08 13:08 ` [PATCH 1/8] Provide KVMState definition outside CONFIG_KVM Glauber Costa
2009-07-08 13:22 ` Avi Kivity
[not found] ` <1247058542-31211-3-git-send-email-glommer@redhat.com>
2009-07-08 13:08 ` [PATCH 3/8] put qemu-kvm-x86.c into kvm.c Glauber Costa
2009-07-08 13:08 ` [PATCH 4/8] replace malloc with qemu_malloc Glauber Costa
2009-07-08 13:08 ` [PATCH 5/8] move kvm_context inside KVMState Glauber Costa
2009-07-08 13:09 ` Glauber Costa [this message]
2009-07-08 13:09 ` [PATCH 7/8] use kvm_upstream sw_breakpoints structure Glauber Costa
2009-07-08 13:09 ` [PATCH 8/8] use upstream code for breakpoint handling Glauber Costa
2009-07-08 13:27 ` [PATCH 7/8] use kvm_upstream sw_breakpoints structure Avi Kivity
2009-07-08 13:39 ` Glauber Costa
2009-07-08 13:44 ` Avi Kivity
2009-07-08 15:23 ` Jan Kiszka
2009-07-08 19:44 ` Jan Kiszka
2009-07-08 19:55 ` Avi Kivity
2009-07-08 13:32 ` [PATCH 6/8] provide env->kvm_fd Gleb Natapov
2009-07-08 13:44 ` Glauber Costa
2009-07-08 13:38 ` Gleb Natapov
2009-07-08 13:23 ` [PATCH 3/8] put qemu-kvm-x86.c into kvm.c Avi Kivity
2009-07-08 13:28 ` Gleb Natapov
2009-07-08 13:41 ` Glauber Costa
2009-07-08 13:23 ` [PATCH 2/8] move qemu-kvm.c to kvm-all.c Avi Kivity
2009-07-08 13:52 ` Glauber Costa
2009-07-08 13:27 ` [PATCH 0/8] Move closer to upstream Avi Kivity
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=1247058542-31211-7-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;
as well as URLs for NNTP newsgroup(s).