qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Re: Suggestion - trap window-close of VM


From: Struan Bartlett
Subject: Re: [Qemu-devel] Re: Suggestion - trap window-close of VM
Date: Wed, 30 Mar 2005 14:20:36 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041007 Debian/1.7.3-5

Thanks for testing my patch on Windows 98.

Ryan Rempel wrote:
On Tue, 29 Mar 2005 23:52:19 +0100, Paul Brook <address@hidden> wrote:
  
This isn't working quite right for me with a Windows 98 guest -- it
traps the attempt to close the window all right, but it doesn't let
the window close even when Window 98 has in fact shut down.
      
As far as qemu is concerned there's nothing special about windows being "shut
down". ie. it's not possible to tell if windows is doing something useful, or
just sitting there waiting for you to turn it off.
    

Just to clarify, I was commenting on Struan's patch, which does try to
determine whether windows is "shut down" -- his patch seems to work
with a Windows 2000 guest, but not a Windows 98 guest (he reported the
former, I was reporting the latter).
  
To respond to Paul's original point, in fact it does seem possible in some circumstances to tell if Windows is doing something useful, or just sitting there waiting for you to turn it off - at least it does for Windows 2000. My patch works by examining the emulated i386 EIP and EFLAGS registers. It subtracts one from the EIP (to find the address of the previously-executed instruction) and examines the virtual memory location pointed to. If the memory location contains 0xF4 (HLT) then it examines the EFLAGS register. If the IF (Interrupt-enable) flag is cleared, then one might in fact assume that Windows 2000 is sitting there just waiting for you to turn it off. The assumption here is that if interrupts are disabled then there is no way the processor's halt state can be interrupted.
 
  
I wonder
whether this is related to the "Windows 98 doesn't use the HLT
instruction" problem that is noted elsewhere (since that apparently
doesn't affect Windows 2000).
      
No. the HLT thing is just windows 9x being crap. It also happens on real
hardware.
    
I reckon you might be right and that it's because Win 9x doesn't use the HLT instruction and the code it executes at shutdown is different. If I had an installation of Win98 to hand, I would use the monitor console to take a look at what the EIP was doing and what instructions were being executed in the shutdown state and then adjust the patch to check for this circumstance too, should that be possible.
In theory windows should be able to "turn off" qemu using APM, like it does on
real machines. However there seem to be bugs in the qemu implementation that
stop this working.
    
Is the bug in the BIOS or in Qemu?

Again to clarify, qemu does ordinarily quit as expected when I shut
down a Windows 98 guest -- I was commenting specifically on Struan's
patch, rather than qemu's normal behaviour. I was speculating that the
HLT instruction might have an impact on Struan's method to detect
whether windows had shut down (since it was a known difference between
Windows 98 and 2000), but I may well be barking up the wrong tree
there.
  
If Qemu ordinarily quits as expected when you shut down a Windows 98 guest, then the '-on-quit ignore-unless-halted' option shouldn't be used although the '-on-quit suspend-unless-halted' option could still be useful.

Struan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]