Get oprofile working more correctly.
[akaros.git] / kern / drivers / dev / vm.c
index f331b84..3067594 100644 (file)
@@ -61,6 +61,15 @@ static int vmok = 0;
 static spinlock_t vmidlock[1];
 static struct kref vmid[1] = { {(void *)1, fake_release} };
 
+/* not clear what .h to put these in. Put them here. */
+
+struct litevm *vmx_open(void);
+int vmx_create_vcpu(struct litevm *litevm, int n);
+int vmx_init(void);
+int vm_set_memory_region(struct litevm *litevm,
+                                                struct litevm_memory_region *mem);
+int vm_run(struct litevm *litevm, struct litevm_run *litevm_run);
+
 static inline struct vm *
 QID2VM(struct qid q)
 {
@@ -91,7 +100,7 @@ static void readn(struct chan *c, void *vp, long n)
                nn = devtab[c->type].read(c, p, n, c->offset);
                printk("readn: Got %d@%lld\n", nn, c->offset);
                if (nn == 0)
-                       error("%s: wanted %d, got %d", Eshort, total, want);
+                       error("%s: wanted %d, got %d", Eshort, want, total);
                c->offset += nn;
                p += nn;
                n -= nn;
@@ -445,7 +454,9 @@ static long vmwrite(struct chan *c, void *ubuf, long n, int64_t unused)
                                vmr.vcpu = strtoul(cb->f[1], NULL, 0);
                                vmr.emulated = strtoul(cb->f[2], NULL, 0);
                                vmr.mmio_completed = strtoul(cb->f[3], NULL, 0);
+                               disable_irq();
                                ret = vm_run(litevm, &vmr);
+                               enable_irq();
                                printk("vm_run returns %d\n", ret);
                                //print_func_exit();
                                return ret;
@@ -507,6 +518,7 @@ static long vmwrite(struct chan *c, void *ubuf, long n, int64_t unused)
                                vmr.flags = strtoul(cb->f[2], NULL, 0);
                                vmr.guest_phys_addr = strtoul(cb->f[3], NULL, 0);
                                vmr.memory_size = strtoul(cb->f[4], NULL, 0);
+                               vmr.init_data = NULL;
                                if (vm_set_memory_region(litevm, &vmr))
                                        error("vm_set_memory_region failed");
                        } else {