[libvirt PATCH 8/9] tests: cpu: Allow passing flags to cpuTestLoadXML
Tim Wiederhake
twiederh at redhat.com
Wed Sep 30 11:54:50 UTC 2020
On Tue, 2020-09-29 at 11:21 +0200, Peter Krempa wrote:
> (...)
> On Mon, Sep 21, 2020 at 15:07:31 +0200, Tim Wiederhake wrote:
> > Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
> > ---
> > tests/cputest.c | 45 ++++++++++++++++++++++++++++++---------------
> > 1 file changed, 30 insertions(+), 15 deletions(-)
> >
> > diff --git a/tests/cputest.c b/tests/cputest.c
> > index b40fd7f7f2..30a125c3da 100644
> > --- a/tests/cputest.c
> > +++ b/tests/cputest.c
> > @@ -203,12 +203,20 @@ cpuTestCompare(const void *arg)
> > virCPUDefPtr host = NULL;
> > virCPUDefPtr cpu = NULL;
> > virCPUCompareResult result;
> > + bool validate = !!(data->flags &
> > VIR_CONNECT_COMPARE_CPU_VALIDATE_XML);
> >
> > - if (!(host = cpuTestLoadXML(data->arch, data->host)) ||
> > - !(cpu = cpuTestLoadXML(data->arch, data->name)))
> > - goto cleanup;
> > + host = cpuTestLoadXML(data->arch, data->host, validate);
> > + cpu = cpuTestLoadXML(data->arch, data->name, validate);
> > +
> > + if (!host || !cpu) {
> > + if (validate)
> > + result = VIR_CPU_COMPARE_ERROR;
> > + else
> > + goto cleanup;
> > + } else {
> > + result = virCPUCompare(host->arch, host, cpu, false);
> > + }
>
> (...) Also reporting a
> validation failure as a COMPARE_ERROR seems wrong IMO.
The enum virCPUCompareResult in libvirt-host.h defines the values
VIR_CPU_COMPARE_{ERROR,INCOMPATIBLE,IDENTICAL,SUPERSET}. I believe
VIR_CPU_COMPARE_ERROR to be correct here, but have rewritten this part
for v3.
Tim
More information about the libvir-list
mailing list