Patchwork [qom-cpu-next] monitor: Use qemu_get_cpu() in monitor_set_cpu()

login
register
mail settings
Submitter Andreas Färber
Date Feb. 15, 2013, 4:10 p.m.
Message ID <1360944608-25739-1-git-send-email-afaerber@suse.de>
Download mbox | patch
Permalink /patch/220772/
State New
Headers show

Comments

Andreas Färber - Feb. 15, 2013, 4:10 p.m.
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().

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 monitor.c |   13 +++++--------
 1 Datei geändert, 5 Zeilen hinzugefügt(+), 8 Zeilen entfernt(-)
Luiz Capitulino - Feb. 18, 2013, 12:59 p.m.
On Fri, 15 Feb 2013 17:10:08 +0100
Andreas Färber <afaerber@suse.de> wrote:

> 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().
> 
> Signed-off-by: Andreas Färber <afaerber@suse.de>

Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>

> ---
>  monitor.c |   13 +++++--------
>  1 Datei geändert, 5 Zeilen hinzugefügt(+), 8 Zeilen entfernt(-)
> 
> diff --git a/monitor.c b/monitor.c
> index 20bd19b..cae33c4 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)
Andreas Färber - Feb. 18, 2013, 3:05 p.m.
Am 18.02.2013 13:59, schrieb Luiz Capitulino:
> On Fri, 15 Feb 2013 17:10:08 +0100
> Andreas Färber <afaerber@suse.de> wrote:
> 
>> 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().
>>
>> Signed-off-by: Andreas Färber <afaerber@suse.de>
> 
> Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com>

Thanks, applied to qom-cpu-next:
https://github.com/afaerber/qemu-cpu/commits/qom-cpu-next

Andreas
Markus Armbruster - Feb. 25, 2013, 1:17 p.m.
Andreas Färber <afaerber@suse.de> writes:

> 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().
>
> Signed-off-by: Andreas Färber <afaerber@suse.de>

Reviewed-by: Markus Armbruster <armbru@redhat.com>

Patch

diff --git a/monitor.c b/monitor.c
index 20bd19b..cae33c4 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)