[libvirt] [PATCH v2 9/9] cpu-baseline command for virsh

Daniel Veillard veillard at redhat.com
Thu Feb 11 20:37:58 UTC 2010


On Thu, Feb 11, 2010 at 08:49:54PM +0100, Jiri Denemark wrote:
> > > +    if (virFileReadAll(from, VIRSH_MAX_XML_FILE, &buffer) < 0)
> > > +        return FALSE;
> > > +
> > > +    p = buffer;
> > > +    while ((p = strstr(p, "<cpu>"))) {
> > > +        list = vshRealloc(ctl, list, sizeof(char *) * (count + 1));
> > > +        list[count++] = p;
> > > +
> > > +        if ((p = strstr(p, "</cpu>"))) {
> > > +            p += strlen("</cpu>");
> > > +            if (*p != '\0') {
> > > +                *p = '\0';
> > > +                p++;
> > > +            }
> > > +        }
> > > +    }
> > 
> >   Aye aye aye ...  I understand what you're trying to do but I think
> > this is a bit weird  ... I think we should be able to come with an
> > alternative, cleaner based on parsing the content as an XML well
> > balanced fragment and then reserialize all cpu elements found.
> >   Your scheme would explode for example if we tried to add a <cpu>
> > element as one possible child of <cpu> or if we added attributes to
> > <cpu>, it's too fragile. I can think the other parts can be commited
> > independantly anyway.
> 
> Yeah, it's ugly but I wanted to avoid the complexity of parsing XML and
> formating back to a string. And I still don't think it is a good idea. Maybe I

  Not that hard. The harder is to get libvirt to accept something like a
concatenation

----------------
<cpu>
  ...
</cpu>
<cpu>
  ...
</cpu>
----------------

But I know how to do it (nut never pretend it's XML :-)

> could extend virsh to support variable number of arguments and take each CPU
> definition from its own file.

virsh being a shell tool, it's easy in a shell to concatenate multiple
input but very hard to split out pieces from XML fragment, so the
current suggestion is IMHO the simplest for users, but the way it's done
need to be refined a bit ;-)

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/




More information about the libvir-list mailing list