All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] Virtualising qmp_query_cpus() arch specifics
@ 2015-07-09  6:36 Peter Crosthwaite
  2015-07-09 12:31 ` Andreas Färber
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Crosthwaite @ 2015-07-09  6:36 UTC (permalink / raw)
  To: Markus Armbruster, Michael Roth, Eric Blake,
	qemu-devel@nongnu.org Developers, Paolo Bonzini,
	Andreas Färber

Hi All,

So for my multi-arch work, one of the eventual requirements is to
remove all #define TARGET_FOO from core code. I came across this in
cpus.c/qmp_query_cpus():

#if defined(TARGET_I386)
        X86CPU *x86_cpu = X86_CPU(cpu);
        CPUX86State *env = &x86_cpu->env;
#elif defined(TARGET_PPC)
        PowerPCCPU *ppc_cpu = POWERPC_CPU(cpu);
        CPUPPCState *env = &ppc_cpu->env;
...

#if defined(TARGET_I386)
        info->value->has_pc = true;
        info->value->pc = env->eip + env->segs[R_CS].base;
#elif defined(TARGET_PPC)
        info->value->has_nip = true;
        info->value->nip = env->nip;
...

This should probably be a QOM CPU virtual function. What makes me
uneasy about it however, is a direct implementation means the QAPI
autogenerated CPUInfoList struct would need to be exposed to
target-foo/cpu.c. Is this ok or an abstraction fail? Do we need some
other other minimal struct to communicate between target-foo and QMP
with these particulars? Any third options?

Regards,
Peter

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] Virtualising qmp_query_cpus() arch specifics
  2015-07-09  6:36 [Qemu-devel] Virtualising qmp_query_cpus() arch specifics Peter Crosthwaite
@ 2015-07-09 12:31 ` Andreas Färber
  2015-07-09 19:04   ` Peter Crosthwaite
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Färber @ 2015-07-09 12:31 UTC (permalink / raw)
  To: Peter Crosthwaite, qemu-devel@nongnu.org Developers
  Cc: Paolo Bonzini, Markus Armbruster, Michael Roth

Am 09.07.2015 um 08:36 schrieb Peter Crosthwaite:
> Hi All,
> 
> So for my multi-arch work, one of the eventual requirements is to
> remove all #define TARGET_FOO from core code. I came across this in
> cpus.c/qmp_query_cpus():
> 
> #if defined(TARGET_I386)
>         X86CPU *x86_cpu = X86_CPU(cpu);
>         CPUX86State *env = &x86_cpu->env;
> #elif defined(TARGET_PPC)
>         PowerPCCPU *ppc_cpu = POWERPC_CPU(cpu);
>         CPUPPCState *env = &ppc_cpu->env;
> ...
> 
> #if defined(TARGET_I386)
>         info->value->has_pc = true;
>         info->value->pc = env->eip + env->segs[R_CS].base;
> #elif defined(TARGET_PPC)
>         info->value->has_nip = true;
>         info->value->nip = env->nip;
> ...
> 
> This should probably be a QOM CPU virtual function. What makes me
> uneasy about it however, is a direct implementation means the QAPI
> autogenerated CPUInfoList struct would need to be exposed to
> target-foo/cpu.c. Is this ok or an abstraction fail? Do we need some
> other other minimal struct to communicate between target-foo and QMP
> with these particulars? Any third options?

Wouldn't that just be a get_pc() matching your set_pc() hook?

Unfortunately there's name differences above, pc vs. nip. Maybe we can
just use a generic field and keep #ifdef stuff only as legacy compat?

Cheers,
Andreas

-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu, Graham Norton; HRB
21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] Virtualising qmp_query_cpus() arch specifics
  2015-07-09 12:31 ` Andreas Färber
@ 2015-07-09 19:04   ` Peter Crosthwaite
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Crosthwaite @ 2015-07-09 19:04 UTC (permalink / raw)
  To: Andreas Färber
  Cc: Michael Roth, Paolo Bonzini, qemu-devel@nongnu.org Developers,
	Markus Armbruster

On Thu, Jul 9, 2015 at 5:31 AM, Andreas Färber <afaerber@suse.de> wrote:
> Am 09.07.2015 um 08:36 schrieb Peter Crosthwaite:
>> Hi All,
>>
>> So for my multi-arch work, one of the eventual requirements is to
>> remove all #define TARGET_FOO from core code. I came across this in
>> cpus.c/qmp_query_cpus():
>>
>> #if defined(TARGET_I386)
>>         X86CPU *x86_cpu = X86_CPU(cpu);
>>         CPUX86State *env = &x86_cpu->env;
>> #elif defined(TARGET_PPC)
>>         PowerPCCPU *ppc_cpu = POWERPC_CPU(cpu);
>>         CPUPPCState *env = &ppc_cpu->env;
>> ...
>>
>> #if defined(TARGET_I386)
>>         info->value->has_pc = true;
>>         info->value->pc = env->eip + env->segs[R_CS].base;
>> #elif defined(TARGET_PPC)
>>         info->value->has_nip = true;
>>         info->value->nip = env->nip;
>> ...
>>
>> This should probably be a QOM CPU virtual function. What makes me
>> uneasy about it however, is a direct implementation means the QAPI
>> autogenerated CPUInfoList struct would need to be exposed to
>> target-foo/cpu.c. Is this ok or an abstraction fail? Do we need some
>> other other minimal struct to communicate between target-foo and QMP
>> with these particulars? Any third options?
>
> Wouldn't that just be a get_pc() matching your set_pc() hook?
>
> Unfortunately there's name differences above, pc vs. nip. Maybe we can
> just use a generic field and keep #ifdef stuff only as legacy compat?
>

Not sure I follow exactly. But I thought of another option. The
multi-arch work allows you to include multiple cpu.h's from code that
doesn't need the cpu-defs.h particulars. cpus.c should qualify. So it
is entirely possible that instead we keep this all local here and use
QOM RTTI:

#include target-foo/cpu.h
#include target-bar/cpu.h

if (object_dynamic_cast(cpu, TYPE_FOO) {
    FooCpu *foo_cpu = FOO_CPU(cpu);
    ...
} else if (object_dynamic_cast(cpu, TYPE_BAR) {
    BarCpu *bar_cpu = BAR_CPU(cpu);
    ...
}

This would push this cleanup until after the multi-arch main series.

Regards,
Peter

> Cheers,
> Andreas
>
> --
> SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
> GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu, Graham Norton; HRB
> 21284 (AG Nürnberg)
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-07-09 19:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-09  6:36 [Qemu-devel] Virtualising qmp_query_cpus() arch specifics Peter Crosthwaite
2015-07-09 12:31 ` Andreas Färber
2015-07-09 19:04   ` Peter Crosthwaite

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.