[libvirt] [PATCH 14/23] cputest: Separate QEMUCaps creation from cpuTestCPUIDJson

Jiri Denemark jdenemar at redhat.com
Fri Oct 13 17:27:43 UTC 2017


On Thu, Oct 12, 2017 at 17:20:06 -0400, John Ferlan wrote:
> 
> 
> On 10/04/2017 10:58 AM, Jiri Denemark wrote:
> > To make the code reusable by other tests.
> > 
> > Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
> > ---
> >  tests/cputest.c | 97 +++++++++++++++++++++++++++++++++++----------------------
> >  1 file changed, 60 insertions(+), 37 deletions(-)
> > 
> > diff --git a/tests/cputest.c b/tests/cputest.c
> > index 0a07a2da14..b72c17a168 100644
> > --- a/tests/cputest.c
> > +++ b/tests/cputest.c
> > @@ -460,6 +460,64 @@ cpuTestHasFeature(const void *arg)
> >  }
> >  
> >  
> > +typedef enum {
> > +    JSON_NONE,
> > +    JSON_HOST,
> > +    JSON_MODELS,
> > +} cpuTestCPUIDJson;
> > +
> > +#if WITH_QEMU && WITH_YAJL
> > +static virQEMUCapsPtr
> > +cpuTestMakeQEMUCaps(const struct data *data)
> > +{
> > +    virQEMUCapsPtr qemuCaps = NULL;
> > +    qemuMonitorTestPtr testMon = NULL;
> > +    qemuMonitorCPUModelInfoPtr model = NULL;
> > +    char *json = NULL;
> > +
> > +    if (virAsprintf(&json, "%s/cputestdata/%s-cpuid-%s.json",
> > +                    abs_srcdir, virArchToString(data->arch), data->host) < 0)
> > +        goto error;
> 
> could be cleanup;

Yeah, but since we have the "error" label and we are jumping in case of
error I think it's slightly better to keep it as is. And it's less
fragile when someone comes and shuffles the code around. I don't really
mind either way, though.

Jirka




More information about the libvir-list mailing list