Skip to contentSkip to conversation

KVM failing to compile with --disable-kvm

PATCH In review Glauber Costa 2 participants 7 messages Oct 2, 2008 KVM

lore
Share & tools
lore
#0 lore raw

cover KVM failing to compile with --disable-kvm

Father Avi,

is it better now?

#1 lore raw

PATCH 1/2 provide a kvm_qemu_memory_alias() function

Following the pattern we already do, provide a qemu_kvm wrapper to the memory aliases x86 functions. Reason is that we don't want to have references to the context spread over qemu.

The destroy alias function is completely removed from libkvm/libkvm.c, since no one in the code base uses it directly.

---
 qemu/qemu-kvm-x86.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
qemu/qemu-kvm-x86.c +12 -0
index 5daedd1..9390a40 100644
@@ -27,6 +27,18 @@ static int kvm_has_msr_star;
 
 static int lm_capable_kernel;
 
+int kvm_qemu_create_memory_alias(uint64_t phys_start,
+                                 uint64_t len,
+                                 uint64_t target_phys)
+{
+    return kvm_create_memory_alias(kvm_context, phys_start, len, target_phys);
+}
+
+int kvm_qemu_destroy_memory_alias(uint64_t phys_start)
+{
+	return kvm_destroy_memory_alias(kvm_context, phys_start);
+}
+
 int kvm_arch_qemu_create_context(void)
 {
     int i;
Signature · 1 line
1.5.5.1
#2 lore raw

PATCH 2/2 fix compilation with --disable-kvm

In reply to Glauber Costa

Currently, kvm is failing to build with --disable-kvm. this patch fixes the issue.

---
 qemu/gdbstub.c       |   15 ++++++++++-----
 qemu/hw/acpi.c       |    6 +++++-
 qemu/hw/cirrus_vga.c |    7 +++----
 qemu/monitor.c       |    6 ++++--
 4 files changed, 22 insertions(+), 12 deletions(-)
qemu/gdbstub.c +10 -5
index d57cd61..d65f1cf 100644
@@ -994,10 +994,12 @@ static int gdb_handle_packet(GDBState *s, CPUState *env, const char *line_buf)
             addr = strtoull(p, (char **)&p, 16);
 #if defined(TARGET_I386)
             env->eip = addr;
-            kvm_load_registers(env);
+            if (kvm_enabled())
+                kvm_load_registers(env);
 #elif defined (TARGET_PPC)
             env->nip = addr;
-            kvm_load_registers(env);
+            if (kvm_enabled())
+                kvm_load_registers(env);
 #elif defined (TARGET_SPARC)
             env->pc = addr;
             env->npc = addr + 4;
@@ -1033,7 +1035,8 @@ static int gdb_handle_packet(GDBState *s, CPUState *env, const char *line_buf)
             addr = strtoull(p, (char **)&p, 16);
 #if defined(TARGET_I386)
             env->eip = addr;
-            kvm_load_registers(env);
+            if (kvm_enabled())
+                kvm_load_registers(env);
 #elif defined (TARGET_PPC)
             env->nip = addr;
             kvm_load_registers(env);
@@ -1078,7 +1081,8 @@ static int gdb_handle_packet(GDBState *s, CPUState *env, const char *line_buf)
         }
         break;
     case 'g':
-        kvm_save_registers(env);
+        if (kvm_enabled())
+            kvm_save_registers(env);
         reg_size = cpu_gdb_read_registers(env, mem_buf);
         memtohex(buf, mem_buf, reg_size);
         put_packet(s, buf);
@@ -1088,7 +1092,8 @@ static int gdb_handle_packet(GDBState *s, CPUState *env, const char *line_buf)
         len = strlen(p) / 2;
         hextomem((uint8_t *)registers, p, len);
         cpu_gdb_write_registers(env, mem_buf, len);
-        kvm_load_registers(env);
+        if (kvm_enabled())
+            kvm_load_registers(env);
         put_packet(s, "OK");
         break;
     case 'm':
qemu/hw/acpi.c +5 -1
index 05f5dc0..a51fcb7 100644
@@ -726,7 +726,11 @@ void qemu_system_cpu_hot_add(int cpu, int state)
 {
     CPUState *env;
 
-    if ((state) && (!qemu_kvm_cpu_env(cpu))) {
+    if (state 
+#ifdef USE_KVM
+        && (!qemu_kvm_cpu_env(cpu))
+#endif
+    ) {
         env = pc_new_cpu(cpu, model, 1);
         if (!env) {
             fprintf(stderr, "cpu %d creation failed\n", cpu);
qemu/hw/cirrus_vga.c +3 -4
index 4f3aef9..dac0731 100644
@@ -2677,14 +2677,13 @@ static void kvm_update_vga_alias(CirrusVGAState *s, int ok, int bank)
 	if (!s->aliases_enabled
 	    || base != s->aliased_bank_base[bank]
 	    || limit != s->aliased_bank_limit[bank]) {
-	    kvm_create_memory_alias(kvm_context,
-				    0xa0000 + bank * 0x8000,
-				    limit, base);
+	    kvm_qemu_create_memory_alias(0xa0000 + bank * 0x8000,
+                                     limit, base);
 	    s->aliased_bank_base[bank] = base;
 	    s->aliased_bank_limit[bank] = limit;
 	}
     } else {
-	kvm_destroy_memory_alias(kvm_context, 0xa0000 + bank * 0x8000);
+	kvm_qemu_destroy_memory_alias(0xa0000 + bank * 0x8000);
     }
 }
 
qemu/monitor.c +4 -2
index d6b3da6..97b5cbe 100644
@@ -292,7 +292,8 @@ static CPUState *mon_get_cpu(void)
         mon_set_cpu(0);
     }
 
-    kvm_save_registers(mon_cpu);
+    if (kvm_enabled())
+        kvm_save_registers(mon_cpu);
 
     return mon_cpu;
 }
@@ -320,7 +321,8 @@ static void do_info_cpus(void)
     mon_get_cpu();
 
     for(env = first_cpu; env != NULL; env = env->next_cpu) {
-        kvm_save_registers(env);
+        if (kvm_enabled())
+            kvm_save_registers(env);
         term_printf("%c CPU #%d:",
                     (env == mon_cpu) ? '*' : ' ',
                     env->cpu_index);
Signature · 1 line
1.5.5.1
#3 lore raw

Re: [PATCH 2/2] fix compilation with --disable-kvm

qemu/monitor.c static CPUState *mon_get_cpu(void) · line 296

Quoted 6 lines · Glauber Costa
qemu/monitor.c +2 -1
-    kvm_save_registers(mon_cpu);
+    if (kvm_enabled())
+        kvm_save_registers(mon_cpu);

If I'm not mistaken, this relies on the optimizer to remove the call to kvm_save_registers(). Compilation with -O0 will break.

I think a better solution is to have kvm_save_registers() contain the kvm_enabled() check, and also be defined to an empty function if kvm is disabled at compile time.

Signature · 1 line
error compiling committee.c: too many arguments to function
#4 lore raw

Re: [PATCH 2/2] fix compilation with --disable-kvm

Quoted 6 lines · Avi Kivity

qemu/monitor.c static CPUState *mon_get_cpu(void) · line 296

Quoted 4 lines · Glauber Costa

- kvm_save_registers(mon_cpu);

qemu/monitor.c +2 -0
+    if (kvm_enabled())
+        kvm_save_registers(mon_cpu);
Quoted 6 lines

If I'm not mistaken, this relies on the optimizer to remove the call to kvm_save_registers(). Compilation with -O0 will break.

I think a better solution is to have kvm_save_registers() contain the kvm_enabled() check, and also be defined to an empty function if kvm is disabled at compile time.

ok master. Will redo.

Quoted 4 lines
Signature · 2 lines
-- 
error compiling committee.c: too many arguments to function
#5 lore raw

Re: [PATCH 2/2] fix compilation with --disable-kvm

Quoted 9 lines · Glauber Costa
Quoted 7 lines · Avi Kivity
Quoted 5 lines · Glauber Costa

- kvm_save_registers(mon_cpu);

qemu/monitor.c +2 -0
+    if (kvm_enabled())
+        kvm_save_registers(mon_cpu);
Quoted 6 lines
Quoted 4 lines

If I'm not mistaken, this relies on the optimizer to remove the call to kvm_save_registers(). Compilation with -O0 will break.

I think a better solution is to have kvm_save_registers() contain the kvm_enabled() check, and also be defined to an empty function if kvm is disabled at compile time.

ok master. Will redo.

I applied it already (since it fixes an issue), so base it on kvm-userspace.git (once I push).

Signature · 1 line
error compiling committee.c: too many arguments to function
#6 lore raw
In reply to Glauber Costa
Quoted 5 lines · Glauber Costa

Father Avi,

is it better now?

Yes, applied. thanks.

Signature · 1 line
error compiling committee.c: too many arguments to function