[libvirt] [PATCH v3 06/20] Make qemuCapsProbeMachineTypes & qemuCapsProbeCPUModels static

Jiri Denemark jdenemar at redhat.com
Wed Sep 26 13:00:31 UTC 2012


On Wed, Sep 26, 2012 at 13:56:22 +0100, Daniel P. Berrange wrote:
> On Wed, Sep 26, 2012 at 11:42:09AM +0200, Jiri Denemark wrote:
> > On Tue, Sep 25, 2012 at 18:59:59 +0100, Daniel P. Berrange wrote:
> > > 
> > > -        p = t;
> > > -        if (!(t = strstr(p, "(default)")) || (next && t >= next)) {
> > > -            list[nitems++] = machine;
> > > -        } else {
> > > -            /* put the default first in the list */
> > > -            memmove(list + 1, list, sizeof(*list) * nitems);
> > > -            list[0] = machine;
> > > -            nitems++;
> > > -        }
> > > +        if (strstr(p, "(default)"))
> > > +            defIdx = caps->nmachineTypes;
> > 
> > While this will work because it sets defIdx to 1, 2, 4, ... until it stops at
> > the one which is really default. Can we preserve the condition that checks if
> > (default) was found at the current line rather than just somewhere in the rest
> > of the qemu output to make this less magic? And I would even preserve the
> > p = t assignment above.
> 
> Ok, so IIUC the folowing change:
> 
> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index fed7a06..b519db7 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -328,7 +328,8 @@ qemuCapsParseMachineTypesStr(const char *output,
>          if (!(name = strndup(p, t - p)))
>              goto no_memory;
>  
> -        if (strstr(p, "(default)"))
> +        p = t;
> +        if (!(t = strstr(p, "(default)")) && (!next || t < next)) {
>              defIdx = caps->nmachineTypes;
>  
>          if ((t = strstr(p, "(alias of ")) && (!next || t < next)) {

Right, that's what I had in mind.

Jirka




More information about the libvir-list mailing list