From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33295) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUBvs-0006G4-5h for qemu-devel@nongnu.org; Fri, 12 Feb 2016 06:30:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aUBvn-0000uU-To for qemu-devel@nongnu.org; Fri, 12 Feb 2016 06:30:39 -0500 Received: from mx2.suse.de ([195.135.220.15]:53016) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aUBvn-0000uK-Fn for qemu-devel@nongnu.org; Fri, 12 Feb 2016 06:30:35 -0500 References: <1455268436-1244-1-git-send-email-valentin.rakush@gmail.com> From: =?UTF-8?Q?Andreas_F=c3=a4rber?= Message-ID: <56BDC25A.9030003@suse.de> Date: Fri, 12 Feb 2016 12:30:34 +0100 MIME-Version: 1.0 In-Reply-To: <1455268436-1244-1-git-send-email-valentin.rakush@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH RFC] qmp, target-i386: device_list_properties for TYPE_CPU List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Valentin Rakush , qemu-devel@nongnu.org Cc: Eduardo Habkost , Markus Armbruster , Luiz Capitulino , asmetanin@virtuozzo.com, den@openvz.org Hi, Am 12.02.2016 um 10:13 schrieb Valentin Rakush: > This is RFC because there is another implementation option: it is > possible to implement this functionality in the object_finalize for > all available targets. All targets change will require more testing. > Please let me know if all targets should be changed at once. I thought I had already seen some Fujitsu/IBM patch to fix this... (pointers appreciated) It should be fixed on the level where the problem is introduced - i.e. if qom/cpu.c calls the cpu_exec_init() in instance_init it needs to call the corresponding exit function in instance_finalize; dito for target-i386/cpu.c or wherever. Or we try to move it from instance_init to realize, avoiding it getting called in the first place. >=20 > This patch changes qmp_device_list_properties and only target-i386 > to allow TYPE_CPU class properties to be quered with QMP interface and > with -device core2duo-x86_64-cpu,help command line. >=20 > Signed-off-by: Valentin Rakush > Cc: Luiz Capitulino > Cc: Eric Blake > Cc: Markus Armbruster > Cc: Andreas F=C3=A4rber > Cc: Daniel P. Berrange > Cc: Eduardo Habkost > --- > qmp.c | 19 +++++++++++++++++++ > target-i386/cpu.c | 32 ++++++++++++++++++++++++++++++-- > 2 files changed, 49 insertions(+), 2 deletions(-) >=20 > diff --git a/qmp.c b/qmp.c > index 6ae7230..2721f16 100644 > --- a/qmp.c > +++ b/qmp.c > @@ -516,6 +516,7 @@ DevicePropertyInfoList *qmp_device_list_properties(= const char *typename, > Error **errp) > { > ObjectClass *klass; > + ObjectClass *cpu_klass; Please use cpu_class, only "class" is a reserved identifier. > Object *obj; > ObjectProperty *prop; > ObjectPropertyIterator iter; > @@ -580,6 +581,24 @@ DevicePropertyInfoList *qmp_device_list_properties= (const char *typename, > prop_list =3D entry; > } > =20 > + cpu_klass =3D object_class_dynamic_cast(klass, TYPE_CPU); > + if (cpu_klass) { > + CPUState *tmp_cpu =3D CPU(obj); > + CPUState *cs =3D first_cpu; > + > + CPU_FOREACH(cs) { > + if (tmp_cpu->cpu_index =3D=3D cs->cpu_index) { > +#if defined(CONFIG_USER_ONLY) > + cpu_list_lock(); > +#endif > + QTAILQ_REMOVE(&cpus, cs, node); > +#if defined(CONFIG_USER_ONLY) > + cpu_list_unlock(); > +#endif > + } > + } > + } > + > object_unref(obj); > =20 > return prop_list; > diff --git a/target-i386/cpu.c b/target-i386/cpu.c > index 3fa14bf..8c32794 100644 > --- a/target-i386/cpu.c > +++ b/target-i386/cpu.c > @@ -1479,7 +1479,7 @@ static void host_x86_cpu_class_init(ObjectClass *= oc, void *data) > =20 > dc->props =3D host_x86_cpu_properties; > /* Reason: host_x86_cpu_initfn() dies when !kvm_enabled() */ > - dc->cannot_destroy_with_object_finalize_yet =3D true; > + dc->cannot_destroy_with_object_finalize_yet =3D false; > } > =20 > static void host_x86_cpu_initfn(Object *obj) > @@ -3225,11 +3225,39 @@ static void x86_cpu_common_class_init(ObjectCla= ss *oc, void *data) > cc->cpu_exec_enter =3D x86_cpu_exec_enter; > cc->cpu_exec_exit =3D x86_cpu_exec_exit; > =20 > + object_class_property_add(oc, "family", "int", > + x86_cpuid_version_get_family, > + x86_cpuid_version_set_family, NULL, NULL, NULL= ); You add class properties here but I don't see you deleting the previous instance properties anywhere? > + object_class_property_add(oc, "model", "int", > + x86_cpuid_version_get_model, > + x86_cpuid_version_set_model, NULL, NULL, NULL)= ; > + object_class_property_add(oc, "stepping", "int", > + x86_cpuid_version_get_stepping, > + x86_cpuid_version_set_stepping, NULL, NULL, NU= LL); > + object_class_property_add_str(oc, "vendor", > + x86_cpuid_get_vendor, > + x86_cpuid_set_vendor, NULL); > + object_class_property_add_str(oc, "model-id", > + x86_cpuid_get_model_id, > + x86_cpuid_set_model_id, NULL); > + object_class_property_add(oc, "tsc-frequency", "int", > + x86_cpuid_get_tsc_freq, > + x86_cpuid_set_tsc_freq, NULL, NULL, NULL); > + object_class_property_add(oc, "apic-id", "int", > + x86_cpuid_get_apic_id, > + x86_cpuid_set_apic_id, NULL, NULL, NULL); > + object_class_property_add(oc, "feature-words", "X86CPUFeatureWordI= nfo", > + x86_cpu_get_feature_words, > + NULL, NULL, NULL, NULL); > + object_class_property_add(oc, "filtered-features", "X86CPUFeatureW= ordInfo", > + x86_cpu_get_feature_words, > + NULL, NULL, NULL, NULL); > + > /* > * Reason: x86_cpu_initfn() calls cpu_exec_init(), which saves the > * object in cpus -> dangling pointer after final object_unref(). > */ > - dc->cannot_destroy_with_object_finalize_yet =3D true; > + dc->cannot_destroy_with_object_finalize_yet =3D false; This looks bogus, Markus will need to take a close look. > } > =20 > static const TypeInfo x86_cpu_type_info =3D { >=20 Regards, Andreas --=20 SUSE Linux GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany GF: Felix Imend=C3=B6rffer, Jane Smithard, Graham Norton; HRB 21284 (AG N= =C3=BCrnberg)