@@ -1550,13 +1550,15 @@ int cpu_x86_register(X86CPU *cpu, const char *cpu_model)
model_pieces = g_strsplit(cpu_model, ",", 2);
if (!model_pieces[0]) {
- goto error;
+ error_setg(&error, "Invalid/empty CPU model name");
+ goto out;
}
name = model_pieces[0];
features = model_pieces[1];
if (cpu_x86_find_by_name(def, name) < 0) {
- goto error;
+ error_setg(&error, "Unable to find CPU definition: %s", name);
+ goto out;
}
def->kvm_features |= kvm_default_features;
@@ -1566,22 +1568,20 @@ int cpu_x86_register(X86CPU *cpu, const char *cpu_model)
&def->svm_features, &def->cpuid_7_0_ebx_features);
if (cpu_x86_parse_featurestr(def, features) < 0) {
- goto error;
+ error_setg(&error, "Invalid cpu_model string format: %s", cpu_model);
+ goto out;
}
cpudef_2_x86_cpu(cpu, def, &error);
+out:
+ g_strfreev(model_pieces);
if (error) {
fprintf(stderr, "%s\n", error_get_pretty(error));
error_free(error);
- goto error;
+ return -1;
}
-
- g_strfreev(model_pieces);
return 0;
-error:
- g_strfreev(model_pieces);
- return -1;
}
#if !defined(CONFIG_USER_ONLY)