Received: from eggs.gnu.org ([2001:4830:134:3::10]:53232) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKfWc-0004Rj-Pj for qemu-devel@nongnu.org; Mon, 03 Mar 2014 21:56:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WKfWU-0004kC-At for qemu-devel@nongnu.org; Mon, 03 Mar 2014 21:56:10 -0500 Received: from cantor2.suse.de ([195.135.220.15]:49658 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKfWU-0004jf-4i for qemu-devel@nongnu.org; Mon, 03 Mar 2014 21:56:02 -0500 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Tue, 4 Mar 2014 03:55:48 +0100 Message-Id: <1393901749-5944-6-git-send-email-afaerber@suse.de> In-Reply-To: <1393901749-5944-1-git-send-email-afaerber@suse.de> References: <1393901749-5944-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH qom-cpu 5/6] cpu: Implement CPUClass::parse_features() for the rest of CPUs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alexey Kardashevskiy , Igor Mammedov , Eduardo Habkost , =?UTF-8?q?Andreas=20F=C3=A4rber?= CPUs who do not provide their own implementation of feature parsing will treat each option as a QOM property and set it to the supplied value. Signed-off-by: Andreas F=C3=A4rber --- qom/cpu.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/qom/cpu.c b/qom/cpu.c index 84c51e5..70fea7b 100644 --- a/qom/cpu.c +++ b/qom/cpu.c @@ -1,7 +1,7 @@ /* * QEMU CPU model * - * Copyright (c) 2012 SUSE LINUX Products GmbH + * Copyright (c) 2012-2014 SUSE LINUX Products GmbH * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -218,6 +218,34 @@ static ObjectClass *cpu_common_class_by_name(const c= har *cpu_model) return NULL; } =20 +static void cpu_common_parse_features(CPUState *cpu, char *features, + Error **errp) +{ + char *featurestr; /* Single "key=3Dvalue" string being parsed */ + char *val; + Error *err =3D NULL; + + featurestr =3D features ? strtok(features, ",") : NULL; + + while (featurestr) { + val =3D strchr(featurestr, '=3D'); + if (val) { + *val =3D 0; + val++; + object_property_parse(OBJECT(cpu), val, featurestr, &err); + if (err) { + error_propagate(errp, err); + return; + } + } else { + error_setg(errp, "Expected key=3Dvalue format, found %s.", + featurestr); + return; + } + featurestr =3D strtok(NULL, ","); + } +} + static void cpu_common_realizefn(DeviceState *dev, Error **errp) { CPUState *cpu =3D CPU(dev); @@ -248,6 +276,7 @@ static void cpu_class_init(ObjectClass *klass, void *= data) CPUClass *k =3D CPU_CLASS(klass); =20 k->class_by_name =3D cpu_common_class_by_name; + k->parse_features =3D cpu_common_parse_features; k->reset =3D cpu_common_reset; k->get_arch_id =3D cpu_common_get_arch_id; k->has_work =3D cpu_common_has_work; --=20 1.8.4.5