ia64/xen-unstable

changeset 16965:d29d74d4eeac

hvm: Fix 'xm save' bug in qhich qemu-dm ignores SIGTERM.

When saving a guest in early ChangeSet (Before 16750), Xend will
send "SIGKILL" signal to kill qemu process. But in ChangeSet 16750,
the signal is modified to "SIGTERM". However, "SIGTERM" handler has
been registered by SDL in qemu. So when qemu process receives a
"SIGTERM", SDL will catch it and it will push out a "SDL_QUIT" even to
qemu. If qemu can receive that event, it will be successfully
terminated. While we do "xm save", qemu can't go out from the dead
loop "while (suspend_requested) {...}" in main_loop() to handle the
SQL_QUIT event. So it is unable to poll that "SDL_QUIT" event. This
makes xm save command hang. This fix enables qemu to poll the
"SDL_QUIT" event while doing save.

Signed-off-by: Xu Dongxiao <dongxiao.xu@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Feb 01 12:01:34 2008 +0000 (2008-02-01)
parents 3787e70b2ab2
children 5d84464dc1fc
files tools/ioemu/target-i386-dm/helper2.c
line diff
     1.1 --- a/tools/ioemu/target-i386-dm/helper2.c	Fri Feb 01 11:21:27 2008 +0000
     1.2 +++ b/tools/ioemu/target-i386-dm/helper2.c	Fri Feb 01 12:01:34 2008 +0000
     1.3 @@ -672,11 +672,28 @@ int main_loop(void)
     1.4          xenstore_record_dm_state("paused");
     1.5  
     1.6          /* Wait to be allowed to continue */
     1.7 -        while (suspend_requested) {
     1.8 +        while (suspend_requested && !shutdown_requested) {
     1.9 +            /*
    1.10 +             * Poll for shutdown via SDL every 10ms.
    1.11 +             * This is needed because SDL steals SIGTERM and only lets us
    1.12 +             * know about it after gui_update().
    1.13 +             */
    1.14 +            struct timeval tv;
    1.15 +            tv.tv_sec  = 0;
    1.16 +            tv.tv_usec = 10000;
    1.17 +
    1.18              FD_ZERO(&fds);
    1.19              FD_SET(xenstore_fd(), &fds);
    1.20 -            if (select(xenstore_fd() + 1, &fds, NULL, NULL, NULL) > 0)
    1.21 +            if (select(xenstore_fd() + 1, &fds, NULL, NULL, &tv) > 0)
    1.22                  xenstore_process_event(NULL);
    1.23 +
    1.24 +            /* Refresh SDL state and pick up any pending shutdown request. */
    1.25 +            gui_update();
    1.26 +        }
    1.27 +
    1.28 +        if (shutdown_requested) {
    1.29 +            ret = EXCP_INTERRUPT;
    1.30 +            break;
    1.31          }
    1.32  
    1.33          xenstore_record_dm_state("running");