Quoting Chris Venteicher (2018-06-21 23:42:11) > Transient S390 configurations require using QEMU to compute CPU Model > Baseline and to do CPU Feature Expansion. > > Start and use a single QEMU instance to do both the baseline and > expansion transactions required by BaselineHypervisorCPU. > --- > src/qemu/qemu_driver.c | 66 ++++++++++++++++++++++++++++++++++++------ > 1 file changed, 57 insertions(+), 9 deletions(-) > > diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c > index 921aafcd79..868d6087a9 100644 > --- a/src/qemu/qemu_driver.c > +++ b/src/qemu/qemu_driver.c > @@ -13419,10 +13419,13 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn, > virArch arch; > virDomainVirtType virttype; > virDomainCapsCPUModelsPtr cpuModels; > - bool migratable; > + bool migratable_only; > virCPUDefPtr cpu = NULL; > char *cpustr = NULL; > char **features = NULL; > + virQEMUCapsInitQMPCommandPtr cmd = NULL; > + bool forceTCG = false; > + qemuMonitorCPUModelInfoPtr modelInfo = NULL; > > virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES | > VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL); > @@ -13430,8 +13433,6 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn, > if (virConnectBaselineHypervisorCPUEnsureACL(conn) < 0) > goto cleanup; > > - migratable = !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE); > - > if (!(cpus = virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_AUTO))) > goto cleanup; > > @@ -13444,6 +13445,19 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn, > if (!qemuCaps) > goto cleanup; > > + /* QEMU can enumerate non-migratable cpu model features for some archs > like x86 > + * migratable_only == true: ask for and include only migratable features > + * migratable_only == false: ask for and include all features > + */ > + migratable_only = !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE); > + > + if (ARCH_IS_S390(arch)) { > + /* QEMU for S390 arch only enumerates migratable features > + * No reason to explicitly ask QEMU for or include non-migratable > features > + */ > + migratable_only = true; > + } > + > if (!(cpuModels = virQEMUCapsGetCPUDefinitions(qemuCaps, virttype)) || > cpuModels->nmodels == 0) { > virReportError(VIR_ERR_OPERATION_UNSUPPORTED, > @@ -13456,18 +13470,31 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn, > > if (ARCH_IS_X86(arch)) { > int rc = virQEMUCapsGetCPUFeatures(qemuCaps, virttype, > - migratable, &features); > + migratable_only, &features); > if (rc < 0) > goto cleanup; > if (features && rc == 0) { > /* We got only migratable features from QEMU if we asked for > them, > * no further filtering in virCPUBaseline is desired. */ > - migratable = false; > + migratable_only = false; > } > > if (!(cpu = virCPUBaseline(arch, cpus, ncpus, cpuModels, > - (const char **)features, migratable))) > + (const char **)features, > migratable_only))) > goto cleanup; > + } else if (ARCH_IS_S390(arch)) { > + > + const char *binary = virQEMUCapsGetBinary(qemuCaps); > + virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); > + > + if (!(cmd = virQEMUCapsNewQMPCommandConnection(binary, cfg->libDir, > + cfg->user, cfg->group, > + forceTCG))) > + goto cleanup; > + > + if (virQEMUCapsQMPBaselineCPUModel(cmd, cpus, &cpu) < 0) > + goto cleanup; /* Content Error */
Cover usecase where qemu doesn't support baseline and returns 0 but cpu is NULL. > + > } else { > virReportError(VIR_ERR_OPERATION_UNSUPPORTED, > _("computing baseline hypervisor CPU is not supported > " > @@ -13477,9 +13504,28 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn, > > cpu->fallback = VIR_CPU_FALLBACK_FORBID; > > - if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) && > - virCPUExpandFeatures(arch, cpu) < 0) > - goto cleanup; > + if (flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) { > + if (ARCH_IS_X86(arch)) { > + if (virCPUExpandFeatures(arch, cpu) < 0) > + goto cleanup; > + } else if (ARCH_IS_S390(arch)) { > + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION)) > + goto cleanup; > + > + if (!(modelInfo = virQEMUCapsCPUModelInfoFromCPUDef(cpu))) > + goto cleanup; > + Were commited to expanding the cpu definition and failure to do so is an error and should not result in updating the model in the output with an unexpanded feature set. Don't let an error case or lack of support by QEMU for expansion return an unexpanded feature set when user asked for expanded. > > + if (qemuMonitorGetCPUModelExpansion(cmd->mon, > + > QEMU_MONITOR_CPU_MODEL_EXPANSION_FULL, > + migratable_only, modelInfo) < > 0) > + goto cleanup; > + > + virCPUDefFree(cpu); > + Expansion enumerates all features and indicates true/false to indicate if feature is/isn't included. Baseline only returns a list of features that are included (true). Filter out all the features that are not included (false) prior to creating the cpu definition. > + if (!(cpu = virQEMUCapsCPUModelInfoToCPUDef(migratable_only, > modelInfo))) > + goto cleanup; > + } > + } > > cpustr = virCPUDefFormat(cpu, NULL); > > @@ -13488,6 +13534,8 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn, > virCPUDefFree(cpu); > virObjectUnref(qemuCaps); > virStringListFree(features); > + virQEMUCapsInitQMPCommandFree(cmd); > + qemuMonitorCPUModelInfoFree(modelInfo); > > return cpustr; > } > -- > 2.17.1 > -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list