ia64/xen-unstable

changeset 13248:55be48549bb1

[IOEMU] Process reset requests before returning control to the guest.

Since 12899:4ae4bdee00e Xen only pays attention the first shutdown or
reboot request for a domain.

When a reset if requested we need to make the SCHEDOP_remote_shutdown
hypercall before we return control to the guest so that it wins the
"race" with the heuristic in xen/arch/x86/hvm/hvm.c:hvm_vcpu_down()
which causes a powerdown.

Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
author Ian Campbell <ian.campbell@xensource.com>
date Wed Jan 03 13:55:53 2007 +0000 (2007-01-03)
parents d6bd12ec82b5
children bf25488db8eb
files tools/ioemu/target-i386-dm/helper2.c
line diff
     1.1 --- a/tools/ioemu/target-i386-dm/helper2.c	Wed Jan 03 13:46:23 2007 +0000
     1.2 +++ b/tools/ioemu/target-i386-dm/helper2.c	Wed Jan 03 13:55:53 2007 +0000
     1.3 @@ -498,6 +498,8 @@ void handle_buffered_io(void *opaque)
     1.4  
     1.5  void cpu_handle_ioreq(void *opaque)
     1.6  {
     1.7 +    extern int vm_running;
     1.8 +    extern int shutdown_requested;
     1.9      CPUState *env = opaque;
    1.10      ioreq_t *req = cpu_get_ioreq();
    1.11  
    1.12 @@ -516,6 +518,25 @@ void cpu_handle_ioreq(void *opaque)
    1.13          }
    1.14  
    1.15          wmb(); /* Update ioreq contents /then/ update state. */
    1.16 +
    1.17 +	/*
    1.18 +         * We do this before we send the response so that the tools
    1.19 +         * have the opportunity to pick up on the reset before the
    1.20 +         * guest resumes and does a hlt with interrupts disabled which
    1.21 +         * causes Xen to powerdown the domain.
    1.22 +         */
    1.23 +        if (vm_running) {
    1.24 +            if (shutdown_requested) {
    1.25 +		fprintf(logfile, "shutdown requested in cpu_handle_ioreq\n");
    1.26 +		destroy_hvm_domain();
    1.27 +	    }
    1.28 +	    if (reset_requested) {
    1.29 +		fprintf(logfile, "reset requested in cpu_handle_ioreq.\n");
    1.30 +		qemu_system_reset();
    1.31 +		reset_requested = 0;
    1.32 +	    }
    1.33 +	}
    1.34 +
    1.35          req->state = STATE_IORESP_READY;
    1.36          xc_evtchn_notify(xce_handle, ioreq_local_port[send_vcpu]);
    1.37      }