public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* qemu-kvm
@ 2006-11-14  7:26 Baruch Even
       [not found] ` <20061114072601.GD28027-xGn4Jn0woyz+OtfAA3OxFg@public.gmane.org>
  0 siblings, 1 reply; 19+ messages in thread
From: Baruch Even @ 2006-11-14  7:26 UTC (permalink / raw)
  To: KVM

Can the Qemu built with KVM support run without KVM? Froma quick perusal
of the kvm.patch it seems that there are places where USE_KVM implies a
qemu-panic without any runtime conditionals.

I'd like to push the KVM patches to Debian Qemu and need to know if they
need to create new executables or just continue to build the existing
ones. To me it seems the former.

Cheers,
Baruch

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: qemu-kvm
       [not found] ` <20061114072601.GD28027-xGn4Jn0woyz+OtfAA3OxFg@public.gmane.org>
@ 2006-11-14  8:28   ` Simon Kagstrom
  2006-11-14  8:50   ` qemu-kvm Avi Kivity
  1 sibling, 0 replies; 19+ messages in thread
From: Simon Kagstrom @ 2006-11-14  8:28 UTC (permalink / raw)
  To: Baruch Even; +Cc: KVM

At Tue, 14 Nov 2006 09:26:01 +0200,
Baruch Even wrote:
> 
> Can the Qemu built with KVM support run without KVM? Froma quick perusal
> of the kvm.patch it seems that there are places where USE_KVM implies a
> qemu-panic without any runtime conditionals.

There is the -no-kvm option which you can pass when starting qemu.

// Simon

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: qemu-kvm
       [not found] ` <20061114072601.GD28027-xGn4Jn0woyz+OtfAA3OxFg@public.gmane.org>
  2006-11-14  8:28   ` qemu-kvm Simon Kagstrom
@ 2006-11-14  8:50   ` Avi Kivity
       [not found]     ` <4559834F.80905-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
  1 sibling, 1 reply; 19+ messages in thread
From: Avi Kivity @ 2006-11-14  8:50 UTC (permalink / raw)
  To: Baruch Even; +Cc: KVM

Baruch Even wrote:
> Can the Qemu built with KVM support run without KVM? Froma quick perusal
> of the kvm.patch it seems that there are places where USE_KVM implies a
> qemu-panic without any runtime conditionals.
>   

qemu-kvm.patch is an older release.  With the new release, it should be 
possible to run without kvm.  Let me know (or better, send patches) if 
there are any such places in kvm-2.

> I'd like to push the KVM patches to Debian Qemu and need to know if they
> need to create new executables or just continue to build the existing
> ones. To me it seems the former.
>
>   




-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: qemu-kvm
       [not found]     ` <4559834F.80905-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
@ 2006-11-14  9:28       ` Simon Kagstrom
       [not found]         ` <8764di9y30.wl%simon.kagstrom-6Uc+yI3S9P8@public.gmane.org>
  0 siblings, 1 reply; 19+ messages in thread
From: Simon Kagstrom @ 2006-11-14  9:28 UTC (permalink / raw)
  To: Avi Kivity; +Cc: KVM, Baruch Even

At Tue, 14 Nov 2006 10:50:23 +0200,
Avi Kivity wrote:
> 
> Baruch Even wrote:
> > Can the Qemu built with KVM support run without KVM? Froma quick perusal
> > of the kvm.patch it seems that there are places where USE_KVM implies a
> > qemu-panic without any runtime conditionals.
> 
> qemu-kvm.patch is an older release.  With the new release, it should be 
> possible to run without kvm.  Let me know (or better, send patches) if 
> there are any such places in kvm-2.

One thing I've thought about (and quickly hacked on) is to "detect"
the presense of KVM and use it if it is there and use "plain" qemu if
it is not. The question is if this is behavior that the rest of you
would like, I'll send a patch if so.

One thing which I've changed is to return errors from libkvm instead
of directly exiting. Personally I think this behavior is preferred
since it does not force decisions upon the program using the library.

// Simon

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: qemu-kvm
       [not found]         ` <8764di9y30.wl%simon.kagstrom-6Uc+yI3S9P8@public.gmane.org>
@ 2006-11-14  9:35           ` Baruch Even
       [not found]             ` <20061114093537.GH28027-xGn4Jn0woyz+OtfAA3OxFg@public.gmane.org>
  2006-11-14  9:41           ` qemu-kvm Avi Kivity
  1 sibling, 1 reply; 19+ messages in thread
From: Baruch Even @ 2006-11-14  9:35 UTC (permalink / raw)
  To: Simon Kagstrom; +Cc: KVM

* Simon Kagstrom <simon.kagstrom-6Uc+yI3S9P8@public.gmane.org> [061114 11:30]:
> At Tue, 14 Nov 2006 10:50:23 +0200,
> Avi Kivity wrote:
> > 
> > Baruch Even wrote:
> > > Can the Qemu built with KVM support run without KVM? Froma quick perusal
> > > of the kvm.patch it seems that there are places where USE_KVM implies a
> > > qemu-panic without any runtime conditionals.
> > 
> > qemu-kvm.patch is an older release.  With the new release, it should be 
> > possible to run without kvm.  Let me know (or better, send patches) if 
> > there are any such places in kvm-2.
> 
> One thing I've thought about (and quickly hacked on) is to "detect"
> the presense of KVM and use it if it is there and use "plain" qemu if
> it is not. The question is if this is behavior that the rest of you
> would like, I'll send a patch if so.

That would be best IMO. In this way qemu will just work and it can run
(much?) faster if the user has kvm. Though this means some loss in
branding for kvm as users are less likely to know they are running under
kvm.

In usch a mode the user should be notified if KVM is not found and if
KVM is found but the machine doesn't have VT support. Though I guess the
KVM module will fail to load if there is no VT support in the CPU.

Cheers,
Baruch

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: qemu-kvm
       [not found]         ` <8764di9y30.wl%simon.kagstrom-6Uc+yI3S9P8@public.gmane.org>
  2006-11-14  9:35           ` qemu-kvm Baruch Even
@ 2006-11-14  9:41           ` Avi Kivity
       [not found]             ` <45598F42.5090400-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
  1 sibling, 1 reply; 19+ messages in thread
From: Avi Kivity @ 2006-11-14  9:41 UTC (permalink / raw)
  To: Simon Kagstrom; +Cc: KVM, Baruch Even

Simon Kagstrom wrote:
> At Tue, 14 Nov 2006 10:50:23 +0200,
> Avi Kivity wrote:
>   
>> Baruch Even wrote:
>>     
>>> Can the Qemu built with KVM support run without KVM? Froma quick perusal
>>> of the kvm.patch it seems that there are places where USE_KVM implies a
>>> qemu-panic without any runtime conditionals.
>>>       
>> qemu-kvm.patch is an older release.  With the new release, it should be 
>> possible to run without kvm.  Let me know (or better, send patches) if 
>> there are any such places in kvm-2.
>>     
>
> One thing I've thought about (and quickly hacked on) is to "detect"
> the presense of KVM and use it if it is there and use "plain" qemu if
> it is not. The question is if this is behavior that the rest of you
> would like, I'll send a patch if so.
>   

I think it is indeed desirable.  Please send the patch.

Of course, -no-kvm should not use kvm even if it there.


> One thing which I've changed is to return errors from libkvm instead
> of directly exiting. Personally I think this behavior is preferred
> since it does not force decisions upon the program using the library.
>   

The exit()s are a hack, of course.


-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH] 1/2: Fall back to plain Qemu if KVM is not present, report errors from libkvm
       [not found]             ` <20061114093537.GH28027-xGn4Jn0woyz+OtfAA3OxFg@public.gmane.org>
@ 2006-11-14 10:30               ` Simon Kagstrom
  0 siblings, 0 replies; 19+ messages in thread
From: Simon Kagstrom @ 2006-11-14 10:30 UTC (permalink / raw)
  To: KVM; +Cc: Baruch Even

[-- Attachment #1: Type: text/plain, Size: 303 bytes --]

This patch to libkvm returns error values from kvm_init and
kvm_create. It also adds a kvm_finalize to close /dev/kvm and cleanup
the kvm context.

Error messages are now printed on stderr and handle_io has been made
static.

Signed-off-by: Simon Kagstrom <simon.kagstrom-6Uc+yI3S9P8@public.gmane.org>


[-- Attachment #2: libkvm-report-errors.patch --]
[-- Type: application/octet-stream, Size: 5835 bytes --]

diff -u ../orig/kvm-2/user/kvmctl.c user/kvmctl.c
--- ../orig/kvm-2/user/kvmctl.c	2006-10-09 15:24:53.000000000 +0200
+++ user/kvmctl.c	2006-11-14 11:27:09.000000000 +0100
@@ -61,8 +61,8 @@
 
 	fd = open("/dev/kvm", O_RDWR);
 	if (fd == -1) {
-		printf("open: %m\n");
-		exit(1);
+		perror("open");
+		return NULL;
 	}
 	kvm = malloc(sizeof(*kvm));
 	kvm->fd = fd;
@@ -71,6 +71,12 @@
 	return kvm;
 }
 
+void kvm_finalize(kvm_context_t kvm)
+{
+	close(kvm->fd);
+	free(kvm);
+}
+
 int kvm_create(kvm_context_t kvm, unsigned long memory, void **vm_mem)
 {
 	unsigned long dosmem = 0xa0000;
@@ -91,28 +97,28 @@
 	/* 640K should be enough. */
 	r = ioctl(fd, KVM_SET_MEMORY_REGION, &low_memory);
 	if (r == -1) {
-		printf("kvm_create_memory_region: %m\n");
-		exit(1);
+		fprintf(stderr, "kvm_create_memory_region: %m\n");
+		return -1;
 	}
 	if (extended_memory.memory_size) {
 		r = ioctl(fd, KVM_SET_MEMORY_REGION, &extended_memory);
 		if (r == -1) {
-			printf("kvm_create_memory_region: %m\n");
-			exit(1);
+			fprintf(stderr, "kvm_create_memory_region: %m\n");
+			return -1;
 		}
 	}
 
 	*vm_mem = mmap(0, memory, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
 	if (*vm_mem == MAP_FAILED) {
-		printf("mmap: %m\n");
-		exit(1);
+		fprintf(stderr, "mmap: %m\n");
+		return -1;
 	}
 	kvm->physical_memory = *vm_mem;
 
 	r = ioctl(fd, KVM_CREATE_VCPU, 0);
 	if (r == -1) {
-		printf("kvm_create_vcpu: %m\n");
-		exit(1);
+		fprintf(stderr, "kvm_create_vcpu: %m\n");
+		return -1;
 	}
 	return 0;
 }
@@ -174,7 +180,7 @@
 		return run->io.count != 0;
 }
 
-int handle_io(kvm_context_t kvm, struct kvm_run *run)
+static int handle_io(kvm_context_t kvm, struct kvm_run *run)
 {
 	uint16_t addr = run->io.port;
 	struct kvm_regs regs;
@@ -199,8 +205,8 @@
 			r = translate(kvm, run->vcpu, &tr, run->io.address, 
 				      &value_addr);
 			if (r) {
-				printf("failed translating I/O address %x\n",
-				       run->io.address);
+				fprintf(stderr, "failed translating I/O address %x\n",
+					run->io.address);
 				exit(1);
 			}
 		}
@@ -227,7 +233,7 @@
 				break;
 			}
 			default:
-				printf("bad I/O size\n");
+				fprintf(stderr, "bad I/O size\n");
 				exit(1);
 			}
 			break;
@@ -247,12 +253,12 @@
 						     *(uint32_t *)value_addr);
 				break;
 			default:
-				printf("bad I/O size\n");
+				fprintf(stderr, "bad I/O size\n");
 				exit(1);
 			}
 			break;
 		default:
-			printf("bad I/O size\n");
+			fprintf(stderr, "bad I/O size\n");
 			exit(1);
 		}
 		if (run->io.string) {
@@ -319,16 +325,17 @@
 		perror("KVM_GET_REGS");
 		exit(1);
 	}
-	printf("rax %016llx rbx %016llx rcx %016llx rdx %016llx\n"
-	       "rsi %016llx rdi %016llx rsp %016llx rbp %016llx\n"
-	       "r8  %016llx r9  %016llx r10 %016llx r11 %016llx\n"
-	       "r12 %016llx r13 %016llx r14 %016llx r15 %016llx\n"
-	       "rip %016llx rflags %08llx\n",
-	       regs.rax, regs.rbx, regs.rcx, regs.rdx,
-	       regs.rsi, regs.rdi, regs.rsp, regs.rbp,
-	       regs.r8,  regs.r9,  regs.r10, regs.r11,
-	       regs.r12, regs.r13, regs.r14, regs.r15,
-	       regs.rip, regs.rflags);
+	fprintf(stderr,
+		"rax %016llx rbx %016llx rcx %016llx rdx %016llx\n"
+		"rsi %016llx rdi %016llx rsp %016llx rbp %016llx\n"
+		"r8  %016llx r9  %016llx r10 %016llx r11 %016llx\n"
+		"r12 %016llx r13 %016llx r14 %016llx r15 %016llx\n"
+		"rip %016llx rflags %08llx\n",
+		regs.rax, regs.rbx, regs.rcx, regs.rdx,
+		regs.rsi, regs.rdi, regs.rsp, regs.rbp,
+		regs.r8,  regs.r9,  regs.r10, regs.r11,
+		regs.r12, regs.r13, regs.r14, regs.r15,
+		regs.rip, regs.rflags);
 }
 
 static int handle_cpuid(kvm_context_t kvm, struct kvm_run *run)
@@ -423,20 +430,20 @@
 	}
 	switch (kvm_run.exit_type) {
 	case KVM_EXIT_TYPE_FAIL_ENTRY:
-		printf("kvm_run: failed entry, reason %u\n", 
-		       kvm_run.exit_reason & 0xffff);
+		fprintf(stderr, "kvm_run: failed entry, reason %u\n", 
+			kvm_run.exit_reason & 0xffff);
 		exit(1);
 		break;
 	case KVM_EXIT_TYPE_VM_EXIT:
 		switch (kvm_run.exit_reason) {
 		case KVM_EXIT_UNKNOWN:
-			printf("unhandled vm exit:  0x%x\n", 
+			fprintf(stderr, "unhandled vm exit:  0x%x\n", 
 			       kvm_run.hw.hardware_exit_reason);
 			kvm_show_regs(kvm, vcpu);
 			abort();
 			break;
 		case KVM_EXIT_EXCEPTION:
-			printf("exception %d (%x)\n", 
+			fprintf(stderr, "exception %d (%x)\n", 
 			       kvm_run.ex.exception,
 			       kvm_run.ex.error_code);
 			abort();
@@ -457,7 +464,7 @@
 			r = handle_halt(kvm, &kvm_run);
 			break;
 		default:
-			printf("unhandled vm exit: 0x%x\n", kvm_run.exit_reason);
+			fprintf(stderr, "unhandled vm exit: 0x%x\n", kvm_run.exit_reason);
 			kvm_show_regs(kvm, vcpu);
 			abort();
 			break;
diff -u ../orig/kvm-2/user/kvmctl.h user/kvmctl.h
--- ../orig/kvm-2/user/kvmctl.h	2006-10-22 11:39:42.000000000 +0200
+++ user/kvmctl.h	2006-11-14 11:02:54.000000000 +0100
@@ -31,8 +31,11 @@
     int (*io_window)(void *opaque);
 };
 
+/* Create a new kvm context */
 kvm_context_t kvm_init(struct kvm_callbacks *callbacks,
 		       void *opaque);
+/* Cleanup the kvm context */
+void kvm_finalize(kvm_context_t kvm);
 int kvm_create(kvm_context_t kvm,
 	       unsigned long phys_mem_bytes,
 	       void **phys_mem);
diff -u ../orig/kvm-2/user/main.c user/main.c
--- ../orig/kvm-2/user/main.c	2006-10-23 12:48:50.000000000 +0200
+++ user/main.c	2006-11-14 11:13:46.000000000 +0100
@@ -120,7 +120,15 @@
 	void *vm_mem;
 
 	kvm = kvm_init(&test_callbacks, 0);
-	kvm_create(kvm, 128 * 1024 * 1024, &vm_mem);
+	if (!kvm) {
+	    fprintf(stderr, "kvm_init failed\n");
+	    return 1;
+	}
+	if (kvm_create(kvm, 128 * 1024 * 1024, &vm_mem) < 0) {
+	    kvm_finalize(kvm);
+	    fprintf(stderr, "kvm_create failed\n");
+	    return 1;
+	}
 	if (ac > 1)
 	    load_file(vm_mem + 0xf0000, av[1]);
 	if (ac > 2)
@@ -128,4 +136,6 @@
 	kvm_show_regs(kvm, 0);
 
 	kvm_run(kvm, 0);
+
+	return 0;
 }

[-- Attachment #3: Type: text/plain, Size: 373 bytes --]

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

[-- Attachment #4: Type: text/plain, Size: 186 bytes --]

_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH] 2/2: Fall back to plain Qemu if KVM is not present, report errors from libkvm
       [not found]             ` <45598F42.5090400-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
@ 2006-11-14 10:36               ` Simon Kagstrom
       [not found]                 ` <871wo69uxb.wl%simon.kagstrom-6Uc+yI3S9P8@public.gmane.org>
  0 siblings, 1 reply; 19+ messages in thread
From: Simon Kagstrom @ 2006-11-14 10:36 UTC (permalink / raw)
  To: KVM; +Cc: Baruch Even

[-- Attachment #1: Type: text/plain, Size: 193 bytes --]

This patch implements fall-back to plain Qemu if KVM is not
present. Some logic has been moved into kvm_qemu_init.

Signed-off-by: Simon Kagstrom <simon.kagstrom-6Uc+yI3S9P8@public.gmane.org>


[-- Attachment #2: qemu-kvm-start-transparent.patch --]
[-- Type: application/octet-stream, Size: 2651 bytes --]

diff -u ../orig/kvm-2/qemu/qemu-kvm.c qemu/qemu-kvm.c
--- ../orig/kvm-2/qemu/qemu-kvm.c	2006-11-05 10:18:52.000000000 +0100
+++ qemu/qemu-kvm.c	2006-11-14 11:04:19.000000000 +0100
@@ -450,10 +450,20 @@
     .io_window = kvm_io_window,
 };
 
-void kvm_qemu_init()
+int kvm_qemu_init()
 {
+    /* Try to initialize kvm */
     kvm_context = kvm_init(&qemu_kvm_ops, saved_env);
-    kvm_create(kvm_context, phys_ram_size, (void**)&phys_ram_base);
+    if (!kvm_context) {
+      	return -1;
+    }
+    phys_ram_size += KVM_EXTRA_PAGES * 4096;
+    if (kvm_create(kvm_context, phys_ram_size, (void**)&phys_ram_base) < 0) {
+	kvm_finalize(kvm_context);
+	return -1;
+    }
+
+    return 0;
 }
 
 int kvm_update_debugger(CPUState *env)
diff -u ../orig/kvm-2/qemu/qemu-kvm.h qemu/qemu-kvm.h
--- ../orig/kvm-2/qemu/qemu-kvm.h	2006-10-16 11:01:02.000000000 +0200
+++ qemu/qemu-kvm.h	2006-11-14 10:00:48.000000000 +0100
@@ -3,7 +3,9 @@
 
 #include "kvmctl.h"
 
-void kvm_qemu_init(void);
+#define KVM_EXTRA_PAGES 3
+
+int kvm_qemu_init(void);
 void kvm_load_registers(CPUState *env);
 int kvm_cpu_exec(CPUState *env);
 int kvm_update_debugger(CPUState *env);
diff -u ../orig/kvm-2/qemu/vl.c qemu/vl.c
--- ../orig/kvm-2/qemu/vl.c	2006-11-05 10:18:52.000000000 +0100
+++ qemu/vl.c	2006-11-14 11:07:17.000000000 +0100
@@ -6099,20 +6099,24 @@
     }
 
     /* init the memory */
-#if USE_KVM
     phys_ram_size = ram_size + vga_ram_size + bios_size;
+#if USE_KVM
+    /* Initialize kvm */
     if (kvm_allowed) {
-	    phys_ram_size += KVM_EXTRA_PAGES * 4096;
-	    kvm_qemu_init();
-    } else {
-	    phys_ram_base = qemu_vmalloc(phys_ram_size);
-	    if (!phys_ram_base) {
-		    fprintf(stderr, "Could not allocate physical memory\n");
-		    exit(1);
-	    }
+	if (kvm_qemu_init() < 0) {
+	    fprintf(stderr, "Could not initialize KVM\n");
+	    kvm_allowed = 0;
+	}
+    }
+    /* Fall back to normal qemu if KVM fails */
+    if (!kvm_allowed) {
+	phys_ram_base = qemu_vmalloc(phys_ram_size);
+	if (!phys_ram_base) {
+	    fprintf(stderr, "Could not allocate physical memory\n");
+	    exit(1);
+	}
     }
 #else
-    phys_ram_size = ram_size + vga_ram_size + bios_size;
     phys_ram_base = qemu_vmalloc(phys_ram_size);
     if (!phys_ram_base) {
         fprintf(stderr, "Could not allocate physical memory\n");
diff -u ../orig/kvm-2/qemu/vl.h qemu/vl.h
--- ../orig/kvm-2/qemu/vl.h	2006-11-05 10:18:52.000000000 +0100
+++ qemu/vl.h	2006-11-14 09:48:31.000000000 +0100
@@ -162,10 +162,6 @@
 #define BIOS_SIZE ((256 + 64) * 1024)
 #endif
 
-#if USE_KVM
-#define KVM_EXTRA_PAGES 3
-#endif
-
 /* keyboard/mouse support */
 
 #define MOUSE_EVENT_LBUTTON 0x01

[-- Attachment #3: Type: text/plain, Size: 373 bytes --]

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

[-- Attachment #4: Type: text/plain, Size: 186 bytes --]

_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] 2/2: Fall back to plain Qemu if KVM is not present, report errors from libkvm
       [not found]                 ` <871wo69uxb.wl%simon.kagstrom-6Uc+yI3S9P8@public.gmane.org>
@ 2006-11-14 11:44                   ` Avi Kivity
       [not found]                     ` <4559AC1F.9080304-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 19+ messages in thread
From: Avi Kivity @ 2006-11-14 11:44 UTC (permalink / raw)
  To: Simon Kagstrom; +Cc: KVM, Baruch Even

Simon Kagstrom wrote:
> This patch implements fall-back to plain Qemu if KVM is not
> present. Some logic has been moved into kvm_qemu_init.
>
> Signed-off-by: Simon Kagstrom <simon.kagstrom-6Uc+yI3S9P8@public.gmane.org>
>
>   
[please inline patches in the future for easier reviewing]

-#if USE_KVM
     phys_ram_size = ram_size + vga_ram_size + bios_size;
+#if USE_KVM
+    /* Initialize kvm */
     if (kvm_allowed) {
-	    phys_ram_size += KVM_EXTRA_PAGES * 4096;
-	    kvm_qemu_init();
-    } else {
-	    phys_ram_base = qemu_vmalloc(phys_ram_size);
-	    if (!phys_ram_base) {
-		    fprintf(stderr, "Could not allocate physical memory\n");
-		    exit(1);
-	    }
+	if (kvm_qemu_init() < 0) {
+	    fprintf(stderr, "Could not initialize KVM\n");
+	    kvm_allowed = 0;
+	}
+    }
+    /* Fall back to normal qemu if KVM fails */
+    if (!kvm_allowed) {
+	phys_ram_base = qemu_vmalloc(phys_ram_size);
+	if (!phys_ram_base) {
+	    fprintf(stderr, "Could not allocate physical memory\n");
+	    exit(1);
+	}
     }
 #else
-    phys_ram_size = ram_size + vga_ram_size + bios_size;



This bit is rather awkward, since it disabled kvm after it has been 
enabled.  It's a cleaner to never enable kvm_allowed in the first place 
(i.e. during argument parsing).

How about a

    int libkvm_init(kvm_libcontext_t *libcontext);
    void libkvm_exit(kvm_libcontext_t libcontext);
   
    int kvm_create(kvm_libcontext_t libcontext, kvm_context_t* vm);
    void kvm_destroy(kvm_context_t *vm);

at present, libkvm_init() can just call access(2) on /dev/kvm.  In the 
future, it is planned that open("/dev/kvm") will not create a VM (it 
just opens a communication channel to the driver), so that libkvm_init() 
will open the device and store the fd.

-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] 2/2: Fall back to plain Qemu if KVM is not present, report errors from libkvm
       [not found]                     ` <4559AC1F.9080304-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
@ 2006-11-14 12:08                       ` Simon Kagstrom
       [not found]                         ` <87y7qe8c43.wl%simon.kagstrom-6Uc+yI3S9P8@public.gmane.org>
  0 siblings, 1 reply; 19+ messages in thread
From: Simon Kagstrom @ 2006-11-14 12:08 UTC (permalink / raw)
  To: Avi Kivity; +Cc: KVM, Baruch Even

(I've edited the patch comments to show the reasoning)

At Tue, 14 Nov 2006 13:44:31 +0200,
Avi Kivity wrote:
>     /* Initialize kvm */
>     if (kvm_allowed) {
> 	if (kvm_qemu_init() < 0) {
> 	    fprintf(stderr, "Could not initialize KVM\n");
> 	    kvm_allowed = 0;
> 	}
>     }
>     /* Fall back to normal qemu if KVM fails */
>     if (!kvm_allowed) {
> 	phys_ram_base = qemu_vmalloc(phys_ram_size);
> 	if (!phys_ram_base) {
> 	    fprintf(stderr, "Could not allocate physical memory\n");
> 	    exit(1);
> 	}
>     }
>
> This bit is rather awkward, since it disabled kvm after it has been 
> enabled.  It's a cleaner to never enable kvm_allowed in the first place 
> (i.e. during argument parsing).

OK. My reasoning was this: qemu with KVM defaults to use kvm and
therefore tries to enable it (kvm_qemu_init), if it cannot be
initialized, it will disable it again.

I can submit a new patch where kvm_init and kvm_create is separated
and kvm_init is done at argument-parsing time if you like, but
personally I think this way is clearer :-)

> How about a
> 
>     int libkvm_init(kvm_libcontext_t *libcontext);
>     void libkvm_exit(kvm_libcontext_t libcontext);
>    
>     int kvm_create(kvm_libcontext_t libcontext, kvm_context_t* vm);
>     void kvm_destroy(kvm_context_t *vm);
> 
> at present, libkvm_init() can just call access(2) on /dev/kvm.  In the 
> future, it is planned that open("/dev/kvm") will not create a VM (it 
> just opens a communication channel to the driver), so that libkvm_init() 
> will open the device and store the fd.

Personally, I would prefer something like

   int kvm_open(kvm_t *kvm;)
   void kvm_close(kvm_t *kvm);

   int kvm_create_vm(kvm_t *kvm, kvm_context_t *vm);
   void kvm_destroy_vm(kvm_t *kvm, kvm_context_t *vm);

// Simon

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] 2/2: Fall back to plain Qemu if KVM is not present, report errors from libkvm
       [not found]                         ` <87y7qe8c43.wl%simon.kagstrom-6Uc+yI3S9P8@public.gmane.org>
@ 2006-11-14 12:24                           ` Avi Kivity
       [not found]                             ` <4559B574.5000000-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 19+ messages in thread
From: Avi Kivity @ 2006-11-14 12:24 UTC (permalink / raw)
  To: Simon Kagstrom; +Cc: KVM, Baruch Even

Simon Kagstrom wrote:
> (I've edited the patch comments to show the reasoning)
>
> At Tue, 14 Nov 2006 13:44:31 +0200,
> Avi Kivity wrote:
>   
>>     /* Initialize kvm */
>>     if (kvm_allowed) {
>> 	if (kvm_qemu_init() < 0) {
>> 	    fprintf(stderr, "Could not initialize KVM\n");
>> 	    kvm_allowed = 0;
>> 	}
>>     }
>>     /* Fall back to normal qemu if KVM fails */
>>     if (!kvm_allowed) {
>> 	phys_ram_base = qemu_vmalloc(phys_ram_size);
>> 	if (!phys_ram_base) {
>> 	    fprintf(stderr, "Could not allocate physical memory\n");
>> 	    exit(1);
>> 	}
>>     }
>>
>> This bit is rather awkward, since it disabled kvm after it has been 
>> enabled.  It's a cleaner to never enable kvm_allowed in the first place 
>> (i.e. during argument parsing).
>>     
>
> OK. My reasoning was this: qemu with KVM defaults to use kvm and
> therefore tries to enable it (kvm_qemu_init), if it cannot be
> initialized, it will disable it again.
>   

Yes, but it leads to code duplication (there's a qemu_vmalloc() outside 
USE_KVM). Also, if some code prior to this depended on kvm_allowed, it 
would be invalidated.

Best to set kvm_allowed once you're sure it's really allowed, and then 
don't touch it.

> I can submit a new patch where kvm_init and kvm_create is separated
> and kvm_init is done at argument-parsing time if you like, but
> personally I think this way is clearer :-)
>
>   
>> How about a
>>
>>     int libkvm_init(kvm_libcontext_t *libcontext);
>>     void libkvm_exit(kvm_libcontext_t libcontext);
>>    
>>     int kvm_create(kvm_libcontext_t libcontext, kvm_context_t* vm);
>>     void kvm_destroy(kvm_context_t *vm);
>>     

I meant kvm_destroy(kvm_context_t vm);

>> at present, libkvm_init() can just call access(2) on /dev/kvm.  In the 
>> future, it is planned that open("/dev/kvm") will not create a VM (it 
>> just opens a communication channel to the driver), so that libkvm_init() 
>> will open the device and store the fd.
>>     
>
> Personally, I would prefer something like
>
>    int kvm_open(kvm_t *kvm;)
>    void kvm_close(kvm_t *kvm);
>
>    int kvm_create_vm(kvm_t *kvm, kvm_context_t *vm);
>    void kvm_destroy_vm(kvm_t *kvm, kvm_context_t *vm);
>   

That means that if sizeof(kvm_t) changes, we need to recompile 
everything. With kvm_context_t and kvm_t as opaque pointers, we preserve 
binary compatibility when their definitions change.

-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] 2/2: Fall back to plain Qemu if KVM is not present, report errors from libkvm
       [not found]                             ` <4559B574.5000000-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
@ 2006-11-14 13:04                               ` Simon Kagstrom
       [not found]                                 ` <87wt5y89ik.wl%simon.kagstrom-6Uc+yI3S9P8@public.gmane.org>
  0 siblings, 1 reply; 19+ messages in thread
From: Simon Kagstrom @ 2006-11-14 13:04 UTC (permalink / raw)
  To: Avi Kivity; +Cc: KVM, Baruch Even

At Tue, 14 Nov 2006 14:24:20 +0200,
Avi Kivity wrote:
> Yes, but it leads to code duplication (there's a qemu_vmalloc() outside 
> USE_KVM). Also, if some code prior to this depended on kvm_allowed, it 
> would be invalidated.
> 
> Best to set kvm_allowed once you're sure it's really allowed, and then 
> don't touch it.

I've attached a new patch below. It's still setting kvm_allowed to 0
in two places - if kvm_qemu_init() fails and if the -no-kvm option is
passed, but it now does a kind of "try-and-see" and sets it to zero if
it fails. This is done regardless of if -no-kvm is passed or not.

I split initialization and creation of a vm in qemu-kvm.c.

The code duplication was there before, and I have not changed that.

> >> at present, libkvm_init() can just call access(2) on /dev/kvm.  In the 
> >> future, it is planned that open("/dev/kvm") will not create a VM (it 
> >> just opens a communication channel to the driver), so that libkvm_init() 
> >> will open the device and store the fd.
> >>     
> >
> > Personally, I would prefer something like
> >
> >    int kvm_open(kvm_t *kvm;)
> >    void kvm_close(kvm_t *kvm);
> >
> >    int kvm_create_vm(kvm_t *kvm, kvm_context_t *vm);
> >    void kvm_destroy_vm(kvm_t *kvm, kvm_context_t *vm);
> >   
> 
> That means that if sizeof(kvm_t) changes, we need to recompile 
> everything. With kvm_context_t and kvm_t as opaque pointers, we preserve 
> binary compatibility when their definitions change.

Sorry, true.

I was actually mostly thinking of the naming (I prefer the simpler
kvm_t).

// Simon

diff -u ../orig/kvm-2/qemu/qemu-kvm.c qemu/qemu-kvm.c
--- ../orig/kvm-2/qemu/qemu-kvm.c	2006-11-05 10:18:52.000000000 +0100
+++ qemu/qemu-kvm.c	2006-11-14 13:56:35.000000000 +0100
@@ -450,10 +450,30 @@
     .io_window = kvm_io_window,
 };
 
-void kvm_qemu_init()
+int kvm_qemu_init()
 {
+    /* Try to initialize kvm */
     kvm_context = kvm_init(&qemu_kvm_ops, saved_env);
-    kvm_create(kvm_context, phys_ram_size, (void**)&phys_ram_base);
+    if (!kvm_context) {
+      	return -1;
+    }
+
+    return 0;
+}
+
+int kvm_qemu_create_context(void)
+{
+    if (kvm_create(kvm_context, phys_ram_size, (void**)&phys_ram_base) < 0) {
+	kvm_qemu_destroy();
+	return -1;
+    }
+
+    return 0;
+}
+
+void kvm_qemu_destroy(void)
+{
+    kvm_finalize(kvm_context);
 }
 
 int kvm_update_debugger(CPUState *env)
diff -u ../orig/kvm-2/qemu/qemu-kvm.h qemu/qemu-kvm.h
--- ../orig/kvm-2/qemu/qemu-kvm.h	2006-10-16 11:01:02.000000000 +0200
+++ qemu/qemu-kvm.h	2006-11-14 13:55:56.000000000 +0100
@@ -3,7 +3,9 @@
 
 #include "kvmctl.h"
 
-void kvm_qemu_init(void);
+int kvm_qemu_init(void);
+int kvm_qemu_create_context(void);
+void kvm_qemu_destroy(void);
 void kvm_load_registers(CPUState *env);
 int kvm_cpu_exec(CPUState *env);
 int kvm_update_debugger(CPUState *env);
diff -u ../orig/kvm-2/qemu/vl.c qemu/vl.c
--- ../orig/kvm-2/qemu/vl.c	2006-11-05 10:18:52.000000000 +0100
+++ qemu/vl.c	2006-11-14 13:56:32.000000000 +0100
@@ -5706,6 +5706,10 @@
 
     nb_nics = 0;
     /* default mac address of the first network interface */
+#if USE_KVM
+    if (kvm_qemu_init() < 0)
+	kvm_allowed = 0;
+#endif
     
     optind = 1;
     for(;;) {
@@ -6099,11 +6103,15 @@
     }
 
     /* init the memory */
-#if USE_KVM
     phys_ram_size = ram_size + vga_ram_size + bios_size;
+#if USE_KVM
+    /* Initialize kvm */
     if (kvm_allowed) {
 	    phys_ram_size += KVM_EXTRA_PAGES * 4096;
-	    kvm_qemu_init();
+	    if (kvm_qemu_create_context() < 0) {
+		    fprintf(stderr, "Could not create KVM context\n");
+		    exit(1);
+	    }
     } else {
 	    phys_ram_base = qemu_vmalloc(phys_ram_size);
 	    if (!phys_ram_base) {
@@ -6112,7 +6120,6 @@
 	    }
     }
 #else
-    phys_ram_size = ram_size + vga_ram_size + bios_size;
     phys_ram_base = qemu_vmalloc(phys_ram_size);
     if (!phys_ram_base) {
         fprintf(stderr, "Could not allocate physical memory\n");

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] 2/2: Fall back to plain Qemu if KVM is not present, report errors from libkvm
       [not found]                                 ` <87wt5y89ik.wl%simon.kagstrom-6Uc+yI3S9P8@public.gmane.org>
@ 2006-11-14 13:24                                   ` Avi Kivity
       [not found]                                     ` <4559C393.70001-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 19+ messages in thread
From: Avi Kivity @ 2006-11-14 13:24 UTC (permalink / raw)
  To: Simon Kagstrom; +Cc: KVM, Baruch Even

Simon Kagstrom wrote:
> diff -u ../orig/kvm-2/qemu/vl.c qemu/vl.c
> --- ../orig/kvm-2/qemu/vl.c	2006-11-05 10:18:52.000000000 +0100
> +++ qemu/vl.c	2006-11-14 13:56:32.000000000 +0100
> @@ -5706,6 +5706,10 @@
>  
>      nb_nics = 0;
>      /* default mac address of the first network interface */
> +#if USE_KVM
> +    if (kvm_qemu_init() < 0)
> +	kvm_allowed = 0;
> +#endif
>   

Doesn't this bit will initialize kvm even if the user specified -no-kvm?

-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] 2/2: Fall back to plain Qemu if KVM is not present, report errors from libkvm
       [not found]                                     ` <4559C393.70001-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
@ 2006-11-14 13:39                                       ` Simon Kagstrom
       [not found]                                         ` <87veli87vf.wl%simon.kagstrom-6Uc+yI3S9P8@public.gmane.org>
  0 siblings, 1 reply; 19+ messages in thread
From: Simon Kagstrom @ 2006-11-14 13:39 UTC (permalink / raw)
  To: Avi Kivity; +Cc: KVM, Baruch Even

At Tue, 14 Nov 2006 15:24:35 +0200,
Avi Kivity wrote:
> 
> Simon Kagstrom wrote:
> > diff -u ../orig/kvm-2/qemu/vl.c qemu/vl.c
> > --- ../orig/kvm-2/qemu/vl.c	2006-11-05 10:18:52.000000000 +0100
> > +++ qemu/vl.c	2006-11-14 13:56:32.000000000 +0100
> > @@ -5706,6 +5706,10 @@
> >  
> >      nb_nics = 0;
> >      /* default mac address of the first network interface */
> > +#if USE_KVM
> > +    if (kvm_qemu_init() < 0)
> > +	kvm_allowed = 0;
> > +#endif
> >   
> 
> Doesn't this bit will initialize kvm even if the user specified -no-kvm?

Yes. Maybe I misunderstood you, but this is how I understood your
comments.

Sorry for spamming the list with patches. I'll send yet another
one. This will check and possibly disable KVM after the command-line
options have been parsed. If -no-kvm has been given, nothing will
happen.


Hopefully this will be the final patch! :-)

// Simon 

diff -u ../orig/kvm-2/qemu/qemu-kvm.c qemu/qemu-kvm.c
--- ../orig/kvm-2/qemu/qemu-kvm.c	2006-11-05 10:18:52.000000000 +0100
+++ qemu/qemu-kvm.c	2006-11-14 13:56:35.000000000 +0100
@@ -450,10 +450,30 @@
     .io_window = kvm_io_window,
 };
 
-void kvm_qemu_init()
+int kvm_qemu_init()
 {
+    /* Try to initialize kvm */
     kvm_context = kvm_init(&qemu_kvm_ops, saved_env);
-    kvm_create(kvm_context, phys_ram_size, (void**)&phys_ram_base);
+    if (!kvm_context) {
+      	return -1;
+    }
+
+    return 0;
+}
+
+int kvm_qemu_create_context(void)
+{
+    if (kvm_create(kvm_context, phys_ram_size, (void**)&phys_ram_base) < 0) {
+	kvm_qemu_destroy();
+	return -1;
+    }
+
+    return 0;
+}
+
+void kvm_qemu_destroy(void)
+{
+    kvm_finalize(kvm_context);
 }
 
 int kvm_update_debugger(CPUState *env)
diff -u ../orig/kvm-2/qemu/qemu-kvm.h qemu/qemu-kvm.h
--- ../orig/kvm-2/qemu/qemu-kvm.h	2006-10-16 11:01:02.000000000 +0200
+++ qemu/qemu-kvm.h	2006-11-14 13:55:56.000000000 +0100
@@ -3,7 +3,9 @@
 
 #include "kvmctl.h"
 
-void kvm_qemu_init(void);
+int kvm_qemu_init(void);
+int kvm_qemu_create_context(void);
+void kvm_qemu_destroy(void);
 void kvm_load_registers(CPUState *env);
 int kvm_cpu_exec(CPUState *env);
 int kvm_update_debugger(CPUState *env);
diff -u ../orig/kvm-2/qemu/vl.c qemu/vl.c
--- ../orig/kvm-2/qemu/vl.c	2006-11-05 10:18:52.000000000 +0100
+++ qemu/vl.c	2006-11-14 14:34:18.000000000 +0100
@@ -6054,6 +6054,15 @@
         }
     }
 
+#if USE_KVM
+    if (kvm_allowed) {
+	if (kvm_qemu_init() < 0) {
+	    fprintf(stderr, "Could not initialize KVM, will disable KVM support\n");
+	    kvm_allowed = 0;
+	}
+    }
+#endif
+
 #ifdef USE_KQEMU
     if (smp_cpus > 1)
         kqemu_allowed = 0;
@@ -6099,11 +6108,15 @@
     }
 
     /* init the memory */
-#if USE_KVM
     phys_ram_size = ram_size + vga_ram_size + bios_size;
+#if USE_KVM
+    /* Initialize kvm */
     if (kvm_allowed) {
 	    phys_ram_size += KVM_EXTRA_PAGES * 4096;
-	    kvm_qemu_init();
+	    if (kvm_qemu_create_context() < 0) {
+		    fprintf(stderr, "Could not create KVM context\n");
+		    exit(1);
+	    }
     } else {
 	    phys_ram_base = qemu_vmalloc(phys_ram_size);
 	    if (!phys_ram_base) {
@@ -6112,7 +6125,6 @@
 	    }
     }
 #else
-    phys_ram_size = ram_size + vga_ram_size + bios_size;
     phys_ram_base = qemu_vmalloc(phys_ram_size);
     if (!phys_ram_base) {
         fprintf(stderr, "Could not allocate physical memory\n");

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH] 2/2: Fall back to plain Qemu if KVM is not present, report errors from libkvm
       [not found]                                         ` <87veli87vf.wl%simon.kagstrom-6Uc+yI3S9P8@public.gmane.org>
@ 2006-11-14 13:55                                           ` Avi Kivity
  0 siblings, 0 replies; 19+ messages in thread
From: Avi Kivity @ 2006-11-14 13:55 UTC (permalink / raw)
  To: Simon Kagstrom; +Cc: KVM, Baruch Even

Simon Kagstrom wrote:
>>>   
>>>       
>> Doesn't this bit will initialize kvm even if the user specified -no-kvm?
>>     
>
> Yes. Maybe I misunderstood you, but this is how I understood your
> comments.
>
>   

I intended something like


    start with kvm_allowed = 1
    if (-no-kvm) kvm_allowed = 0
    if (kvm_allowed && !kvm_init() < 0) kvm_allowed = 0


> Sorry for spamming the list with patches. I'll send yet another
> one. 

Keep on patching :)

> This will check and possibly disable KVM after the command-line
> options have been parsed. If -no-kvm has been given, nothing will
> happen.
>
>
>  
> +#if USE_KVM
> +    if (kvm_allowed) {
> +	if (kvm_qemu_init() < 0) {
> +	    fprintf(stderr, "Could not initialize KVM, will disable KVM support\n");
> +	    kvm_allowed = 0;
> +	}
> +    }
> +#endif
> +
>   

Yes, exactly what I meant.


I'll apply this.  Thanks!

-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

^ permalink raw reply	[flat|nested] 19+ messages in thread

* qemu-kvm
@ 2010-02-13 12:39 Alberich de megres
  2010-02-13 15:16 ` qemu-kvm Markus Breitländer
  0 siblings, 1 reply; 19+ messages in thread
From: Alberich de megres @ 2010-02-13 12:39 UTC (permalink / raw)
  To: kvm

Hi!!

I got a curious situation that leads me to start sailing on qemu-kvm
source code.

I got an audio latency very very high, even with some little cuts at
playback. In qemu lists they told me qemu is synchronous, so if it
take so long to draw high screen resolution audio could be affected.
As I saw, qemu uses sdl to draw guest screen on host computer, my
question is: when sdl draw it uses some kind of 2d acceleration?

Woulld it be hard to make for example screen draw asynchronously to
audio playback? where would be a good point to start look for how to
do it?

Thanks!

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: qemu-kvm
  2010-02-13 12:39 qemu-kvm Alberich de megres
@ 2010-02-13 15:16 ` Markus Breitländer
  2010-02-14 12:13   ` qemu-kvm Alberich de megres
  2010-02-16 19:31   ` qemu-kvm Alberich de megres
  0 siblings, 2 replies; 19+ messages in thread
From: Markus Breitländer @ 2010-02-13 15:16 UTC (permalink / raw)
  Cc: kvm

You can alter the sound driver settings by setting some variables before
starting the VM.

I use the following in my start scripts:

export QEMU_AUDIO_DRV=alsa
export QEMU_AUDIO_DAC_FIXED_FREQ=48000
export QEMU_AUDIO_ADC_FIXED_FREQ=48000
export QEMU_ALSA_DAC_BUFFER_SIZE=4096

Maybe this helps?

Greets,
  Markus

Am 13.02.2010 13:39, schrieb Alberich de megres:
> Hi!!
> 
> I got a curious situation that leads me to start sailing on qemu-kvm
> source code.
> 
> I got an audio latency very very high, even with some little cuts at
> playback. In qemu lists they told me qemu is synchronous, so if it
> take so long to draw high screen resolution audio could be affected.
> As I saw, qemu uses sdl to draw guest screen on host computer, my
> question is: when sdl draw it uses some kind of 2d acceleration?
> 
> Woulld it be hard to make for example screen draw asynchronously to
> audio playback? where would be a good point to start look for how to
> do it?
> 
> Thanks!
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: qemu-kvm
  2010-02-13 15:16 ` qemu-kvm Markus Breitländer
@ 2010-02-14 12:13   ` Alberich de megres
  2010-02-16 19:31   ` qemu-kvm Alberich de megres
  1 sibling, 0 replies; 19+ messages in thread
From: Alberich de megres @ 2010-02-14 12:13 UTC (permalink / raw)
  To: Markus Breitländer; +Cc: kvm

Thanks Markus!
I will try it, and tell you.

Another question: when sdl draw guest OS uses some kind of 2d
acceleration on host side?

2010/2/13 Markus Breitländer <breitlaender@stud.fh-dortmund.de>:
> You can alter the sound driver settings by setting some variables before
> starting the VM.
>
> I use the following in my start scripts:
>
> export QEMU_AUDIO_DRV=alsa
> export QEMU_AUDIO_DAC_FIXED_FREQ=48000
> export QEMU_AUDIO_ADC_FIXED_FREQ=48000
> export QEMU_ALSA_DAC_BUFFER_SIZE=4096
>
> Maybe this helps?
>
> Greets,
>  Markus
>
> Am 13.02.2010 13:39, schrieb Alberich de megres:
>> Hi!!
>>
>> I got a curious situation that leads me to start sailing on qemu-kvm
>> source code.
>>
>> I got an audio latency very very high, even with some little cuts at
>> playback. In qemu lists they told me qemu is synchronous, so if it
>> take so long to draw high screen resolution audio could be affected.
>> As I saw, qemu uses sdl to draw guest screen on host computer, my
>> question is: when sdl draw it uses some kind of 2d acceleration?
>>
>> Woulld it be hard to make for example screen draw asynchronously to
>> audio playback? where would be a good point to start look for how to
>> do it?
>>
>> Thanks!
>> --
>> To unsubscribe from this list: send the line "unsubscribe kvm" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: qemu-kvm
  2010-02-13 15:16 ` qemu-kvm Markus Breitländer
  2010-02-14 12:13   ` qemu-kvm Alberich de megres
@ 2010-02-16 19:31   ` Alberich de megres
  1 sibling, 0 replies; 19+ messages in thread
From: Alberich de megres @ 2010-02-16 19:31 UTC (permalink / raw)
  To: Markus Breitländer; +Cc: kvm

2010/2/13 Markus Breitländer <breitlaender@stud.fh-dortmund.de>:
> You can alter the sound driver settings by setting some variables before
> starting the VM.
>
> I use the following in my start scripts:
>
> export QEMU_AUDIO_DRV=alsa
> export QEMU_AUDIO_DAC_FIXED_FREQ=48000
> export QEMU_AUDIO_ADC_FIXED_FREQ=48000
> export QEMU_ALSA_DAC_BUFFER_SIZE=4096
>
> Maybe this helps?
>
> Greets,
>  Markus
>

sorry, this didn't improve nothing. I still got the same latency and
audio cuts on playbacks.

If i low resolution on guest machine, then everything works perfect.
What makes me think it could something with graphic on host side.. am
i saying something stupid?

thansk!!

> Am 13.02.2010 13:39, schrieb Alberich de megres:
>> Hi!!
>>
>> I got a curious situation that leads me to start sailing on qemu-kvm
>> source code.
>>
>> I got an audio latency very very high, even with some little cuts at
>> playback. In qemu lists they told me qemu is synchronous, so if it
>> take so long to draw high screen resolution audio could be affected.
>> As I saw, qemu uses sdl to draw guest screen on host computer, my
>> question is: when sdl draw it uses some kind of 2d acceleration?
>>
>> Woulld it be hard to make for example screen draw asynchronously to
>> audio playback? where would be a good point to start look for how to
>> do it?
>>
>> Thanks!
>> --
>> To unsubscribe from this list: send the line "unsubscribe kvm" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2010-02-16 19:31 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-14  7:26 qemu-kvm Baruch Even
     [not found] ` <20061114072601.GD28027-xGn4Jn0woyz+OtfAA3OxFg@public.gmane.org>
2006-11-14  8:28   ` qemu-kvm Simon Kagstrom
2006-11-14  8:50   ` qemu-kvm Avi Kivity
     [not found]     ` <4559834F.80905-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2006-11-14  9:28       ` qemu-kvm Simon Kagstrom
     [not found]         ` <8764di9y30.wl%simon.kagstrom-6Uc+yI3S9P8@public.gmane.org>
2006-11-14  9:35           ` qemu-kvm Baruch Even
     [not found]             ` <20061114093537.GH28027-xGn4Jn0woyz+OtfAA3OxFg@public.gmane.org>
2006-11-14 10:30               ` [PATCH] 1/2: Fall back to plain Qemu if KVM is not present, report errors from libkvm Simon Kagstrom
2006-11-14  9:41           ` qemu-kvm Avi Kivity
     [not found]             ` <45598F42.5090400-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2006-11-14 10:36               ` [PATCH] 2/2: Fall back to plain Qemu if KVM is not present, report errors from libkvm Simon Kagstrom
     [not found]                 ` <871wo69uxb.wl%simon.kagstrom-6Uc+yI3S9P8@public.gmane.org>
2006-11-14 11:44                   ` Avi Kivity
     [not found]                     ` <4559AC1F.9080304-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2006-11-14 12:08                       ` Simon Kagstrom
     [not found]                         ` <87y7qe8c43.wl%simon.kagstrom-6Uc+yI3S9P8@public.gmane.org>
2006-11-14 12:24                           ` Avi Kivity
     [not found]                             ` <4559B574.5000000-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2006-11-14 13:04                               ` Simon Kagstrom
     [not found]                                 ` <87wt5y89ik.wl%simon.kagstrom-6Uc+yI3S9P8@public.gmane.org>
2006-11-14 13:24                                   ` Avi Kivity
     [not found]                                     ` <4559C393.70001-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2006-11-14 13:39                                       ` Simon Kagstrom
     [not found]                                         ` <87veli87vf.wl%simon.kagstrom-6Uc+yI3S9P8@public.gmane.org>
2006-11-14 13:55                                           ` Avi Kivity
  -- strict thread matches above, loose matches on Subject: below --
2010-02-13 12:39 qemu-kvm Alberich de megres
2010-02-13 15:16 ` qemu-kvm Markus Breitländer
2010-02-14 12:13   ` qemu-kvm Alberich de megres
2010-02-16 19:31   ` qemu-kvm Alberich de megres

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox