[libvirt] [PATCH] Add warning message to XML definition files stored on disk

Eric Blake eblake at redhat.com
Thu Apr 28 20:06:15 UTC 2011


On 04/28/2011 10:34 AM, Michal Privoznik wrote:
> Users often edit XML domain file stored in configuration directory
> thinking of modifying a domain/network/pool/etc. Thus it is wise
> to let them know they are using the wrong way and give them hint.

> +++ b/src/conf/domain_conf.c
> @@ -8543,6 +8543,7 @@ int virDomainSaveConfig(const char *configDir,
>                                     VIR_DOMAIN_XML_WRITE_FLAGS)))
>          goto cleanup;
>  
> +    virSavePrependWarning(&xml);
>      if (virDomainSaveXML(configDir, def, xml))

Prepending can be expensive - in the middle of the operation, we have to
have twice the space for xml malloc'd, and we are also spending time on
a memcpy from old memory to new.  Is there any way to instead change
virDomainSaveXML and friends to take a flags argument, and pass 0 from
most callers but VIR_XML_EMIT_WARNING from these particular callers;
then if the flag is set, they call the common helper function:

virEmitXMLWarning(int fd)

which outputs the message directly into the target file prior to
outputting xml?  That would be less memory pressure and copying involved.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110428/c1e9e0d8/attachment-0001.sig>


More information about the libvir-list mailing list