Message ID | 2b9e79d9-9c13-3edc-38f4-80062824e0b6@linux.vnet.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, 8 Feb 2018 16:52:28 +0100 Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com> wrote: > diff --git a/qapi-schema.json b/qapi-schema.json > index 12c7dc8..0b36860 100644 > --- a/qapi-schema.json > +++ b/qapi-schema.json > @@ -607,7 +607,27 @@ > ## > { 'struct': 'CpuInfo2', > 'data': {'cpu-index': 'int', '*halted': 'bool', 'qom-path': 'str', > - 'thread-id': 'int', '*props': 'CpuInstanceProperties' } } > + 'thread-id': 'int', '*props': 'CpuInstanceProperties', > + '*archdata': 'CpuInfoArchData' } } > + > +## > +# @CpuInfoArchData: > +# > +# Architecure specific information about a virtual CPU > +# > +# Since: 2.12 > +# > +## > +{ 'union': 'CpuInfoArchData', > + 'base': { 'arch': 'CpuInfoArch' }, > + 'discriminator': 'arch', > + 'data': { 'x86': 'CpuInfoOther', > + 'sparc': 'CpuInfoOther', > + 'ppc': 'CpuInfoOther', > + 'mips': 'CpuInfoOther', > + 'tricore': 'CpuInfoOther', > + 's390': 'CpuInfoS390', > + 'other': 'CpuInfoOther' } } > > ## > # @query-cpus-fast: I don't think you need CpuInfoArchData, you can have S390CpuState instead and ignore the other archs. It's not like all archs data can be returned at the same time, and also you start having to replicate that arch string list everywhere. Lastly, the arch name is returned by query-target, so no need to duplicate that one either.
On 08.02.2018 17:22, Luiz Capitulino wrote: > On Thu, 8 Feb 2018 16:52:28 +0100 > Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com> wrote: > >> diff --git a/qapi-schema.json b/qapi-schema.json >> index 12c7dc8..0b36860 100644 >> --- a/qapi-schema.json >> +++ b/qapi-schema.json >> @@ -607,7 +607,27 @@ >> ## >> { 'struct': 'CpuInfo2', >> 'data': {'cpu-index': 'int', '*halted': 'bool', 'qom-path': 'str', >> - 'thread-id': 'int', '*props': 'CpuInstanceProperties' } } >> + 'thread-id': 'int', '*props': 'CpuInstanceProperties', >> + '*archdata': 'CpuInfoArchData' } } >> + >> +## >> +# @CpuInfoArchData: >> +# >> +# Architecure specific information about a virtual CPU >> +# >> +# Since: 2.12 >> +# >> +## >> +{ 'union': 'CpuInfoArchData', >> + 'base': { 'arch': 'CpuInfoArch' }, >> + 'discriminator': 'arch', >> + 'data': { 'x86': 'CpuInfoOther', >> + 'sparc': 'CpuInfoOther', >> + 'ppc': 'CpuInfoOther', >> + 'mips': 'CpuInfoOther', >> + 'tricore': 'CpuInfoOther', >> + 's390': 'CpuInfoS390', >> + 'other': 'CpuInfoOther' } } >> >> ## >> # @query-cpus-fast: > > I don't think you need CpuInfoArchData, you can have S390CpuState > instead and ignore the other archs. It's not like all archs data > can be returned at the same time, and also you start having to > replicate that arch string list everywhere. Lastly, the arch name > is returned by query-target, so no need to duplicate that one either. > I don't think I really understood your suggestion. Was it to assume that only s390 will have arch-specific data?. I.e. something along the lines of - 'thread-id': 'int', '*props': 'CpuInstanceProperties' } } + 'thread-id': 'int', '*props': 'CpuInstanceProperties', + '*archdata': 'CpuInfoS390' } } or some kind of in-line, anonymous union? I have to confess I'm pretty QAPI-illiterate, so I may have done it overly complicated. At least it feels that way.
On Thu, 8 Feb 2018 18:02:07 +0100 Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com> wrote: > On 08.02.2018 17:22, Luiz Capitulino wrote: > > On Thu, 8 Feb 2018 16:52:28 +0100 > > Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com> wrote: > > > >> diff --git a/qapi-schema.json b/qapi-schema.json > >> index 12c7dc8..0b36860 100644 > >> --- a/qapi-schema.json > >> +++ b/qapi-schema.json > >> @@ -607,7 +607,27 @@ > >> ## > >> { 'struct': 'CpuInfo2', > >> 'data': {'cpu-index': 'int', '*halted': 'bool', 'qom-path': 'str', > >> - 'thread-id': 'int', '*props': 'CpuInstanceProperties' } } > >> + 'thread-id': 'int', '*props': 'CpuInstanceProperties', > >> + '*archdata': 'CpuInfoArchData' } } > >> + > >> +## > >> +# @CpuInfoArchData: > >> +# > >> +# Architecure specific information about a virtual CPU > >> +# > >> +# Since: 2.12 > >> +# > >> +## > >> +{ 'union': 'CpuInfoArchData', > >> + 'base': { 'arch': 'CpuInfoArch' }, > >> + 'discriminator': 'arch', > >> + 'data': { 'x86': 'CpuInfoOther', > >> + 'sparc': 'CpuInfoOther', > >> + 'ppc': 'CpuInfoOther', > >> + 'mips': 'CpuInfoOther', > >> + 'tricore': 'CpuInfoOther', > >> + 's390': 'CpuInfoS390', > >> + 'other': 'CpuInfoOther' } } > >> > >> ## > >> # @query-cpus-fast: > > > > I don't think you need CpuInfoArchData, you can have S390CpuState > > instead and ignore the other archs. It's not like all archs data > > can be returned at the same time, and also you start having to > > replicate that arch string list everywhere. Lastly, the arch name > > is returned by query-target, so no need to duplicate that one either. > > > I don't think I really understood your suggestion. Was it to assume that > only s390 will have arch-specific data?. I.e. something along the lines of > - 'thread-id': 'int', '*props': 'CpuInstanceProperties' } } > + 'thread-id': 'int', '*props': 'CpuInstanceProperties', > + '*archdata': 'CpuInfoS390' } } > > or some kind of in-line, anonymous union? I have to confess I'm pretty > QAPI-illiterate, so I may have done it overly complicated. At least it > feels that way. Yes, what you propose above is what I had in mind. Maybe the QAPI has some better way to do it though.
diff --git a/cpus.c b/cpus.c index cb04b2c..a972378 100644 --- a/cpus.c +++ b/cpus.c @@ -2099,6 +2099,10 @@ CpuInfo2List *qmp_query_cpus_fast(Error **errp) MachineClass *mc = MACHINE_GET_CLASS(ms); CpuInfo2List *head = NULL, *cur_item = NULL; CPUState *cpu; +#if defined(TARGET_S390X) + S390CPU *s390_cpu; + CPUS390XState *env; +#endif CPU_FOREACH(cpu) { CpuInfo2List *info = g_malloc0(sizeof(*info)); @@ -2122,6 +2126,15 @@ CpuInfo2List *qmp_query_cpus_fast(Error **errp) info->value->halted = cpu->halted; } + /* add architecture specific data if available */ +#if defined(TARGET_S390X) + s390_cpu = S390_CPU(cpu); + env = &s390_cpu->env; + info->value->has_archdata = true; + info->value->archdata = g_malloc0(sizeof(*info->value->archdata)); + info->value->archdata->arch = CPU_INFO_ARCH_S390; + info->value->archdata->u.s390.cpu_state = env->cpu_state; +#endif if (!cur_item) { head = cur_item = info; } else { diff --git a/hmp.c b/hmp.c index 0c36864..bfd1038 100644 --- a/hmp.c +++ b/hmp.c @@ -427,6 +427,17 @@ void hmp_info_cpus_fast(Monitor *mon, const QDict *qdict) } monitor_printf(mon, " qom-path=%s\n", cpu->value->qom_path); monitor_printf(mon, "\n"); + if (cpu->value->has_archdata) { + switch (cpu->value->archdata->arch) { + case CPU_INFO_ARCH_S390: + monitor_printf(mon, " state=%s\n", + CpuInfoS390State_str(cpu->value->archdata-> + u.s390.cpu_state)); + break; + default: + break; + } + } } qapi_free_CpuInfo2List(head); diff --git a/qapi-schema.json b/qapi-schema.json index 12c7dc8..0b36860 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -607,7 +607,27 @@ ## { 'struct': 'CpuInfo2', 'data': {'cpu-index': 'int', '*halted': 'bool', 'qom-path': 'str', - 'thread-id': 'int', '*props': 'CpuInstanceProperties' } } + 'thread-id': 'int', '*props': 'CpuInstanceProperties', + '*archdata': 'CpuInfoArchData' } } + +## +# @CpuInfoArchData: +# +# Architecure specific information about a virtual CPU +# +# Since: 2.12 +# +## +{ 'union': 'CpuInfoArchData', + 'base': { 'arch': 'CpuInfoArch' }, + 'discriminator': 'arch', + 'data': { 'x86': 'CpuInfoOther', + 'sparc': 'CpuInfoOther', + 'ppc': 'CpuInfoOther', + 'mips': 'CpuInfoOther', + 'tricore': 'CpuInfoOther', + 's390': 'CpuInfoS390', + 'other': 'CpuInfoOther' } } ## # @query-cpus-fast: