static S390CPUModel *get_max_cpu_model(Error **errp) { #ifndef CONFIG_USER_ONLY static S390CPUModel max_model; static bool cached; if (cached) { return &max_model; } if (kvm_enabled()) { kvm_s390_get_host_cpu_model(&max_model, errp); } else { /* TCG enulates a z900 */ max_model.def = &s390_cpu_defs[0]; bitmap_copy(max_model.features, max_model.def->default_feat, S390_FEAT_MAX); } if (!*errp) { cached = true; return &max_model; } #endif return NULL; }
static void s390_host_cpu_model_initfn(Object *obj) { S390CPU *cpu = S390_CPU(obj); Error *err = NULL; if (!kvm_enabled() || !kvm_s390_cpu_models_supported()) { return; } cpu->model = g_malloc0(sizeof(*cpu->model)); kvm_s390_get_host_cpu_model(cpu->model, &err); if (err) { error_report_err(err); g_free(cpu->model); /* fallback to unsupported cpu models */ cpu->model = NULL; } }
static S390CPUModel *get_max_cpu_model(Error **errp) { static S390CPUModel max_model; static bool cached; if (cached) { return &max_model; } if (kvm_enabled()) { kvm_s390_get_host_cpu_model(&max_model, errp); } else { /* TCG emulates a z900 (with some optional additional features) */ max_model.def = &s390_cpu_defs[0]; bitmap_copy(max_model.features, max_model.def->default_feat, S390_FEAT_MAX); add_qemu_cpu_model_features(max_model.features); } if (!*errp) { cached = true; return &max_model; } return NULL; }