[PATCH 1/9] add debuging facilities to memory registration at libkvm

Glauber Costa
2008-08-13T00:52:42Z

libkvm/libkvm.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c
index 5edfad7..0bacb43 100644
--- a/libkvm/libkvm.c
+++ b/libkvm/libkvm.c
@@ -52,6 +52,8 @@
#include "kvm-s390.h"
#endif

+//#define DEBUG_MEMREG
+
int kvm_abi = EXPECTED_KVM_API_VERSION;
int kvm_page_size;

@@ -548,6 +550,12 @@ int kvm_create_mem_hole(kvm_context_t kvm, unsigned long phys_start,
}
free_slot(slot);

+#ifdef DEBUG_MEMREG
+ printf("%s, newslot1: gpa: %llx, size: %llx, uaddr: %llx, slot: %x, flags: %lx\n",
+ __func__, newslot1.guest_phys_addr, newslot1.memory_size,
+ newslot1.userspace_addr, newslot1.slot, newslot1.flags);
+#endif
+
r = ioctl(kvm->vm_fd, KVM_SET_USER_MEMORY_REGION, &newslot1);
if (r == -1) {
fprintf(stderr, "kvm_create_mem_hole: %s\n", strerror(errno));
@@ -557,6 +565,11 @@ int kvm_create_mem_hole(kvm_context_t kvm, unsigned long phys_start,
newslot1.memory_size, 1, newslot1.userspace_addr,
newslot1.flags);

+#ifdef DEBUG_MEMREG
+ printf("%s, newslot2: gpa: %llx, size: %llx, uaddr: %llx, slot: %x, flags: %lx\n",
+ __func__, newslot2.guest_phys_addr, newslot2.memory_size,
+ newslot2.userspace_addr, newslot2.slot, newslot2.flags);
+#endif
r = ioctl(kvm->vm_fd, KVM_SET_USER_MEMORY_REGION, &newslot2);
if (r == -1) {
fprintf(stderr, "kvm_create_mem_hole: %s\n", strerror(errno));
@@ -584,6 +597,11 @@ int kvm_register_userspace_phys_mem(kvm_context_t kvm,
int r;

memory.slot = get_free_slot(kvm);
+#ifdef DEBUG_MEMREG
+ printf("%s, memory: gpa: %llx, size: %llx, uaddr: %llx, slot: %x, flags: %lx\n",
+ __func__, memory.guest_phys_addr, memory.memory_size,
+ memory.userspace_addr, memory.slot, memory.flags);
+#endif
r = ioctl(kvm->vm_fd, KVM_SET_USER_MEMORY_REGION, &memory);
if (r == -1) {
fprintf(stderr, "create_userspace_phys_mem: %s\n", strerror(errno));
--
1.5.5.1