From patchwork Thu Oct 15 16:50:36 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glauber Costa X-Patchwork-Id: 54059 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9FGwJLY026402 for ; Thu, 15 Oct 2009 16:58:19 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934796AbZJOQvM (ORCPT ); Thu, 15 Oct 2009 12:51:12 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S934632AbZJOQvM (ORCPT ); Thu, 15 Oct 2009 12:51:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:15951 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761781AbZJOQvL (ORCPT ); Thu, 15 Oct 2009 12:51:11 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9FGoj8B027938 for ; Thu, 15 Oct 2009 12:50:45 -0400 Received: from localhost.localdomain (vpn-13-142.rdu.redhat.com [10.11.13.142]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9FGocao020686; Thu, 15 Oct 2009 12:50:43 -0400 From: Glauber Costa To: kvm@vger.kernel.org Cc: avi@redhat.com Subject: [PATCH v2 2/3] get rid of vcpu structure Date: Thu, 15 Oct 2009 13:50:36 -0300 Message-Id: <1255625437-32395-3-git-send-email-glommer@redhat.com> In-Reply-To: <1255625437-32395-2-git-send-email-glommer@redhat.com> References: <1255625437-32395-1-git-send-email-glommer@redhat.com> <1255625437-32395-2-git-send-email-glommer@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/qemu-kvm.c b/qemu-kvm.c index 700d030..7943281 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -440,16 +440,13 @@ static void kvm_create_vcpu(CPUState *env, int id) { long mmap_size; int r; - kvm_vcpu_context_t vcpu_ctx = qemu_malloc(sizeof(struct kvm_vcpu_context)); r = kvm_vm_ioctl(kvm_state, KVM_CREATE_VCPU, id); if (r < 0) { fprintf(stderr, "kvm_create_vcpu: %m\n"); - goto err; + return; } - vcpu_ctx->fd = r; - env->kvm_fd = r; env->kvm_state = kvm_state; @@ -459,7 +456,7 @@ static void kvm_create_vcpu(CPUState *env, int id) goto err_fd; } env->kvm_run = - mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED, vcpu_ctx->fd, + mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED, env->kvm_fd, 0); if (env->kvm_run == MAP_FAILED) { fprintf(stderr, "mmap vcpu area: %m\n"); @@ -468,9 +465,7 @@ static void kvm_create_vcpu(CPUState *env, int id) return; err_fd: - close(vcpu_ctx->fd); - err: - free(vcpu_ctx); + close(env->kvm_fd); } static int kvm_set_boot_vcpu_id(kvm_context_t kvm, uint32_t id) diff --git a/qemu-kvm.h b/qemu-kvm.h index abcb98d..588bc80 100644 --- a/qemu-kvm.h +++ b/qemu-kvm.h @@ -76,12 +76,7 @@ struct kvm_context { int max_gsi; }; -struct kvm_vcpu_context { - int fd; -}; - typedef struct kvm_context *kvm_context_t; -typedef struct kvm_vcpu_context *kvm_vcpu_context_t; #include "kvm.h" int kvm_alloc_kernel_memory(kvm_context_t kvm, unsigned long memory,