Commit ee5605e55676752335420dfddb98860f7d8ecd89
1 parent
001a3f5a
Ensure a SIGALRM results in a break out from the cpu loop.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3769 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
20 additions
and
14 deletions
vl.c
| @@ -233,6 +233,10 @@ const char *prom_envs[MAX_PROM_ENVS]; | @@ -233,6 +233,10 @@ const char *prom_envs[MAX_PROM_ENVS]; | ||
| 233 | int nb_drives_opt; | 233 | int nb_drives_opt; |
| 234 | char drives_opt[MAX_DRIVES][1024]; | 234 | char drives_opt[MAX_DRIVES][1024]; |
| 235 | 235 | ||
| 236 | +static CPUState *cur_cpu; | ||
| 237 | +static CPUState *next_cpu; | ||
| 238 | +static int event_pending; | ||
| 239 | + | ||
| 236 | #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR) | 240 | #define TFR(expr) do { if ((expr) != -1) break; } while (errno == EINTR) |
| 237 | 241 | ||
| 238 | /***********************************************************/ | 242 | /***********************************************************/ |
| @@ -1180,16 +1184,16 @@ static void host_alarm_handler(int host_signum) | @@ -1180,16 +1184,16 @@ static void host_alarm_handler(int host_signum) | ||
| 1180 | struct qemu_alarm_win32 *data = ((struct qemu_alarm_timer*)dwUser)->priv; | 1184 | struct qemu_alarm_win32 *data = ((struct qemu_alarm_timer*)dwUser)->priv; |
| 1181 | SetEvent(data->host_alarm); | 1185 | SetEvent(data->host_alarm); |
| 1182 | #endif | 1186 | #endif |
| 1183 | - CPUState *env = cpu_single_env; | ||
| 1184 | - if (env) { | ||
| 1185 | - /* stop the currently executing cpu because a timer occured */ | ||
| 1186 | - cpu_interrupt(env, CPU_INTERRUPT_EXIT); | 1187 | + CPUState *env = next_cpu; |
| 1188 | + | ||
| 1189 | + /* stop the currently executing cpu because a timer occured */ | ||
| 1190 | + cpu_interrupt(env, CPU_INTERRUPT_EXIT); | ||
| 1187 | #ifdef USE_KQEMU | 1191 | #ifdef USE_KQEMU |
| 1188 | - if (env->kqemu_enabled) { | ||
| 1189 | - kqemu_cpu_interrupt(env); | ||
| 1190 | - } | ||
| 1191 | -#endif | 1192 | + if (env->kqemu_enabled) { |
| 1193 | + kqemu_cpu_interrupt(env); | ||
| 1192 | } | 1194 | } |
| 1195 | +#endif | ||
| 1196 | + event_pending = 1; | ||
| 1193 | } | 1197 | } |
| 1194 | } | 1198 | } |
| 1195 | 1199 | ||
| @@ -7340,8 +7344,6 @@ void main_loop_wait(int timeout) | @@ -7340,8 +7344,6 @@ void main_loop_wait(int timeout) | ||
| 7340 | 7344 | ||
| 7341 | } | 7345 | } |
| 7342 | 7346 | ||
| 7343 | -static CPUState *cur_cpu; | ||
| 7344 | - | ||
| 7345 | static int main_loop(void) | 7347 | static int main_loop(void) |
| 7346 | { | 7348 | { |
| 7347 | int ret, timeout; | 7349 | int ret, timeout; |
| @@ -7351,15 +7353,13 @@ static int main_loop(void) | @@ -7351,15 +7353,13 @@ static int main_loop(void) | ||
| 7351 | CPUState *env; | 7353 | CPUState *env; |
| 7352 | 7354 | ||
| 7353 | cur_cpu = first_cpu; | 7355 | cur_cpu = first_cpu; |
| 7356 | + next_cpu = cur_cpu->next_cpu ?: first_cpu; | ||
| 7354 | for(;;) { | 7357 | for(;;) { |
| 7355 | if (vm_running) { | 7358 | if (vm_running) { |
| 7356 | 7359 | ||
| 7357 | - env = cur_cpu; | ||
| 7358 | for(;;) { | 7360 | for(;;) { |
| 7359 | /* get next cpu */ | 7361 | /* get next cpu */ |
| 7360 | - env = env->next_cpu; | ||
| 7361 | - if (!env) | ||
| 7362 | - env = first_cpu; | 7362 | + env = next_cpu; |
| 7363 | #ifdef CONFIG_PROFILER | 7363 | #ifdef CONFIG_PROFILER |
| 7364 | ti = profile_getclock(); | 7364 | ti = profile_getclock(); |
| 7365 | #endif | 7365 | #endif |
| @@ -7367,6 +7367,12 @@ static int main_loop(void) | @@ -7367,6 +7367,12 @@ static int main_loop(void) | ||
| 7367 | #ifdef CONFIG_PROFILER | 7367 | #ifdef CONFIG_PROFILER |
| 7368 | qemu_time += profile_getclock() - ti; | 7368 | qemu_time += profile_getclock() - ti; |
| 7369 | #endif | 7369 | #endif |
| 7370 | + next_cpu = env->next_cpu ?: first_cpu; | ||
| 7371 | + if (event_pending) { | ||
| 7372 | + ret = EXCP_INTERRUPT; | ||
| 7373 | + event_pending = 0; | ||
| 7374 | + break; | ||
| 7375 | + } | ||
| 7370 | if (ret == EXCP_HLT) { | 7376 | if (ret == EXCP_HLT) { |
| 7371 | /* Give the next CPU a chance to run. */ | 7377 | /* Give the next CPU a chance to run. */ |
| 7372 | cur_cpu = env; | 7378 | cur_cpu = env; |