Recent changes have added a 'canonical_name' field to the xml definitions for our CPU models. Parse this field into the C structure and pass it around where necessary. --- src/conf/cpu_conf.c | 3 +++ src/conf/cpu_conf.h | 1 + src/cpu/cpu_x86.c | 24 ++++++++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 7abe489733..a771893956 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -113,6 +113,7 @@ void ATTRIBUTE_NONNULL(1) virCPUDefFreeModel(virCPUDef *def) { VIR_FREE(def->model); + VIR_FREE(def->canonical_model); VIR_FREE(def->vendor); VIR_FREE(def->vendor_id); virCPUDefFreeFeatures(def); @@ -161,6 +162,7 @@ virCPUDefCopyModelFilter(virCPUDef *dst, dst->features = g_new0(virCPUFeatureDef, src->nfeatures); dst->model = g_strdup(src->model); + dst->canonical_model = g_strdup(src->canonical_model); dst->vendor = g_strdup(src->vendor); dst->vendor_id = g_strdup(src->vendor_id); dst->microcodeVersion = src->microcodeVersion; @@ -211,6 +213,7 @@ virCPUDefStealModel(virCPUDef *dst, virCPUDefFreeModel(dst); dst->model = g_steal_pointer(&src->model); + dst->canonical_model = g_steal_pointer(&src->canonical_model); dst->features = g_steal_pointer(&src->features); dst->microcodeVersion = src->microcodeVersion; dst->nfeatures_max = src->nfeatures_max; diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h index 3e4c53675c..ba8dab6c7f 100644 --- a/src/conf/cpu_conf.h +++ b/src/conf/cpu_conf.h @@ -142,6 +142,7 @@ struct _virCPUDef { virCPUCheck check; virArch arch; char *model; + char *canonical_model; char *vendor_id; /* vendor id returned by CPUID in the guest */ int fallback; /* enum virCPUFallback */ char *vendor; diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 8d0e3947ce..70800d9579 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -142,6 +142,7 @@ struct _virCPUx86Signatures { typedef struct _virCPUx86Model virCPUx86Model; struct _virCPUx86Model { char *name; + char *canonical_name; bool decodeHost; bool decodeGuest; virCPUx86Vendor *vendor; @@ -864,6 +865,7 @@ x86DataToCPU(const virCPUx86Data *data, cpu = virCPUDefNew(); cpu->model = g_strdup(model->name); + cpu->canonical_model = g_strdup(model->canonical_name); x86DataCopy(©, data); x86DataCopy(&modelData, &model->data); @@ -1281,6 +1283,7 @@ x86ModelFree(virCPUx86Model *model) return; g_free(model->name); + g_free(model->canonical_name); virCPUx86SignaturesFree(model->signatures); virCPUx86DataClear(&model->data); g_strfreev(model->removedFeatures); @@ -1296,6 +1299,7 @@ x86ModelCopy(virCPUx86Model *model) copy = g_new0(virCPUx86Model, 1); copy->name = g_strdup(model->name); + copy->canonical_name = g_strdup(model->canonical_name); copy->signatures = virCPUx86SignaturesCopy(model->signatures); x86DataCopy(©->data, &model->data); copy->removedFeatures = g_strdupv(model->removedFeatures); @@ -1451,6 +1455,17 @@ x86ModelCompare(virCPUx86Model *model1, } +static int +x86ModelParseCanonicalName(virCPUx86Model *model, + xmlXPathContextPtr ctxt) +{ + if (!(model->canonical_name = virXPathString("string(./canonical_name[1])", ctxt))) + model->canonical_name = g_strdup(model->name); + + return 0; +} + + static int x86ModelParseDecode(virCPUx86Model *model, xmlXPathContextPtr ctxt) @@ -1668,6 +1683,9 @@ x86ModelParse(xmlXPathContextPtr ctxt, model = g_new0(virCPUx86Model, 1); model->name = g_strdup(name); + if (x86ModelParseCanonicalName(model, ctxt) < 0) + return -1; + if (x86ModelParseDecode(model, ctxt) < 0) return -1; @@ -2268,6 +2286,7 @@ x86Decode(virCPUDef *cpu, sigFamily, sigModel, sigStepping); cpu->model = g_steal_pointer(&cpuModel->model); + cpu->canonical_model = g_steal_pointer(&cpuModel->canonical_model); cpu->features = g_steal_pointer(&cpuModel->features); cpu->nfeatures = cpuModel->nfeatures; cpuModel->nfeatures = 0; @@ -3010,6 +3029,11 @@ virCPUx86Update(virCPUDef *guest, return -1; } + if (guestModel->canonical_name) { + g_free(guest->canonical_model); + guest->canonical_model = g_strdup(guestModel->canonical_name); + } + if (virCPUx86DisableRemovedFeatures(guest, guestModel) < 0) return -1; -- 2.41.0 _______________________________________________ Devel mailing list -- devel@xxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx