On Wed, Nov 26, 2008 at 08:54:40PM +0000, Daniel P. Berrange wrote:
[..snip..]
Hmm, interesting idea - we already have a variant for parsing based
off an arbitrary XML node, rather than assuming the root,
virDomainDefPtr virDomainDefParseNode(virConnectPtr conn,
virCapsPtr caps,
xmlDocPtr doc,
xmlNodePtr root);
So we could add a wrapper function which writes out a XML doc
<domstate state="running" pid="1234">
<monitor path="/dev/pts/4">
<domain id='32'>
... normal domain XML config ...
</domain>
</domstate>
And so have a function
virDomainObjPtr virDomainObjParse(const char *filename)
which'd parse the custom QEMU state, and then just invoke the
virDomainDefParseNode for the nested <domain> tag.
Yes, nice - this
simplifies things. I'll try that.
Now, some things like VNC port, domain ID really are easily tracked
in the regular domain XML - rather than adding VIR_DOMAIN_XML_STATE
I've a slight alternative idea.
The formatXML methods already accept a flag VIR_DOMAIN_XML_INACTIVE
which when passed causes it to skip some attributes which only
make sense for running VMs - VNC port, ID, VIF name
The parseXML methods, just hardcode this and always skip these
attributes. We should fix this so the parsing only skips these
attrs if this same VIR_DOMAIN_XML_INACTIVE flag is passed. Then
just make sure all existing code is changed to set this flag
when parsing XML. The code for loading VM from disk can simply
not set this flag. Technically the LXC driver shold be doing
this already, precisely for the VIF name issue.
Like the attached patch?
-- Guido