From: Jerone Young <jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Cc: kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: [PATCH 06 of 20] Move kvm_create_kernel_phys_mem to libkvm-x86.c
Date: Fri, 02 Nov 2007 05:36:42 -0500 [thread overview]
Message-ID: <c66785783d56c9aa034d.1193999802@thinkpad> (raw)
In-Reply-To: <patchbomb.1193999796@thinkpad>
# HG changeset patch
# User Jerone Young <jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
# Date 1193998359 18000
# Node ID c66785783d56c9aa034de01a3519cf7f42a0f383
# Parent e3def9892f39527f216acbde2de4dad0e8501183
Move kvm_create_kernel_phys_mem to libkvm-x86.c
This patch moves kvm_create_kernel_phys_mem to x86 as this is
the only arch that will be allocating memory for guest in the
kernel (at least for older kvm versions).
Signed-off-by: Jerone Young <jeroney-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
diff --git a/libkvm/kvm-x86.h b/libkvm/kvm-x86.h
--- a/libkvm/kvm-x86.h
+++ b/libkvm/kvm-x86.h
@@ -5,6 +5,8 @@
*/
#ifndef KVM_X86_H
#define KVM_X86_H
+
+#include "kvm-common.h"
/* FIXME: share this number with kvm */
/* FIXME: or dynamically alloc/realloc regions */
@@ -36,4 +38,7 @@ int kvm_arch_create(kvm_context_t kvm, u
int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes,
void **vm_mem);
+void *kvm_create_kernel_phys_mem(kvm_context_t kvm, unsigned long phys_start,
+ unsigned long len, int log, int writable);
+
#endif
diff --git a/libkvm/libkvm-x86.c b/libkvm/libkvm-x86.c
--- a/libkvm/libkvm-x86.c
+++ b/libkvm/libkvm-x86.c
@@ -274,4 +274,36 @@ int kvm_arch_create(kvm_context_t kvm, u
return 0;
}
-
+void *kvm_create_kernel_phys_mem(kvm_context_t kvm, unsigned long phys_start,
+ unsigned long len, int log, int writable)
+{
+ int r;
+ int prot = PROT_READ;
+ void *ptr;
+ struct kvm_memory_region memory = {
+ .memory_size = len,
+ .guest_phys_addr = phys_start,
+ .flags = log ? KVM_MEM_LOG_DIRTY_PAGES : 0,
+ };
+
+ memory.slot = get_free_slot(kvm);
+ r = ioctl(kvm->vm_fd, KVM_SET_MEMORY_REGION, &memory);
+ if (r == -1) {
+ fprintf(stderr, "create_kernel_phys_mem: %s", strerror(errno));
+ return 0;
+ }
+ register_slot(memory.slot, memory.guest_phys_addr);
+ kvm_memory_region_save_params(kvm, &memory);
+
+ if (writable)
+ prot |= PROT_WRITE;
+
+ ptr = mmap(NULL, len, prot, MAP_SHARED, kvm->vm_fd, phys_start);
+ if (ptr == MAP_FAILED) {
+ fprintf(stderr, "create_kernel_phys_mem: %s", strerror(errno));
+ return 0;
+ }
+
+ return ptr;
+}
+
diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c
--- a/libkvm/libkvm.c
+++ b/libkvm/libkvm.c
@@ -375,38 +375,6 @@ int kvm_create(kvm_context_t kvm, unsign
return 0;
}
-void *kvm_create_kernel_phys_mem(kvm_context_t kvm, unsigned long phys_start,
- unsigned long len, int log, int writable)
-{
- int r;
- int prot = PROT_READ;
- void *ptr;
- struct kvm_memory_region memory = {
- .memory_size = len,
- .guest_phys_addr = phys_start,
- .flags = log ? KVM_MEM_LOG_DIRTY_PAGES : 0,
- };
-
- memory.slot = get_free_slot(kvm);
- r = ioctl(kvm->vm_fd, KVM_SET_MEMORY_REGION, &memory);
- if (r == -1) {
- fprintf(stderr, "create_kernel_phys_mem: %s", strerror(errno));
- return 0;
- }
- register_slot(memory.slot, memory.guest_phys_addr);
- kvm_memory_region_save_params(kvm, &memory);
-
- if (writable)
- prot |= PROT_WRITE;
-
- ptr = mmap(NULL, len, prot, MAP_SHARED, kvm->vm_fd, phys_start);
- if (ptr == MAP_FAILED) {
- fprintf(stderr, "create_kernel_phys_mem: %s", strerror(errno));
- return 0;
- }
-
- return ptr;
-}
#ifdef KVM_CAP_USER_MEMORY
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
next prev parent reply other threads:[~2007-11-02 10:36 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-02 10:36 [PATCH 00 of 20] [RESEND] Refactor libkvm code Phase 1 Jerone Young
2007-11-02 10:36 ` [PATCH 01 of 20] Move kvm_context to kvmctl.h Jerone Young
2007-11-02 17:28 ` [kvm-ppc-devel] " Hollis Blanchard
2007-11-02 17:42 ` Jerone Young
2007-11-02 10:36 ` [PATCH 02 of 20] Make static slot & kvm_memory region funcions public Jerone Young
2007-11-02 10:36 ` [PATCH 03 of 20] Move fuction kvm_alloc_kernel_memory to libkvm-x86.c Jerone Young
2007-11-02 10:36 ` [PATCH 04 of 20] Move kvm_alloc_userspace_memory " Jerone Young
2007-11-02 10:36 ` [PATCH 05 of 20] Modify out arch specific code from kvm_create function Jerone Young
2007-11-02 10:36 ` Jerone Young [this message]
2007-11-02 10:36 ` [PATCH 07 of 20] Move kvm_create_phys_mem to libkvm-x86.c Jerone Young
2007-11-02 10:36 ` [PATCH 08 of 20] Move kvm_destroy_phys_mem " Jerone Young
2007-11-02 10:36 ` [PATCH 09 of 20] Move kvm_create_memory_alias & kvm_destroy_memory_alias " Jerone Young
2007-11-02 10:36 ` [PATCH 10 of 20] Move kvm_get & kmv_set_lapci functions " Jerone Young
2007-11-02 10:36 ` [PATCH 11 of 20] Make functions in libkvm.c nonstatic Jerone Young
2007-11-02 10:36 ` [PATCH 12 of 20] Move abi 10 functions to libkvm-x86.c Jerone Young
2007-11-02 10:36 ` [PATCH 13 of 20] Move msrs " Jerone Young
2007-11-02 10:36 ` [PATCH 14 of 20] Move print_seg & Move kvm_show_regs to kvmctl-x86.c Jerone Young
2007-11-02 10:36 ` [PATCH 15 of 20] Declare kvm_abi as a global variable in libkvm.h Jerone Young
2007-11-02 10:36 ` [PATCH 16 of 20] Move kvm_get_apic to libkvm-x86.c Jerone Young
2007-11-02 10:36 ` [PATCH 17 of 20] Move cr8 functions " Jerone Young
2007-11-02 10:36 ` [PATCH 18 of 20] Move kvm_setup_cpuid " Jerone Young
2007-11-02 10:36 ` [PATCH 19 of 20] Move kvm_show_code " Jerone Young
2007-11-02 10:36 ` [PATCH 20 of 20] Remove unsued inclusion of linux/kvm_parah.h in userspace libkvm.h Jerone Young
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=c66785783d56c9aa034d.1193999802@thinkpad \
--to=jyoung5-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.