[Qemu-devel] [PATCH] intentinoal slowing down qemu - brake

2006-11-30 Thread Miroslav Novak

This patch adds support for slowing down qemu and saving cpu load.
The '-brake' command line parameter or monitor command 'brake' 
determines how long to wait in the main_loop with respect to duration of 
time that qemu used for the emulation itself.
Thus e.g. zero value runs at full speed, 1 at 1/2 speed, 10 at 1/11 
speed, etc.


A drawback of this approach is that the timer interrupt can be missed if 
raised too often. This happens if the loop_main divided by (1+brake) is 
less than the frequency of PIC interrupts.

In such case the time of emulated system runs slowly.

This problem occurs mainly for Linux emulation where kernel parameter HZ 
is of several hunderds.
For DOS emulation, where the timer interrupts are raised usualy at 18Hz, 
this approach works nice, and one can play old DOS games at reasonable 
speed and save batteries.



Mirek

diff -aur ../../orig/qemu-0.8.2/monitor.c ./monitor.c
--- ../../orig/qemu-0.8.2/monitor.c	2006-07-22 19:23:34.0 +0200
+++ ./monitor.c	2006-11-27 18:11:34.0 +0100
@@ -276,6 +276,14 @@
 term_printf("Invalid CPU index\n");
 }
 
+static void do_brake_set(int multiplier)
+{
+if (multiplier < 0)
+term_printf("Current brake multiplier %d\n", brake_mult);
+else
+brake_mult = multiplier;
+}
+
 static void do_info_jit(void)
 {
 dump_exec_info(NULL, monitor_fprintf);
@@ -1198,6 +1206,8 @@
 #endif
  { "stopcapture", "i", do_stop_capture,
"capture index", "stop capture" },
+{ "brake", "i", do_brake_set, 
+  "multiplier", "set brake multiplier (non-negative integer), negative value prints actual setting" },
 { NULL, NULL, }, 
 };
 
diff -aur ../../orig/qemu-0.8.2/vl.c ./vl.c
--- ../../orig/qemu-0.8.2/vl.c	2006-07-22 19:23:34.0 +0200
+++ ./vl.c	2006-11-27 18:25:22.0 +0100
@@ -156,6 +156,7 @@
 #endif
 int acpi_enabled = 1;
 int fd_bootchk = 1;
+int brake_mult = 0;
 
 /***/
 /* x86 ISA bus support */
@@ -5045,8 +5046,39 @@
 
 static CPUState *cur_cpu;
 
+
+int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y) {
+	/* Perform the carry for the later subtraction by updating y. */
+	if (x->tv_usec < y->tv_usec) {
+		int nsec = (y->tv_usec - x->tv_usec) / 100 + 1;
+		y->tv_usec -= 100 * nsec;
+		y->tv_sec += nsec;
+	}
+	if (x->tv_usec - y->tv_usec > 100) {
+		int nsec = (x->tv_usec - y->tv_usec) / 100;
+		y->tv_usec += 100 * nsec;
+		y->tv_sec -= nsec;
+	}
+
+	/* Compute the time remaining to wait.
+	 *  tv_usec is certainly positive. */
+	result->tv_sec = x->tv_sec - y->tv_sec;
+	result->tv_usec = x->tv_usec - y->tv_usec;
+
+	/* Return 1 if result is negative. */
+	return x->tv_sec < y->tv_sec;
+}
+
+
 int main_loop(void)
 {
+struct timeval tti, tti2, tti3, ttix;
+//#define BRAKE_DEBUG
+#ifdef BRAKE_DEBUG
+int64_t mti, mti1, mti2, mti3;
+int prcnt=0;
+#endif
+
 int ret, timeout;
 #ifdef CONFIG_PROFILER
 int64_t ti;
@@ -5055,6 +5087,11 @@
 
 cur_cpu = first_cpu;
 for(;;) {
+
+gettimeofday(&tti, NULL);
+#ifdef BRAKE_DEBUG
+mti = profile_getclock();
+#endif
 if (vm_running) {
 
 env = cur_cpu;
@@ -5113,6 +5150,41 @@
 #ifdef CONFIG_PROFILER
 dev_time += profile_getclock() - ti;
 #endif
+
+gettimeofday(&tti2, NULL);
+#ifdef BRAKE_DEBUG
+mti2 = profile_getclock();
+#endif
+
+{
+struct timespec ts;
+int delus, delunc=0;
+sigset_t sis, osis;
+
+timeval_subtract(&ttix, &tti2, &tti);
+delus = ttix.tv_usec*brake_mult - delunc;
+ts.tv_sec=0;
+ts.tv_nsec=delus*1000;
+
+sigfillset(&sis);
+sigprocmask(SIG_BLOCK, &sis, &osis);
+if (delus>0) while (nanosleep(&ts, &ts));
+sigprocmask(SIG_SETMASK, &osis, NULL);
+#ifdef BRAKE_DEBUG
+mti3 = profile_getclock();
+#endif
+gettimeofday(&tti3, NULL);
+
+timeval_subtract(&ttix, &tti3, &tti2);
+delunc = ttix.tv_usec-delus; 
+#ifdef BRAKE_DEBUG
+if (!((++prcnt)%128)) {
+printf("cycles %qd, \t%qd, \t%qd, \t%qd \%\n", (mti1 - mti), (mti2 - mti1), (mti3 - mti2), (100*(mti1 - mti))/(mti3-mti) );
+//printf("del[us] %d, \t%d\n", delus, delunc);
+//printf("ts[ns] = %d\n", ts.tv_nsec);
+}
+#endif
+}
 }
 cpu_disable_ticks();
 return ret;
@@ -5224,6 +5296,7 @@
 #endif
"-loadvm filestart right away with a saved state (loadvm in monitor)\n"
 	   "-vnc displaystart a VNC server on display\n"
+   "-brake multiplierenables brake system which slows down qemu `multiplier'-times\n"
"\n"
"During emulation, the following keys are useful:\n"
"ctrl-alt-f  toggle full screen\n"
@@ -5302,6 +5375,7 @@
 QEMU_OPTION_smp,
 QEMU_OPTION_vnc,
 QEMU_OP

[Qemu-devel] Mouse Problem. It's not SDL_VIDEO_X11_DGAMOUSE=0

2006-11-30 Thread Luis Ramirez

Hello,

I've the same problem as everybody with the mouse. When I start qemu
the mouse goes to the bottom-right corner.
I solved the problem in the past adding the SDL_VIDEO_X11_DGAMOUSE = 0
to the env variables.

My HD die and know I have reinstalled all the things.
In the past my linux was a Sarge with XFree86 sever with a 2.6.10 kernel.

Today is a Dapper Ubuntu with Xorg with a 2.6.18 kernel.

These are my items in both system:
qemu 0.8.2
kqemu 1.3.0-pre9

My flags:
sudo qemu -hda /home/luis/qemu/windows_XP.img -hdb
/home/luis/qemu/w2k_work.img -net nic,vlan=0 -net
tap,vlan=0,ifname=tap0,script=/etc/qemu-ifup -m 512M

The env var SDL_VIDEO_X11_DGAMOUSE=0 is set.

Do you know another reason for this problem??

--
Luis Ramírez González.
--
< NO A LAS PATENTES DE SOFTWARE EN LA UE >
< STOP EU SOFTWARE PATENTS >
http://www.nosoftwarepatents.com/es/m/intro/index.html
http://swpat.ffii.org/index.es.html
LARG
--


___
Qemu-devel mailing list
Qemu-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/qemu-devel


[Qemu-devel] question on samba/linux_guest

2006-11-30 Thread Christian MICHON

Hi list,

I know for sure "-smb" option is meant for using samba inside a Windows guest
inside a linux host.

I would like to do the opposite: having a Windows host and a properly configured
samba inside a linux guest, use windows explorer to browse specific disk areas
of the linux guest.

I can already do this using vmplayer in host-only network mode, similar to the
network user mode over slirp. The problem is that I do not know what IP address
I should use when mapping the disk inside windows host.

Indeed, the IP address inside the qemu guest is something like 10.0.2.15, but
I cannot access it from XP. I tried to fiddle with "-redir" options, but it
refuses to redirect port 445 (though I'm admin on XP).

Has anyone managed this yet ? If so, please share the command lines.
It must be possible, but maybe not easy.

Just a precision: I want to use the slirp mode only, not the tap-win32 stuff.
Thanks in advance
--
Christian


___
Qemu-devel mailing list
Qemu-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/qemu-devel


[Qemu-devel] Emulating a machine with no keyboard connected

2006-11-30 Thread Marius Nuennerich
Hi List,

I would like to emulate an i386 machine which has no PS/2 keyboard or
USB keyboard plugged in. Is this possible?

If there is currently no way to do this, where could one start to
implement this "feature"? I thought about something like
"-k none" as parameter.

regards
Marius

P.S. I'm not a subscriber so please CC me.


___
Qemu-devel mailing list
Qemu-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/qemu-devel


[Qemu-devel] OHCI for i386

2006-11-30 Thread Ed Swierk

After spending some time trying to figure out why the emulated UHCI
USB controller is so slow, I switched uhci_usb_init() in hw/pc.c to
ohci_usb_init(). To my delight, Linux booted up and detected the
controller on the first try, and accessing an emulated block device is
2 to 3 times faster.

It seems that UHCI is used only on i386, while the other architectures
use OHCI. Would switching i386 to OHCI cause problems for other guest
OSes?

--Ed


___
Qemu-devel mailing list
Qemu-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/qemu-devel