On Wed, Sep 23, 2020 at 22:26:28 -0400, Collin Walling wrote: > When executing the hypervisor-cpu-compare/baseline commands and > the XML file contains a CPU definition using host-passthrough > and no model name, the commands will fail and return an error > message from the QMP response. That's the expected and correct behavior, only the error message is should be better and reported directly by libvirt. > Let's fix this by checking for host-passthrough and a missing > model name after the CPU definition has been converted from > XML. If these conditions are matched, then the CPU definition's > model name will be set to "host". > > Signed-off-by: Collin Walling <walling@xxxxxxxxxxxxx> > --- > src/qemu/qemu_driver.c | 41 +++++++++++++++++++++++++++++++---------- > 1 file changed, 31 insertions(+), 10 deletions(-) > > diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c > index 1cecef01f7..427d2419f3 100644 > --- a/src/qemu/qemu_driver.c > +++ b/src/qemu/qemu_driver.c > @@ -12281,6 +12281,26 @@ qemuConnectCPUModelComparison(virQEMUCapsPtr qemuCaps, > } > > > +static int > +qemuConnectCheckCPUModel(virCPUDefPtr cpu) > +{ > + if (!cpu->model) { > + /* > + * On some architectures a model name is never present > + * for the host-passthrough mode, so default it to "host" > + */ > + if (cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH) { > + cpu->model = g_strdup("host"); > + } else { > + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", > + _("cpu parameter is missing a model name")); > + return -1; > + } > + } > + return 0; > +} > + > + > static int > qemuConnectCompareHypervisorCPU(virConnectPtr conn, > const char *emulator, ... > @@ -12470,10 +12484,17 @@ qemuConnectCPUModelBaseline(virQEMUCapsPtr qemuCaps, > if (VIR_ALLOC(baseline) < 0) > return NULL; > > - if (virCPUDefCopyModel(baseline, cpus[0], false)) > + if (qemuConnectCheckCPUModel(cpus[0]) < 0) > + return NULL; > + > + if (virCPUDefCopyModel(baseline, cpus[0], false) < 0) > return NULL; > > for (i = 1; i < ncpus; i++) { > + > + if (qemuConnectCheckCPUModel(cpus[i]) < 0) > + return NULL; > + > if (qemuMonitorGetCPUModelBaseline(proc->mon, baseline, > cpus[i], &result) < 0) > return NULL; As explained in the "qemu: substitute missing model name for host-passthrough" thread, we should only make sure all CPUs passed to the baseline API have a non-empty <model> element. Jirka