aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUri Lublin <uril@qumranet.com>2007-03-15 14:57:16 +0000
committerUri Lublin <uril@qumranet.com>2007-03-15 14:57:16 +0000
commit60019c339da62ad488f2101c47a01a82c114b0fb (patch)
tree5e498ef4e5cf5fe8713783fa2b97ec6c0ea9fda7
parent91a6dd3909bfc006d0c69ec54f5401cc4d209334 (diff)
user: if KVM_GET_MEM_MAP is not defined, fake kvm_get_mem_map()
The fake is to set the bits of all pages of the slot (no holes in the memory). This overcomes compilation problems caused by KVM_GET_MEM_MAP definition (and ioctl implementation) not making it to the master git tree, yet. see also r4533
-rw-r--r--kvm/user/kvmctl.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/kvm/user/kvmctl.c b/kvm/user/kvmctl.c
index f9644fb77..e7d1beb65 100644
--- a/kvm/user/kvmctl.c
+++ b/kvm/user/kvmctl.c
@@ -351,7 +351,27 @@ int kvm_get_dirty_pages(kvm_context_t kvm, int slot, void *buf)
int kvm_get_mem_map(kvm_context_t kvm, int slot, void *buf)
{
+#ifdef KVM_GET_MEM_MAP
return kvm_get_map(kvm, KVM_GET_MEM_MAP, slot, buf);
+#else /* not KVM_GET_MEM_MAP ==> fake it: all pages exist */
+ unsigned long i, n, m, npages;
+ unsigned char v;
+
+ if (slot >= KVM_MAX_NUM_MEM_REGIONS) {
+ errno = -EINVAL;
+ return -1;
+ }
+ npages = kvm->mem_regions[slot].memory_size / PAGE_SIZE;
+ n = npages / 8;
+ m = npages % 8;
+ memset(buf, 0xff, n); /* all pages exist */
+ v = 0;
+ for (i=0; i<=m; i++) /* last byte may not be "aligned" */
+ v |= 1<<(7-i);
+ if (v)
+ *(unsigned char*)(buf+n) = v;
+ return 0;
+#endif /* KVM_GET_MEM_MAP */
}
static int more_io(struct kvm_run *run, int first_time)