aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Färber <afaerber@suse.de>2013-02-15 17:01:09 +0100
committerAndreas Färber <afaerber@suse.de>2013-03-12 10:35:54 +0100
commit1c8bb3cc7b98ad07a028567b86fc6baa5c5a0b7a (patch)
tree59480d3e2555b421c925ceef097c00bc05c418f6
parentd76fddaeeec674cab4802b585db6c9fb3a0066dc (diff)
monitor: Use qemu_get_cpu() in monitor_set_cpu()
No functional change, just a reduction of CPU loops. The mon_cpu field is left untouched for now since changing that requires a number of larger prerequisites, including cpu_synchronize_state() and mon_get_cpu(). Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
-rw-r--r--monitor.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/monitor.c b/monitor.c
index c48530bd55..ab05c49abb 100644
--- a/monitor.c
+++ b/monitor.c
@@ -855,17 +855,14 @@ EventInfoList *qmp_query_events(Error **errp)
/* set the current CPU defined by the user */
int monitor_set_cpu(int cpu_index)
{
- CPUArchState *env;
CPUState *cpu;
- for (env = first_cpu; env != NULL; env = env->next_cpu) {
- cpu = ENV_GET_CPU(env);
- if (cpu->cpu_index == cpu_index) {
- cur_mon->mon_cpu = env;
- return 0;
- }
+ cpu = qemu_get_cpu(cpu_index);
+ if (cpu == NULL) {
+ return -1;
}
- return -1;
+ cur_mon->mon_cpu = cpu->env_ptr;
+ return 0;
}
static CPUArchState *mon_get_cpu(void)