Message ID | 1370794247-28267-16-git-send-email-afaerber@suse.de |
---|---|
State | New |
Headers | show |
On Sun, 9 Jun 2013 18:10:44 +0200 Andreas Färber <afaerber@suse.de> wrote: > Allows to drop CPUArchState variable. > > Signed-off-by: Andreas Färber <afaerber@suse.de> > --- > dump.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/dump.c b/dump.c > index 44a1339..4e6b855 100644 > --- a/dump.c > +++ b/dump.c > @@ -702,10 +702,16 @@ static ram_addr_t get_start_block(DumpState *s) > return -1; > } > > +static void count_one_cpu(CPUState *cpu, void *data) > +{ > + int *nr = data; > + > + *nr = *nr + 1; > +} > + > static int dump_init(DumpState *s, int fd, bool paging, bool has_filter, > int64_t begin, int64_t length, Error **errp) > { > - CPUArchState *env; > int nr_cpus; > Error *err = NULL; > int ret; > @@ -738,9 +744,7 @@ static int dump_init(DumpState *s, int fd, bool paging, bool has_filter, > */ > cpu_synchronize_all_states(); > nr_cpus = 0; > - for (env = first_cpu; env != NULL; env = env->next_cpu) { > - nr_cpus++; > - } > + qemu_for_each_cpu(count_one_cpu, &nr_cpus); Isn't it worth it to have an API for this? Reviewed-by: Luiz Capitulino <lcapitulino@redhat.com> > > ret = cpu_get_dump_info(&s->dump_info); > if (ret < 0) {
diff --git a/dump.c b/dump.c index 44a1339..4e6b855 100644 --- a/dump.c +++ b/dump.c @@ -702,10 +702,16 @@ static ram_addr_t get_start_block(DumpState *s) return -1; } +static void count_one_cpu(CPUState *cpu, void *data) +{ + int *nr = data; + + *nr = *nr + 1; +} + static int dump_init(DumpState *s, int fd, bool paging, bool has_filter, int64_t begin, int64_t length, Error **errp) { - CPUArchState *env; int nr_cpus; Error *err = NULL; int ret; @@ -738,9 +744,7 @@ static int dump_init(DumpState *s, int fd, bool paging, bool has_filter, */ cpu_synchronize_all_states(); nr_cpus = 0; - for (env = first_cpu; env != NULL; env = env->next_cpu) { - nr_cpus++; - } + qemu_for_each_cpu(count_one_cpu, &nr_cpus); ret = cpu_get_dump_info(&s->dump_info); if (ret < 0) {
Allows to drop CPUArchState variable. Signed-off-by: Andreas Färber <afaerber@suse.de> --- dump.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)