From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:40281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1R7N-000110-SB for qemu-devel@nongnu.org; Fri, 01 Feb 2013 19:38:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U1R7L-0007rX-PE for qemu-devel@nongnu.org; Fri, 01 Feb 2013 19:38:05 -0500 Received: from cantor2.suse.de ([195.135.220.15]:51150 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1R7L-0007UY-GI for qemu-devel@nongnu.org; Fri, 01 Feb 2013 19:38:03 -0500 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Sat, 2 Feb 2013 01:37:06 +0100 Message-Id: <1359765428-27805-3-git-send-email-afaerber@suse.de> In-Reply-To: <1359765428-27805-1-git-send-email-afaerber@suse.de> References: <1359765428-27805-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-next v3 2/4] target-i386: Split command line parsing out of cpu_x86_register() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: blauwirbel@gmail.com, imammedo@redhat.com, ehabkost@redhat.com, anthony@codemonkey.ws, =?UTF-8?q?Andreas=20F=C3=A4rber?= In order to instantiate a CPU subtype we will need to know which type, so move the cpu_model splitting into cpu_x86_init(). Parameters need to be set on the X86CPU instance, so move cpu_x86_parse_featurestr() into cpu_x86_init() as well. This leaves cpu_x86_register() operating on the model name only. Signed-off-by: Andreas F=C3=A4rber --- target-i386/cpu.c | 50 +++++++++++++++++++++++++++++++----------------= --- 1 Datei ge=C3=A4ndert, 31 Zeilen hinzugef=C3=BCgt(+), 19 Zeilen entfernt= (-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index e74802b..ee2fd6b 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -1516,24 +1516,14 @@ static void filter_features_for_kvm(X86CPU *cpu) } #endif =20 -static int cpu_x86_register(X86CPU *cpu, const char *cpu_model) +static int cpu_x86_register(X86CPU *cpu, const char *name) { CPUX86State *env =3D &cpu->env; x86_def_t def1, *def =3D &def1; Error *error =3D NULL; - char *name, *features; - gchar **model_pieces; =20 memset(def, 0, sizeof(*def)); =20 - model_pieces =3D g_strsplit(cpu_model, ",", 2); - if (!model_pieces[0]) { - error_setg(&error, "Invalid/empty CPU model name"); - goto out; - } - name =3D model_pieces[0]; - features =3D model_pieces[1]; - if (cpu_x86_find_by_name(def, name) < 0) { error_setg(&error, "Unable to find CPU definition: %s", name); goto out; @@ -1565,9 +1555,7 @@ static int cpu_x86_register(X86CPU *cpu, const char= *cpu_model) goto out; } =20 - cpu_x86_parse_featurestr(cpu, features, &error); out: - g_strfreev(model_pieces); if (error) { fprintf(stderr, "%s\n", error_get_pretty(error)); error_free(error); @@ -1578,26 +1566,50 @@ out: =20 X86CPU *cpu_x86_init(const char *cpu_model) { - X86CPU *cpu; + X86CPU *cpu =3D NULL; CPUX86State *env; + gchar **model_pieces; + char *name, *features; Error *error =3D NULL; =20 + model_pieces =3D g_strsplit(cpu_model, ",", 2); + if (!model_pieces[0]) { + error_setg(&error, "Invalid/empty CPU model name"); + goto error; + } + name =3D model_pieces[0]; + features =3D model_pieces[1]; + cpu =3D X86_CPU(object_new(TYPE_X86_CPU)); env =3D &cpu->env; env->cpu_model_str =3D cpu_model; =20 - if (cpu_x86_register(cpu, cpu_model) < 0) { - object_delete(OBJECT(cpu)); - return NULL; + if (cpu_x86_register(cpu, name) < 0) { + goto error; + } + + cpu_x86_parse_featurestr(cpu, features, &error); + if (error) { + goto error; } =20 object_property_set_bool(OBJECT(cpu), true, "realized", &error); if (error) { + goto error; + } + g_strfreev(model_pieces); + return cpu; + +error: + g_strfreev(model_pieces); + if (error) { + fprintf(stderr, "%s\n", error_get_pretty(error)); error_free(error); + } + if (cpu !=3D NULL) { object_delete(OBJECT(cpu)); - return NULL; } - return cpu; + return NULL; } =20 #if !defined(CONFIG_USER_ONLY) --=20 1.7.10.4