[libvirt] [PATCH v2 9/9] cpu-baseline command for virsh
Daniel P. Berrange
berrange at redhat.com
Fri Feb 12 11:05:54 UTC 2010
On Thu, Feb 11, 2010 at 09:37:58PM +0100, Daniel Veillard wrote:
> 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 :-)
Isn't there anyway to get the XML parser to stop processing input once it
has parsed one complete document, without consuming the rest of the data
in the file. eg
> <cpu>
> ...
> </cpu>
Make it stop here ^^^
Then, invoke it again to parse the next document in the file
> <cpu>
> ...
> </cpu>
And so on....
Daniel
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
More information about the libvir-list
mailing list